My understanding of beans:
EB: Synchronous, persistent, multi-user bean
SB: Synchronous, transient, single-user bean
MB: Asynchronous, persistent(?), multi-user bean
So how do I go about getting a synchronous, transient, multi-user bean?
A related question is: how do I pass SB references between different SBs without going through EBs or MBs?
you can pass reference to the interfaces , not to the classes themselves.then whenever you need to use them ( or in your ejbCreate() ) you do the jndi lookup, and call the right create method on the home interface to get your remote object.
mind you, I dont think that Statefull session bean is transient but persistent. Stateful session beans represent a business process and retain it's state between method calls.
It's important that we agree about the meaning of "multi-user bean" before I can try to answer your question.
An entity is multi-user in the sense that many users can access the same entity. The entity bean instance, the object that the client talks to, is not multi-user. More accurately, a bean instance only supports a single transaction.
So, the thing that is "multi-user" about an entity bean is the entity itself, not the bean instance. Other types of beans don't have an "entity" that they represent - they hold the data themselves, within the bean instance. So in this sense, no type of EJB supports multi-user acces (that is, no type of EJB instance).
Because other types of beans don't have a concept of an entity, they can't directly enable access to multiple transactions. EJB doesn't allow any way of making a "global object" within the App server. Even entity beans can be loaded several times in different containers or in the same container. The only thing that makes them global is that the data is kept in a global repository, such as a DB.
If you want a per-spec solution, this is porbably what you have to use: either a stateless session bean or an entity bean that keep their data in a DB. They can't be really transient anyway, because they must hold the data between different user transactions.
There are other non-portable options:
- Use a stateless session bean and set it's pool size to 1 (if supported by the App server)
- Use a static variable in SLSB class to keep the multi-user data.
You must remember that these options limit the scalabillity and portabillity of your code.
Seems my newly posted topic relate to this topic.
I need some how a mechanism to create one copy of information in memory for all access.
I am trying to implement a serverside service that provides windows registry like information. All clients can read/write to the registery information. I am thinking of creating a server that mainains all registry information in memory and periodically synchronize the changes to a permanent storage.
Can EJB do this. Seems I need a bean (only a bean) to exist in the server...