>
> I am confused as to why I would choose a way to get an
> initial context.
> Anyone know of a document that explains why we would choose
> one way vs.
> another?
> Thanks, and sorry if this is a stupid question!
>
> For example,
> 1)
> InitialContext context = new InitialContext();
> Object obj = context.lookup("java:comp/env/ejb/Category");
> CategoryHome ch = (CategoryHome)PortableRemoteObject.narrow(obj,
> CategoryHome.class);
That's the generic and simple way. Recommended.
> 2)
> final Properties properties = new Properties();
> properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "allaire.ejipt.ContextFactory");
> ...//set rest of props
> Context initCtx = new InitialContext(properties);
This is non-generic and more complex. The code must be updated for changes
in the provider. However, it allows you to access multiple providers in the
same application. Use in complex scenarios only.
> 3) Deprecated!
> Context initCtx = new InitialContext(properties);
> Context initCtx = new InitialContext(ctx.getEnvironment());
> home = (shopping.CategoryHome)
> initCtx.lookup("shopping.CategoryHome");
>
Don't use this, obviously.
- Avi
--
s/\be(\w+)/e-\1/g;
===========================================================================
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".