Well, in some of the App servers I use(Orion, OC4J, JBoss), an uncaught
exception rolls back the current transaction. If you exectute
beanHome.findByPrimaryKey(...) and nothing is found, a FinderException
or a ObjectNotFoundException are thrown. Same goes for create() and
remove() methods. This may or may not work in some app servers. I think
it'll work in most, since the app server usually catches the Exception
and rethrows it, and the transactional context is set BEFORE method
execution. But it COULD be a problem, esp. if you're trying to cache
EJBHomes remotely(from a non-transactional client, for instance). Since
David was asking for potential problems and I'm not aware of the context
he'll have this working in, I mentioned the _potential_ risk. But I
think the risk is truly small.

I would go for the Singleton and cache the ejbHome instances barebones,
and fix it later if I find it not to be working, since all you'll be
needing is minor changes on the Singleton implementation, not the
interface:

public MyBeanHome getMyBeanHome() {
        return (MyBeanHome) myHomes.getElement(MYBEAN);
}

Would then become:

public MyBeanHome getMyBeanHome() {
        HomeHandle handle = myHomes.getElement(MYBEAN);
        return (MyBeanHome) handle.getEJBHome();
}

No need to issue a "build all-classes-since-world-was-created" command.

HTH,

Juan Pablo Lorandi
Chief Software Architect
Code Foundry Ltd.
[EMAIL PROTECTED]

Barberstown, Straffan, Co. Kildare, Ireland.
Tel: +353-1-6012050  Fax: +353-1-6012051
Mobile: +353-86-2157900
www.codefoundry.com


> -----Original Message-----
> From: Sven E. van �t Veer [mailto:[EMAIL PROTECTED]] 
> Sent: Tuesday, July 30, 2002 6:01 PM
> To: Juan Pablo Lorandi
> Subject: RE: Effect of "static" EJBHomeFactory vs. "singleton"
> 
> 
> So, for what I understand is that, in case you want to 
> develop a 'portable' application that runs on *any* app 
> server you should use a singleton that does not cache 
> ejbHomes but maybe only the JNDI context or ejbHome handles ??
> 
> But how about homes for session beans ? do they vote in 
> transactions too ??
> 
> >
> > Also bear in mind that such EJBHome cache may not work 
> seamlessly in 
> > all containers, since many may enroll the EJBHome instance in a 
> > particular transaction, which will in turn make the 
> instance useless 
> > in any other transaction. An EJBHome is a fully blown transactional 
> > component that executes business rules(altough they may not 
> be coded 
> > in Java but in SQL or EQL), and it may attempt to vote within the 
> > current transaction to no avail. Storing handles to EJBHome 
> instances 
> > may work better, but with performance losses.
> >
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.377 / Virus Database: 211 - Release Date: 15/7/2002
> 

==========================================================================To 
unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to