On Thu, May 13, 2004 at 10:30:17AM +0100, Paulo Lopes wrote:
> David Blevins wrote:
> >I've put some work into allowing people to have one OpenEJB per
> >webapp, so if that is really what you want I'll see if I can get
> >something to you.
> > 
> >
> No, that's not quite what i need. I've 2 webapps, one if a frontend end 
> to my application that is served to the internet, the other one is a 
> "backoffice" to manage the frontend that is available only to the 
> intranet. Both have distinct security configurations and roles applied 
> to users and i need to keep the separated.
> 
> The frontend works fine because it only needs to use EJB's per user 
> request, so at that time, openejb_loader webapp is already running.
> 
> The backoffice, has a simple scheduler that runs tasks at a given time, 
> so it is started with a servlet with the "load-on-startup" tag, and here 
> is the problem, if a task is run on load or at the time that the server 
> is starting, tomcat might have not started openejb_loader webapp yet.

Sounds pretty neat.  Definite good use of a Tomcat/OpenEJB setup.


> >If that doesn't work, you could add the loader.jar and related servlet
> >to each of the webapps and delete the openejb_loader webapp
> >completely.
> > 
> >
> How many openejb servers would be available? 1 or 2?
> 

That would still get you one OpenEJB per Tomcat, just that each of the
webapps would have ability to do what the loader webapp does.  The
webapp Tomcat chooses to load first would be the one which gets to
load OpenEJB.  After that nothing would happen.

The loading is a process tiggered as a result of the first
InitialContext creation that points to the
org.openejb.client.LocalInitialContextFactory.  All the loader servlet
really does is create a new InitialContext and exit.  So you don't
even need the loader servlet at all if you don't want it.  You just
need code like this in one of your own servlets that load on startup:

    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, 
          "org.openejb.client.LocalInitialContextFactory");
    p.put("openejb.home", "c:\\dir\\openejb");
    
    InitialContext ctx = new InitialContext( p );
    
You could even put the openejb_loader-0.9.2.jar (not war) in Tomcat's
common lib directory and then you wouldn't need to put one copy in
each webapp.

-David

Reply via email to