You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@geronimo.apache.org by ivanrc <ir...@indra.es> on 2008/01/04 13:43:59 UTC

Gbean and EJBs

Hello,

I want to know if a Gbean that is in the same EAR with other EJBs, can
obtain the local interface of one of these  EJBs.

thanks. 
-- 
View this message in context: http://www.nabble.com/Gbean-and-EJBs-tp14615530s134p14615530.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Gbean and EJBs

Posted by David Jencks <da...@yahoo.com>.
On Jan 8, 2008, at 1:34 AM, ivanrc wrote:

>
> I doesn´t work. I can obtain EJB local interface. I think this  
> lines work as
> if I do new InitialContext() without parameters.
>
> I would like to obtain the interface as we do with EJB 3.0. I try  
> it adding
> this lines to source code...

This absolutely definitely will not work.  GBeans are lower-level  
server components that aren't really expected to use jndi (for  
instance the jndi system is set up with a few gbeans), and we  
certainly don't provide jndi-based dependency injection through  
annotations for them.  You have to look up the ejb in jndi "by  
hand".  I would recommend using "new InitialContext()" if you can get  
it to work since you can arrange for other things like datasources to  
be available there as well, whereas with the openejb jndi system I  
don't think datasources are available.

thanks
david jencks

>
> @EJB(name="TeamBeanRemote")
> TeamRemote local=null;
>
> -- and adding a ejb-ref to gbean tag as this:
>
>
> <gbean name="TestGBean" class="com.test.SSEGBean">
>   	<attribute name="port">4201</attribute>
> 	<attribute name="host">localhost</attribute>
> 	<ejb-ref>
>         <ref-name>TeamBeanRemote</ref-name>
>         <nam:pattern
> xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
>            <nam:artifactId>test_ejb3</nam:artifactId>
>            <nam:name>test_ejb3</nam:name>
>         </nam:pattern>
>         </ejb-ref>
>   </gbean>
>
>
> .. but It doesn´t work.  Can I use EJB3.0 annotations inside Gbean?
>
>
>
> Jacek Laskowski wrote:
>>
>> On Jan 8, 2008 8:24 AM, ivanrc <ir...@indra.es> wrote:
>>
>>> How can Gbean obtain the global jndi?
>>
>> During "the simplest and easiest approaches" day everything should be
>> simplest and easiest (as well as intuitive) so your best bet would be
>> to look at gbean as any other java remote client and do the  
>> following:
>>
>>         Properties properties = new Properties();
>>         properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
>> "org.apache.openejb.client.LocalInitialContextFactory");
>>
>>         Context ctx = new InitialContext(properties);
>>         MyEjbBeanIntf myEjbBean = (MyEjbBeanIntf)
>> ctx.lookup("MyEjbBeanLocal");
>>
>> As the gbean's actually part of the server environment, I'd expect  
>> you
>> can leave off the Context.INITIAL_CONTEXT_FACTORY setting and look up
>> ejbs without it.
>>
>> Jacek
>>
>> -- 
>> Jacek Laskowski
>> http://www.JacekLaskowski.pl
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Gbean-and-EJBs- 
> tp14615530s134p14685205.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>


Re: Gbean and EJBs

Posted by ivanrc <ir...@indra.es>.
I doesn´t work. I can obtain EJB local interface. I think this lines work as
if I do new InitialContext() without parameters.

I would like to obtain the interface as we do with EJB 3.0. I try it adding
this lines to source code...

@EJB(name="TeamBeanRemote")
TeamRemote local=null;

-- and adding a ejb-ref to gbean tag as this:


<gbean name="TestGBean" class="com.test.SSEGBean">
  	<attribute name="port">4201</attribute>
	<attribute name="host">localhost</attribute>
	<ejb-ref>
        <ref-name>TeamBeanRemote</ref-name>
        <nam:pattern
