Hi

I have seen problems with using this approach. Writing to static variables
is not allowed in the EJB standard. Most servers don't force you to follow
this rule, but there are reasons for why it has been stated. In Websphere 4
cashing the homeinterface will result in an invalid reference if you restart
the bean that it points to. Another problem is the class loading policy of
the server that you are using. Worst case is one classloader per bean, which
would mean one static map per bean. Restarting or redeploying the bean or
application would not garantie that the static map would be reinitialised,
and would therefor hold old references. I know this was the case in an
application I made running on JBoss 3.0.1. 

Shortly, by breaking the ejb rules, you break portability og possibly the
application. There is no garanti that later versions or fixes of your chosen
server will continue to let you break the rules.

I made a test program for JBoss 3.0.x to check for getting home and creating
session bean for local interfaces, and it was very quick, so I doubt that
there is much to gain by doing this.

And if you really want to go for Brett's solution, make sure you do it
right. Brett writes that threading is not a problem, but he is terribly
wrong. The problem is not if you get two instances initially or not. The
problem is that you could get an ivalid instance. This is has to do with how
the prosessor organises read and writes. Shortly, it can reorganize read and
write as it "wants" between a read/write barriers (synchonization) which
could give you bizare and untracable problems if you dont play by the
synchronization rules. I tried to find the relevant articles on Java Report
web site, but I cannot find them. (The articles where about double phased
locking, but also applies to this problem).

So my advice is: Don't do optimasations like this before you really need it,
check if it really is something to gain at all, and expect problems (at
least in the future).

Best regards
Oystein


-----Opprinnelig melding-----
Fra: Lukas Severin [mailto:[EMAIL PROTECTED]]
Sendt: 29. november 2002 13:27
Til: [EMAIL PROTECTED]
Emne: Re: [Xdoclet-user] caching homes in util


thanks for your input, Yes of course one is free to choose whatever one
wants, thats not an argument for pro nor con ;-) The obvious advantage with
Brett's solution is that you will have one utility class, the disadvantage
is the typecast you need to do.  However you do know what you should cast
into since the lookup will take a the Home.class as an argument, so I dont
see that as a problem. Cashing homes is no problem, cashing Contexts
shouldnt be done.

So personally I feel Brett's solution is better if none else has a good
argument against it ....

Lukas

By the way, what is PITA ?

----- Original Message -----
From: "Aslak Hellesoy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; "Lukas Severin" <[EMAIL PROTECTED]>
Cc: "xdoclet-user" <[EMAIL PROTECTED]>
Sent: Friday, November 29, 2002 12:04 PM
Subject: RE: [Xdoclet-user] caching homes in util


>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Konstantin
> > Priblouda
> > Sent: 29. november 2002 11:47
> > To: Lukas Severin
> > Cc: xdoclet-user
> > Subject: Re: [Xdoclet-user] caching homes in util
> >
> >
> > --- Lukas Severin <[EMAIL PROTECTED]> wrote:
> > > Instead of generating a bean util (for each bean)
> > > with xdoclet, would it not
> > > be better to use something like the following home
> > > factory ?
> > >
> > >
> > http://www-106.ibm.com/developerworks/java/library/j-ejb0924.html?
> > dwzone=jav
> >
> > Nobody prevents you from doing it. But it will
> > introduce dependency on external ( additional )
> > classes
> > and this is PITA in most EJB environments.
> >
>
> What external classes are you talking about Konstantin?
>
> > XDoclet generates a class, and you use this utility.
> > It also caches home interfaces if you like.
> >
>
> In my previous post I incorrectly quoted Mathias that caching homes is
bad.
> I meant caching InitialContext is bad, due to cluster environments and
> servers going up and down.
>
> Aslak
>
> > And in my private extendet version it also provides
> > observer/observable list-wrappers for finders
> > and CRUD adapters and DataObject-strippers, which can
> > be chained together to provide  sophisticated
> > infrastructure which comes handy to swing apps.
> >
> > regards
> >
> > =====
> > Konstantin Priblouda ( ko5tik )    Freelance Software developer
> > < http://www.pribluda.de > < play java games -> http://www.yook.de >
> > < render charts online -> http://www.pribluda.de/povray/ >
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> > http://mailplus.yahoo.com
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Get the new Palm Tungsten T
> > handheld. Power & Color in a compact size!
> > http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
> > _______________________________________________
> > Xdoclet-user mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/xdoclet-user
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Get the new Palm Tungsten T
> handheld. Power & Color in a compact size!
> http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
> _______________________________________________
> Xdoclet-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/xdoclet-user



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user


-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en
_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to