Simplified-JBoss way to have POJO RPC in Java with container session management

Currently I only know the RPC way for POJOs in Java and with a very complex EJB / JBoss solution.

Is there a better way to provide similar functionality with a thinner layer (inside or without a Java EE container), using RMI, or something that can serialize and send objects fully wire-spaced?

I am not currently interested in BTW HTTP / JSON serialization.

EDIT: For clarification: I'm trying to replace the old EJB 2.1 / JBoss 4 solution with something more manageable at the container level. I need to have full control over the database (planning to use iBATIS, which would allow me to use fairly complex SQL very easily), but the only thing I want to keep over the wire is:

  • Calling methods for finding / changing data (automatic serialization takes place here).
  • Transparent session control (authentication / authorization). I still have to see how to do this.

Both subjects should work in general, of course. Unauthorized users are not granted access.

Since I am not very fond of writing webapps, I am planning to create a GUI (Swing or SWT) that will only manage POJOs, do some messages and call methods from the container. I want to keep serialization as simple as possible.

+1


source to share


4 answers


As almost always, Spring comes to the rescue. From the reference documentation, you'll want to read Chapter 17. Deletion and Web Services Using Spring .

There are several ways to choose. The beauty of Spring is that all of your interfaces and implementations are vanilla POJOs. Wiring in RMI or whatever is done with Spring. You can:

Spring has the added benefit of being able to easily and transparently wire both server and client.



Personally, I would choose either (2) or (3). HTTP is web friendly. It is easily deployed in a web container. Jetty long lived connections give you the ability to redirect the server (efficiently) over HTTP.

All of these methods allow complex objects to be transmitted over the wire, but in this respect they are slightly different from each other. You need to consider if your server and client will be distributed separately, and if this will be a problem if you change the interface required to redistribute the class files. Or you can use a customized serialization solution (even XML) to avoid this. But this also has problems.

Using a web container will allow you to easily hook up Spring Security , which can be a little tricky at first because there are so many options. It HttpSession

can also be used to provide status information between requests.

+2


source


Simple RPC is exactly what RMI was created for. If you create a serializable interface, you can call methods in one application from another application.



+1


source


You can try XStream ( http://x-stream.github.io/ ) via REST. Easy to apply on pre-existing pojos set.

Can you please provide more information on what you are trying to achieve since you are not interested in rest / json?

0


source


If you only want value objects, just make sure POJOs implement Serializable and write objects over sockets (using ObjectOutputStream). On the receiving end, read the objects using ObjectInputStream. The receiving end must have a compatible POJO version (see SerialVersionUID). Hessian / Burlap 'protocol -ize: http://hessian.caucho.com/ and http://www.caucho.com/resin-3.0/protocols/burlap.xtp

0


source







All Articles