Why not a HomeManager for your java application client (not a ejb bean)?
Sample code, not checked since I have typed it into my mail client. Also
does not handle concurrency, exception handling.......but a start.
public final class HomeManager {
private static HomeManager _instance = new HomeManager();
private HashMap _homes = new HashMap();
private Context _context = null;
private HomeManager() { init(); }
public static HomeManager getInstance() { return _instance; }
private void init() {
try {
_context = new InitialContext();
} catch (NamingException e) {
System.out.println(e);
}
}
public EJBHome lookup(String name) throws Exception {
EJBHome home = null;
if((home=(EJBHome)_homes.get(name))==null) {
home =
(EJBHome)PortableRemoteObject.narrow(_context.lookup(name),EJBHome.class);
home =
(EJBHome)PortableRemoteObject.narrow(home,home.getEJBMetaData().getHomeInter
faceClass());
_homes.put(name,home);
}
return home;
}
}
Why pool contexts when you can pool homes. Is this not the starting point
for your interation with beans...before creation.
William
> -----Original Message-----
> From: Sandeep Sharma [SMTP:[EMAIL PROTECTED]]
> Sent: Friday, March 03, 2000 10:55 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Proper use of initial context ?
>
> Ye pooling is a very good idea I would say ..
>
> You can maintain a context cache that would simply hold a collection of
> contexts ..
>
> 1. You dont need to worry about creating a new InitialContext always
> 2. Closing of all the context at once when the application closes would be
> easier
>
> -Sandi
>
>
> >From: Hed Bar-Nissan <[EMAIL PROTECTED]>
> >Reply-To: A mailing list for Enterprise JavaBeans development
> ><[EMAIL PROTECTED]>
> >To: [EMAIL PROTECTED]
> >Subject: Proper use of initial context ?
> >Date: Sun, 27 Feb 2000 19:01:59 +0200
> >
> >What would be the propper use of initial context objects ?
> >
> >1. provide one for each stateless session bean ?
> >2. each time construct a new initial context object ?
> >3. maintain a pool of initial context objects ?
> >
> >
> >hed.
> >
> >=========================================================================
> ==
> >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".
> >
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
> ==========================================================================
> =
> 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".
***********************************************************************
Bear Stearns is not responsible for any recommendation, solicitation,
offer or agreement or any information about any transaction, customer
account or account activity contained in this communication.
***********************************************************************
===========================================================================
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".