On Wednesday 28 September 2005 15:40, Michael Wechner wrote:
> Felix Röthenbacher wrote:
> >> but doesn't that mean we would have to run a JNDI service as a server
> >> parallel to Lenya (similar to a DNS demon)? Also the binding would
> >> have to happen during startup, because it's implementation specific.
> >> If we can do this out of the box, then great, but I don't know how
> >> simple this is to integrate.
> >
> > web.xml is the place where it can be defined for Tomcat. With Jetty,
> > either JettyPlus has to be used or the rmiregistry has to be started.
> > Out-of-the-box is possible and not too hard to implement.
>
> you might want to give it a try ;-)
>
> What about other servlet containers, e.g WebLogic?

Making this container-neutral should be no problem. To expand in my previous 
post, the solution seems to be a ServletContextListener that just initializes 
the insert-whatever-here* and puts it under the JNDI tree. 

insert-whatever-here can be anything from your-clusterable-singleton to 
hibernate to a jsr-170 implementation; although i havent tried the latter, 
i'm confident this is the right direction.

The good thing about this pattern is that it works well in all JNDI-aware 
containers (that includes all J2EE appservers) and can be modified to work in 
all topologies as well. In short this goes like 

//======================================================================
// foo can be the repository, a datasource, a clusterable singleton etc
Foobar foo = FoobarFactory.initializeOrConfigureOrWhatever();

// not sure this is needed, see below
Properies props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);
props.put(Context.PROVIDER_URL, PROVIDER_URL)

// calling the same constructor with no args should be fine too
// we are not trying to do any lookups
InitialContext context = new InitialContext(props);

// ok now put it under the JNDI tree
String key = "some key that can could be retreived form web.xml or other 
conf";
context.bind(key, foo);
//======================================================================


Now, JSR-170 does *not* specify how a Repository should be obtained. This 
probably means that to abstract implementation-dependent initialization of 
repos, you probably have to come up with an abstraction for this. One 
possibility is to come up with an interface like RepoFactory and load the 
implementation by getting the actual classname from web.xml.

Cheers,

Manos


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to