views:

69

answers:

4

Hi all,

I have a stand-alone, Swing application that uses Hiberanate for its persistence layer. I need to extend this to a three-tier system, so that there will be multiple instances of the Swing application and a central server. The client is a stock trading platform, so it will contain a lot of business logic. The server will be responsible for mostly persistence operations and some business logic.

What would be the best way to implement the server for my needs? EJB3 or Spring? What is the best practice for Swing applications to interact with a server? I don't want to go with RMI since not only is it becoming obsolete but also there is no guarantee that the clients and the server will be on the same network.

Thanks!

+1  A: 

I don't want to go with RMI since not only is it becoming obsolete

This isn't true at all. As long as Java is around, you'll have RMI.

And what do you think EJBs are using to communicate? It's RMI.

but also there is no guarantee that the clients and the server will be on the same network.

Personally, I'd prefer Spring. You can expose your service layer using web services or HTTP remoting.

duffymo
A: 

Go with Spring and RMI. If your client and server are both Java it is the best solution with best performance and productivity.

eugener
+1  A: 

If the client is a Java client, I don't see the point of using web services (and thus having the overhead of the object to XML serialization) and I would go for EJB 3.x.

For me, the major benefits (beyond performance and scalability) that you get with a good container are fault-tolerance and fail-over (both on the server side and client side, especially with Stateless Session Beans if they are idempotent). For a stock trading platform, this matters.

Also note that using EJB3 doesn't necessarily exclude using Spring for the glue (on the client side and/or the server side).

And if the need to expose your services as web services should arise (e.g. for another non Java client), just annotate them with JAX-WS annotations.

Pascal Thivent
A: 

Note that EJBs don't necessarily use RMI as the transport protocol. OpenEJB for example uses its own custom protocol. We get about 7300 TPS over the wire which is pretty good. There is a Spring integration as well so if you wanted, you could build the server with Spring and inject Spring beans into EJBs and vice versa:

http://openejb.apache.org/3.0/spring.html

David Blevins