| |
Sistemi distribuiti: design
-
Forum del Corso
Messaggi del Thread
|
| Autore |
Messaggio |
igor.cappello
|
Thread
Postato:
15 marzo 2006
Titolo:
caching the reference to an ejb... is this safe?
|
|
|
I have a (long but simple) question regarding a small design choice:
I'm writing the java swing client for the project. Since in my project there is some kind of authentication (very simple, and very weak...), and since I suppose only one user at a time can login using the swing client, I could limit the net traffic caching the remote interface for the stateful bean that maps the logged user, instead of making a request to the server every time the client needs to invoke an ejb's method. Is this a good choice or does it violate some "ejb good practices"?
Actually I implemented the "ask every time" policy, because I consider it safer: using the other policy, what if the server decides that the ejb is not anymore useful (es. timeout)? the client's reference becomes broken!
thanks, Igor
|
|
|
afogarolli
|
Postato:
15 marzo 2006
Titolo:
Re: caching the reference to an ejb... is this safe?
|
|
|
I think you can do it, just use identification in the swing client.
In Stateful session bean, the client controls life cycle ( creation and removal but not activation and passivation). So when does container call ejbActivate() and ejbPassivate() methods? For example, if you set maximum beans in cache as 100 beans, when clients are accessing a bean concurrently, container creates beans till 100 (maximum bean limit) and assigns those beans to clients. After this limit, if the 101st client accesses this bean, Container passivates some of the idle beans that depending on Container algorithms. Just before passivating beans, it calls ejbPassivate() method. Here passivation means, it stores the bean's state (instance variables values) in the secondary storage (file storage or database). The passivation happens through Serialization. Later if the the idle client accesses the bean again, then Container activates the bean and reassigns the passivated values to its instance variables and calls ejbActivate() method.
Here what we understand is that client controls creation and destruction of beans but not activation and passivation. Activation and passivation are controlled by Container and depend on instance cache size.
For more information about the session statefull life cicle you can take a look at this site:
http://www.unix.org.ua/orelly/java-ent/ebeans/ch07_04.htm
Hope it helps. Angela
|
|
|
igor.cappello
|
Postato:
15 marzo 2006
Titolo:
Re: caching the reference to an ejb... is this safe?
|
|
|
thanks for the explanation!!!
Igor
|
|
|
|
|