xmlns:nam="http://geronimo.apache.org/xml/ns/naming-1.1">
           <nam:artifactId>test_ejb3</nam:artifactId>
           <nam:name>test_ejb3</nam:name>
        </nam:pattern>
        </ejb-ref>
  </gbean>


.. but It doesn´t work.  Can I use EJB3.0 annotations inside Gbean?



Jacek Laskowski wrote:
> 
> On Jan 8, 2008 8:24 AM, ivanrc <ir...@indra.es> wrote:
> 
>> How can Gbean obtain the global jndi?
> 
> During "the simplest and easiest approaches" day everything should be
> simplest and easiest (as well as intuitive) so your best bet would be
> to look at gbean as any other java remote client and do the following:
> 
>         Properties properties = new Properties();
>         properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
> "org.apache.openejb.client.LocalInitialContextFactory");
> 
>         Context ctx = new InitialContext(properties);
>         MyEjbBeanIntf myEjbBean = (MyEjbBeanIntf)
> ctx.lookup("MyEjbBeanLocal");
> 
> As the gbean's actually part of the server environment, I'd expect you
> can leave off the Context.INITIAL_CONTEXT_FACTORY setting and look up
> ejbs without it.
> 
> Jacek
> 
> -- 
> Jacek Laskowski
> http://www.JacekLaskowski.pl
> 
> 

-- 
View this message in context: http://www.nabble.com/Gbean-and-EJBs-tp14615530s134p14685205.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Gbean and EJBs

Posted by Jacek Laskowski <ja...@laskowski.net.pl>.
On Jan 8, 2008 8:24 AM, ivanrc <ir...@indra.es> wrote:

> How can Gbean obtain the global jndi?

During "the simplest and easiest approaches" day everything should be
simplest and easiest (as well as intuitive) so your best bet would be
to look at gbean as any other java remote client and do the following:

        Properties properties = new Properties();
        properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.openejb.client.LocalInitialContextFactory");

        Context ctx = new InitialContext(properties);
        MyEjbBeanIntf myEjbBean = (MyEjbBeanIntf) ctx.lookup("MyEjbBeanLocal");

As the gbean's actually part of the server environment, I'd expect you
can leave off the Context.INITIAL_CONTEXT_FACTORY setting and look up
ejbs without it.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl

Re: Gbean and EJBs

Posted by ivanrc <ir...@indra.es>.
Hello,

How can Gbean obtain the global  
jndi?





djencks wrote:
> 
> 
> On Jan 4, 2008, at 4:43 AM, ivanrc wrote:
> 
>>
>> Hello,
>>
>> I want to know if a Gbean that is in the same EAR with other EJBs, can
>> obtain the local interface of one of these  EJBs.
> 
> I haven't tried it but I expect you could look them up in global  
> jndi, probably under java:.  I believe the names the ejbs are bound  
> to are logged as the ejb module is deployed.
> 
> hope I'm right :-)
> david jencks
> 
>>
>> thanks.
>> -- 
>> View this message in context: http://www.nabble.com/Gbean-and-EJBs- 
>> tp14615530s134p14615530.html
>> Sent from the Apache Geronimo - Users mailing list archive at  
>> Nabble.com.
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Gbean-and-EJBs-tp14615530s134p14683996.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Re: Gbean and EJBs

Posted by David Jencks <da...@yahoo.com>.
On Jan 4, 2008, at 4:43 AM, ivanrc wrote:

>
> Hello,
>
> I want to know if a Gbean that is in the same EAR with other EJBs, can
> obtain the local interface of one of these  EJBs.

I haven't tried it but I expect you could look them up in global  
jndi, probably under java:.  I believe the names the ejbs are bound  
to are logged as the ejb module is deployed.

hope I'm right :-)
david jencks

>
> thanks.
> -- 
> View this message in context: http://www.nabble.com/Gbean-and-EJBs- 
> tp14615530s134p14615530.html
> Sent from the Apache Geronimo - Users mailing list archive at  
> Nabble.com.
>