I have modified (simplified) the util template by removing the caching. Here is the reason. Feel free to comment.
It's not the util object's responsibility to do the caching. That is normally taken care of by the container. If caching is still needed on the application level, it should be done by the class calling util's getHome() methods. >From the javax.naming.InitialContext API: http://java.sun.com/j2se/1.4/docs/api/javax/naming/InitialContext.html "An InitialContext instance is not synchronized against concurrent access by multiple threads. Multiple threads each manipulating a different InitialContext instance need not synchronize. Threads that need to access a single InitialContext instance concurrently should synchronize amongst themselves and provide the necessary locking." >From BEA JNDI docs: http://e-docs.bea.com/wls/docs61/jndi/jndi.html#472853 "After clients finish working with a Context, the client should close the Context in order to release resources. BEA recommends that you use a finally{} block and wrap the close() method in a try{} block. If you attempt to close a context that was never instantiated because of an error, the Java client application throws an exception." Further, I have made it possible to specify whether you want the util class to use the logical component name or the JNDI name for lookups. logical is the default, since that is the spec recommendation. /** * @ejb:util generate="physical|logical" */ Aslak > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]]On Behalf Of > [EMAIL PROTECTED] > Sent: 1. februar 2002 12:11 > To: Ara Abrahamian; 'Dion Almaer'; 'Dmitri Colebatch'; 'Jozsa Kristof'; > [EMAIL PROTECTED] > Subject: RE: [Xdoclet-user] Generated Util classes' getHome() > > > Yes! that's definitely the way to do it. End of discussion. Period. :-) > > Aslak > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED]]On Behalf Of Ara > > Abrahamian > > Sent: 1. februar 2002 10:39 > > To: 'Dion Almaer'; 'Dmitri Colebatch'; 'Jozsa Kristof'; > > [EMAIL PROTECTED] > > Subject: RE: [Xdoclet-user] Generated Util classes' getHome() > > > > > > But Dion, why not use the logical java:comp/env? You can always remap > > the logical name to the absolute one, even in an application client. > > It's ok for most cases. Sure if you want to use Tyler's ejb deployment > > to different jndi-names you have to use physical names, or maybe I'm > > wrong? For that case we need to provide multiple lookup methods too :-) > > > > So I propose: > > - default is: generate lookup method using jndiname (comp/env), this > > means that @ejb:lookupobject (don't you think it's way better to call it > > this way than utilobject?) has generate="logical" by default. > > - User can specify @ejb:lookupobject generate="physical" to get lookup > > methods which use physical jndi names. Generate="both" will generate > > both lookup methods. > > > > Agree? > > > > Cheers, > > Ara. > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] [mailto:xdoclet-user- > > > [EMAIL PROTECTED]] On Behalf Of Dion Almaer > > > Sent: Friday, February 01, 2002 1:40 AM > > > To: Dmitri Colebatch; Jozsa Kristof; > > [EMAIL PROTECTED] > > > Subject: RE: [Xdoclet-user] Generated Util classes' getHome() > > > > > > The Util class could always do: > > > > > > lookup in java:comp/env > > > if not found: > > > lookup in absolute > > > > > > But then it makes you think... why not just look up the absolute. > > > > > > D > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > > [mailto:[EMAIL PROTECTED]]On Behalf Of Dmitri > > > > Colebatch > > > > Sent: Thursday, January 31, 2002 3:02 PM > > > > To: Jozsa Kristof; [EMAIL PROTECTED] > > > > Subject: Re: [Xdoclet-user] Generated Util classes' getHome() > > > > > > > > > > > > Christopher, > > > > > > > > there has been some discussion of this recently on dev (I think > > thats > > > where it was). > > > > > > > > quick abc on jndi and ejb: inside an ejb container, the spec > > > "recommends" that a bean looks up resources in the java:comp/env > > > > namespace, and the container has to provide facilities for mapping > > > references to other beans, datasources, etc. into that > > > > namespace. > > > > Each bean has its own java:comp/env namespace - that is to say that > > > depending on your configuration, lookups in one java:comp/env > > > > namespace may or may not work elsewhere. > > > > > > > > so in short - the only reason that java:comp/env works is that the > > > container makes it work - so, from outside the container, > > > > comp/env isn't going to work. As you've noticed, looking up > > normally > > > works fine. > > > > > > > > I cant remember what the direction the recent discussion took, but > > > perhaps one of the other guys can chime in with some > > > > feedback on > > > > intended usage of the util classes - maybe you would like a remote > > util > > > class? > > > > > > > > cheers > > > > dim > > > > > > > > ----- Original Message ----- > > > > From: "Jozsa Kristof" <[EMAIL PROTECTED]> > > > > To: <[EMAIL PROTECTED]> > > > > Sent: Friday, February 01, 2002 8:53 AM > > > > Subject: [Xdoclet-user] Generated Util classes' getHome() > > > > > > > > > > > > > Hello, > > > > > > > > > > using the generated *Util classes, it seems that their getHome() > > > methods > > > > > fail when they're invoked 'outside' of the EJB environment. As I > > see > > > if I > > > > > get the home manually (getting InitialContext, doing lookup and > > narrow > > > the > > > > > home class), and use the classes' JNDI_NAME, it works fine, but > > fails > > > using > > > > > COMP_NAME, and unfortunately the *Util classes defaults to that. > > > > > > > > > > I'm still not an EJB expert, so I cant really explain why the > > beans > > > don't > > > > > get bounded into 'java:comp/env/ejb/', I only see that using the > > plain > > > > > JNDI_NAME would be fine for me. Is there any way to change the > > > generated > > > > > Util classes behaviour from an xdoclet tag or somehow else; or > > shall I > > > do > > > > > something else to get my beans working with the current settings? > > > > > > > > > > All that happens on JBoss3, last working snap, the exact error at > > > getHome() > > > > > invocation is: 'javax.naming.NameNotFoundException: comp not > > bound' > > > > > > > > > > Christopher > > > > > -- > > > > > .Digital.Yearning.for.Networked.Assassination.and.Xenocide > > > > > > > > > > _______________________________________________ > > > > > Xdoclet-user mailing list > > > > > [EMAIL PROTECTED] > > > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > > > > > > > > > > > _______________________________________________ > > > > Xdoclet-user mailing list > > > > [EMAIL PROTECTED] > > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > > > > > > > > > _______________________________________________ > > > Xdoclet-user mailing list > > > [EMAIL PROTECTED] > > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > > > > > _________________________________________________________ > > Do You Yahoo!? > > Get your free @yahoo.com address at http://mail.yahoo.com > > > > > > _______________________________________________ > > Xdoclet-user mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > > _______________________________________________ > Xdoclet-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/xdoclet-user _______________________________________________ Xdoclet-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-user
