tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From is_maximum <mnr...@gmail.com>
Subject RE: suggestion for defining local ref name for session beans
Date Tue, 15 Sep 2009 06:01:54 GMT

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