dcsimg
Call Session/Entity Bean from another JAR file
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Arturs_Vanags
Posted On:   Wednesday, October 17, 2001 03:19 AM

FIRST beans plased in FIRST.JAR, second in SECOND.JAR. In FIRST bean is method doSomething, it must call method doSomrthing2 from SECOND bean. How do it?

Re: Call Session/Entity Bean from another JAR file

Posted By:   RATHAKRISHNAN_K  
Posted On:   Thursday, October 18, 2001 12:28 AM

Hi Arturs,


It doesn't matter whether you've your EJBs in two difft. JARs or
in the same JAR, but, the fact is that if one bean is going to
access the other then the farmer becomes a client of the later.
So, irrespective of their availability in JARs you can always go
ahead with looking up for the other bean and invoke methods
as you would with any other Java Client.


RK.

Re: Call Session/Entity Bean from another JAR file

Posted By:   Bozidar_Dangubic  
Posted On:   Wednesday, October 17, 2001 06:09 AM


public void doSomething()
{
SecondHome home = (SecondHome) getHome("SecondBean",SecondHome.class) ;
SecondRemote remote = home.findByPrimaryKey(id) ;
remote.doSomething2();
}

private Object getHome(String name, Class className)
{
try
{
Object ref = jndiContext.lookup(name) ;
return PortableRemoteObject.narrow(ref,className) ;
}
catch(NamingException nEx)
{
throw new EJBException(nEx) ;
}
}
About | Sitemap | Contact