How about using a factory method.  You put a reference to the factory in the
session and then use it to retrieve any specific beans that you might require.

Just a  thought
C.





[EMAIL PROTECTED] on 05/01/2001 01:58:09 PM

Please respond to [EMAIL PROTECTED]
                                                              
                                                              
                                                              
 To:      [EMAIL PROTECTED]                      
                                                              
 cc:      (bcc: Clarance Howatt/Net)                          
                                                              
                                                              
                                                              
 Subject: EJB reference caching in actions                    
                                                              







Hello,

for maintainability reasons I would like to refacture my action classes'
perform()-methods. Since I use stateless session beans for the complete
business logic the code in the perform()-methods looks pretty much the same:

// lookup for the ssb home interface
// create a ssb
// call some business function

The first step and possibly the second one could be eliminated by caching
the home interface and eventually caching the stateless session bean.

So my questions are:
1) Caching the home interfaces should not be a problem. But where should I
put these ? As attributes in the current session ? In a singleton object
that caches them ? Or even in the controller servlet (very bad idea) or the
action class (bad too) ? What about multithreading ?

2) Caching the stateless session beans is even more complicated. If I put
them in session scope then it is likely that the client will keep a
reference to a heavyweight server object throughout its lifecycle. The ejb
container normally has a pool of these but I don't think that the session
scope approach will scale well. So I put them in application scope ? Or make
a singleton object that caches these. Multithreading ?

I think that these are standard problems that have already been solved by
someone. So if anyone has an idea I would much appreciate any answer.

Regards

Nikolaus Rumm




Reply via email to