I need to develop an application in java, which uses a client[embedded server]-server-(-server)-(…) approach. (data sent on commits, or automatically)
The workflow (entities, validation, logic, sessions) is everywhere the same. In server-server connections, it looks logical to use EJB-s (entity and session beans, in the future probably message driven beans also). The client speaks with a local “server”, or – based on user settings – to one or more real server (servers may speak to many servers too).
Is it possible (and: simple) to use locally the EJB framework (without a local Java EE server running, to avoid installation on the clients, and memory usage), and if, is it considered a good solution? Or should I implement a different logic on the client, and switch based on the settings? Which is easier?
Yes, it is possible. The EJB 3.1 spec defines an embeddable EJB container (Chapter 20) that can be used in Java SE applications without the need of an Java EE application server.
But even prior to EJB 3.1 there are containers that are easily embeddable, e.g. OpenEJB from Apache.
Whether this is good or bad is of course debatable but I think if there are existing EJBs and you want to use them locally then why not. Others would probably prefer Spring but I don’t have much experience in it so I can’t comment on that.