• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we lookup(access) the bean directly?  RSS feed

 
Sachin Lewis
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we directly look up the bean, i mean instead of giving lookup of the datasource?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by Datasource?
You will have to lookup the bean using Context API.
 
Sachin Lewis
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I mean instead of using Properties,IntialContextFactory... and so on, how to do it with EJB Refrence ?

Example : (Instead of the below code, how to lookup the bean directly using EJB Refrence)
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
properties.put("java.naming.provider.url", "iiop://.....");
InitialContext initialcontext = new InitialContext(properties);
CartHome carthome = (CartHome)initialcontext.lookup("cartjndi");
Cart cart = carthome.create();

Cheers,
Sachin
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is no. That would defeat the purpose of EJB's by not allowing their lifecycle to be managed.
Kyle
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's a one-page tutorial for ejb-ref's.
 
Sachin Lewis
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You all. The replies helped me.
Cheers,

Sachin Lewis
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!