tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: suggestion for defining local ref name for session beans
Date Thu, 17 Sep 2009 02:24:37 GMT
Hi Mohammad,

Right, the mappedName attribute is vendor specific.  Our support  
matches that of GlassFish but does have some additional capabilities.

Grab the EJB 3.1 PDF2 (the most recent one from march) and check out  
section "4.4 Global JNDI Access"  It basically describes the standard  
naming format that is being added for each bean.  It's a little  
verbose for most cases, but it will at least be a standard way to  
locate any bean without having to declare a reference on it.

Is that more or less what you are looking for?


We don't implement it yet, but an openejb.jndiname.format like so get  
you close:

  global/{moduleId}/{ejbName}/{interfaceClass}


-David

On Sep 14, 2009, at 11:01 PM, is_maximum wrote:


>
> Hey John,
>
> According to below link,unfortunately mappedName is not portable and  
> it is
> dependent on vendors to support
>
> http://www.ermalaev.spb.ru/javaee/5/docs/api/javax/ejb/Stateless.html
>
> mappedName
> public abstract String mappedName
>
> A product specific name(e.g. global JNDI name) that this session  
> bean should
> be mapped to. Application servers are not required to support any  
> particular
> form or type of mapped name, nor the ability to use mapped names.  
> The mapped
> name is product-dependent and often installation-dependent. No use  
> of a
> mapped name is portable.
>
> Default: ""
>
>
>
> meetoblivion wrote:
>>
>> Mohammad,
>>
>> What I believe we were both referring to is the case of:
>>
>> @Stateless(mappedName="ejb/somePath")
>> public class MyEJB implements MyEJBService {
>> // methods...
>> }
>>
>> And then from your other class..
>>
>> ejbContext.lookup("ejb/somePath")
>>
>> or
>>
>> ic.lookup("ejb/somePath")
>>
>> You're guaranteed to get the EJB mapped to that name.  The app server
>> cannot
>> ignore the mappedName on the Stateless/Stateful annotation.  It may  
>> also
>> put
>> it in other places, but you're guaranteed to get it mapped there.
>>
>> - John
>>
>> -----Original Message-----
>> From: is_maximum [mailto:mnrz57@gmail.com]
>> Sent: Sunday, September 13, 2009 3:25 PM
>> To: users@openejb.apache.org
>> Subject: Re: suggestion for defining local ref name for session beans
>>
>>
>>
>>
>> Quintin Beukes-2 wrote:
>>>
>>> Yes, you can create a mapped name when defining each EJB (part of  
>>> the
>>> @Stateless annotation), and then inside the facade session bean you
>>> can lookup the others doing something like this:
>>>
>>> InitialContext ctx = new InitialContext();
>>> Object lookedUpEJB = ctx.lookup(otherEjbsMappedName);
>>>
>>> Then lookedUpEJB will contain a reference to the EJB. you can wrap
>>> this in a static method of either the facade bean or some other  
>>> class.
>>> When initializing an InitialContext without constructor arguments,  
>>> it
>>> is for the local server by default, and therefore you can lookup any
>>> EJBs in the server.
>>>
>>> Also, if you don't explicitly define a mapped name for the EJB, it
>>> will default to ${beanImplementationClass}Local. So if you have the
>>> following:
>>>
>>> @Stateless
>>> public class MyBean implements MyLocal {}
>>> @Local
>>> public class MyLocal {}
>>>
>>> Then you can do the following to get a reference:
>>> private Object lookup(String name) throws NamingException {
>>>  return new InitialContext().lookup(name);
>>> }
>>>
>>> MyLocal bean = lookup("MyBeanLocal");
>>>
>>> Hope this helps,
>>>
>>>
>>
>>
>> Well thanks, But as far as I can remember, in EJB spec it is said  
>> not to
>> use
>> "mappedName" because still it depends on the provider (or maybe  
>> container)
>> that how to retrieve that name and in some container it might be  
>> ignored!!
>> but using the @EJBs it is ensured that you still can lookup your  
>> local
>> interfaces
>>
>> And the naming style you stated "MyLocalBeanLocal" is defined for  
>> OpenEJB.
>> We are using OpenEJB in running our test cases but in application  
>> server
>> it
>> is not the case.
>>
>> The purpose of this post is that I hope the EJB 3.1 get improved  
>> through
>> David. I know if this is the correct he will try to add such feature.
>>
>> Thank you all guys
>>
>> -----
>> --
>> Regards
>>
>> Mohammad Norouzi
>>
>> Help each other to reach the future faster
>>
>> http://pixelshot.wordpress.com Pixelshot Photoblog
>>
>> http://brainable.blogspot.com Brainable Blog
>>
>>
>> -- 
>> View this message in context:
>> http://www.nabble.com/suggestion-for-defining-local-ref-name-for-session-bea
>> ns-tp25420391p25426273.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>>
>>
>
>
> -----
> --
> Regards
>
> Mohammad Norouzi
>
> Help each other to reach the future faster
>
> http://pixelshot.wordpress.com Pixelshot Photoblog
>
> http://brainable.blogspot.com Brainable Blog
>
>
> -- 
> View this message in context: http://www.nabble.com/suggestion-for-defining-local-ref-name-for-session-beans-tp25420391p25448431.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Mime
View raw message