You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by JONATHAN PHILIP HOLLOWAY <jp...@aber.ac.uk> on 2002/12/19 14:47:12 UTC

JNDIConnectorPlugin Example - C.Caveness Book

Has anybody attempted to use the example in the Programming Jakarta Struts book
for the JNDI stuff.  It defines two things:

a) A JNDIConnectorPlugin class that takes the properties from the struts-config.xml
configuration file.

b) An EJBHomeFactory that uses the JNDIConnectorPlugin to lookup a reference to
an Enterprise Java Bean.

The JNDIConnectorPlugin simply takes the values from the config file and inserts 
them into the servlet context for retreval by any servlet via:

    getServlet.getServletContext()

The problem with this is that it needs to call this from the EJBhomeFactory which
is simply a singleton class and has no reference to the Servlet Context.  In the book
by C.Caveness he retrieves these properties from a properties file but what I want
to do is to get them from the servlet context (which JNDIPlugin has used to place
the values).  Is there any way of doing this from a standard class or does EJBHomeFactory
need to be implemented as a servlet?  

Is this the best approach to take when looking up EJB's form an action class via
the jndi properties?  It seems to me like it is and I don't want to hardcode the values
in the EJBHomeFactory rather take them from the servlet context. 

Also when it comes to the EJBHomeFactory I only want to cache references to one EJB
namely my central facade session bean.  Does anybody know whether it's possible to
resuse the same instance (that's cached) in different action classes or does it have to be
a seperate instance for each action class (in a similar way to which a database connection
pool works).

Does anybody have any other better methods of looking up EJB's form action classes?

Many thanks,
Jon.

*---------------------------------------------*
 Jonathan Holloway,               
 Dept. Of Computer Science,       
 Aberystwyth University, 
 Ceredigion,                      
 West Wales,                      
 SY23 3DV.                        
                                  
 07968 902140                     
 http://users.aber.ac.uk/jph8     
*---------------------------------------------*