tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Arnaud Level <le...@ist.fujitsu.com>
Subject ejb-ref/EjbRef/EjbFactory implementation
Date Tue, 13 Mar 2001 09:11:06 GMT
Hi everyone,
I'm working on the implementation of the EjbFactory class (Tomcat 4.0).
According to what I've understand, this class is used when the lookup
method is called from a Servlet (or jsp).
e.g: Context ctx = new InitialContext();
      ctx.lookup("java:comp\MyEjb");
If the ejb-ref tag has been defined in the web.xml file, Tomcat is able
to find the EjbFactory (through the EjbRef saved for MyEjb). Then what
can this Factory do ?
It delegates the job to the Ejb server in its getObjectInstance method:
    - by creating a new InitialContext (with the factory class of my Ejb
server as env parameter).
   - by calling the lookup method of the newly created context and
returning the resulting value.
If this is correct, what the point to define the home,remote and
ejb-link (in the web.xml file) value since they are not passed to the
Ejb server which will use the one defined in its own web.xml file. So
the question is what are those value (defined in the web.xml file of
read by Tomcat) used for ?
Am I misundertanding something ?
Any help is appreciated.
Thank you.
Arnaud Level.

This is a basic way to implement it but it shows the idea:
e.g: EjbFactory.java
  public Object getObjectInstance(Object obj, Name name, Context
nameCtx,
                                    Hashtable environment)
        throws NamingException {

        if (obj instanceof EjbRef) {
            Reference ref = (Reference) obj;
            Hashtable table = new Hashtable(2);
            table.put(Context.INITIAL_CONTEXT_FACTORY,
"com...MyEjbServerCtxFactory");
           javax.naming.InitialContext initCtx = new
javax.naming.InitialContext(table);
           return initCtx.lookup("MyEjb"); //
        }
        return null;

    }



Mime
View raw message