views:

299

answers:

4

Hi to all,

I have to design a distributed application composed by one server (developed in Java) and one or more remote GUI clients (Swing application with windows).

As stated before the clients are Swing GUI application that can connect to the server in order to receive and send data. The communication is bidirectional (Server <=> Clients). Data sent over the network is mainly composed by my domain logic objects.

Two brief examples: a client calls the server in order to receive data to populate a table inside a window; the server calls client in order to send data to refresh a specific widget (like a button).

The amount of data transmitted between server and clients and the frequency of the network calls are not particularly high.

Which technology do you suggest me for the server-clients communication?

I've in mind one technology suitable for me but I would like to know your opinions.

Thanks a lot.

A: 

I believe sockets should do the trick. They are flexible and not especially hard to code/maintain. Most entry level programmer should also be able to maintain them. They are also fast and adapt to any kind of environment.

Unless, your server is going to be off-site or you expect to have firewall issues. In that case, web services are the way to go since your basic communication happens through port 80.

Tanmay
Thanks for your answer.I think socket is an easy way for network communication, too.But what about you effort for writing and reading domain objects on sockets? It can be negligible?What do you mean for "off-site"?I think that server will be placed in a dedicated LAN and accessible from any remote host where my Swing application is installed (software authentication/login will be required).
epok
If you want to send domain objects, I agree that RMI is a better option. I must admit that my first thought is never RMI, but with Java clients and servers it may be a better option. By off-site I meant server is somewhere on the internet while your clients are in a network. Looks like that is not expected to happen.
Tanmay
Thanks for your comment.Probably (as suggested by msparer and you) I will adopt RMI for server-client communication.
epok
+4  A: 

The first technology that came to my mind was RMI - suitable if you're communicating between java client and java server. But you may get difficulties if you want do switch the client technology to - say - a webinterface.

msparer
Thanks for your answer.In fact the technology I thinked about is RMI.I don't think that client will be changed in a web interface in the future (Swing technology will be enough).So other than this point do you think that there can be other disadvantages adopting RMI?
epok
to be honest, I haven't used RMI for a long time. "Long" in a sense of 2 years. What I'm using now a lot is SOAP with Apache CXF - which might not be the best choice if you're sending huge Object graphs. The stuff I did with RMI however worked pretty well (I used to sync data between a PDA and a workstation back then).
msparer
In fact data sent over network for server-clients communication is composed by domain objects. Sometimes these objects can be "simple" (for example only one object with two integers and a string) or "complex" (a list of many objects sent by the server to the clients).Clearly the implementation of these objects is visible to the servers and to the clients.
epok
A: 

I would second msparer's suggestion of RMI, except I would just use EJB3 (which uses RMI as the communication protocol). EJB3 are very easy and even if you don't use the other feaures EJB gives you (e.g., security) you can still leverage Container Managed Transactions (CMT). It really does make development easy.

As for the server->client communication, you would probably want to use JMS. Again, using EJB3 this is pretty e3asy to do with annotations. The clients will subscribe to the message service and receive update notifications from the server.

And yes, I am currently working on an application that does this very thing. Unfortunately we are using EJB2.1. Still, it is my opinion that this is where EJBs really shine. Using EJBs in a web app is frequently overkill, but in a distributed client/server app they work very well.

Nemi
+1  A: 

I would go with RMI but implement the whole architecture using Spring framework. This way it is independent of technology used and can be switched to other ways of communication (such as HTTP or other ) with almost no coding.

UPDATE: And Spring will allow you to have none of RMI specific code.

eugener