users@glassfish.java.net

Re: Internal processes in EJB

From: <glassfish_at_javadesktop.org>
Date: Tue, 18 Nov 2008 08:27:07 PST

statefull session beans are not meant to be used in this manner. They are used to maintain across a "conversation" with one client, not to be shared between clients. A good example might be a "shopping cart" which is used to maintain the contents of what you have ordered until checkout time. Two different customers would not share the same "shopping cart".

From what you are describing, I would probably build one or more resource adapters to handle the communications requirements with the special hardware depending on the communications mechanism. It could be one to handle all, or one to handle each.

You mention "real-time" by the client. Is this "near-time" in that the client would look at stored state (say a database) and the state would be updated periodically, or would the client request the state "on demand". Both can be done.

The first way would be to have you resource adapter poll the equipment and invoke an endpoint that drives an MDB to store the state in the database.

The second way would be to create an outbound connection interface (could be proprietary or could be using the Common Client Interface) and allow a client to "connect" to the resource adapter and acquire state on demand by actually querying the equipment right then and there. Picture your equipment being an SQL database and your clients using a "connection" to query it. The same type of setup can be done where your "connection" actually talks to live equipment.

To have your clients retrieve the information, you could use JPA and make the data Entity beans. These would be shared among clients.
[Message sent by forum member 'bbergquist' (bbergquist)]

http://forums.java.net/jive/thread.jspa?messageID=317245