tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@gmail.com>
Subject Re: Can I lookup a different service from a service without @EJB?
Date Fri, 03 Jun 2011 18:45:14 GMT

On Jun 3, 2011, at 10:57 AM, Andre Brito wrote:

> Hey guys. The subject of this thread is ugly, I know. Pardon me, my english
> is very poor.
> 
> I know I can use @EJB. Is simpler, easier and cleaner. But this question
> appeared in the team. With JBoss, if I'm in SessionBean A and I need
> SessionBean B, I must call the ServiceLocator. How can I do that with
> OpenEJB? I tied this:
> 
> 
>> // SessionBean A looking up SessionBean B
>> Properties properties = new Properties();
>> properties.setProperty(Context.INITIAL..., "RemoteInitialContextFactory");
>> properties.setProperty(Context.PROVIDER_URL, "ejbd://10.1.1.2:4201");
>> 
>> // 10.1.1.2 is where the server is started, using openejb start
>> --ejbd-bind.
>> 
>> Context ctx = new InitialContext(properties);
>> ctx.lookup("SessionBeanBRemote");
>> 
> 

This doc has some info.

   http://openejb.apache.org/3.0/service-locator.html

If the two beans are in the same vm you can use the org.apache.openejb.client.LocalInitialContextFactory
instead and leave out the Context.PROVIDER_URL.

-David


Mime
View raw message