my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes confused in annotations Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "confused in annotations" Watch "confused in annotations" New topic
Author

confused in annotations

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi Ranchers,

currently i am working ejb 3.0 application with IBM was 7.0 as server.
I have 2 local and remote interfaces and a session bean which implements both local and remote interfaces.

In client , how do i get local and remote session bean using annotations. i mean how do i diffferentiate..

My Local Interface:


My Remote Interface



My SesssionBean:





My Delegate code which access session bean:




I am deciding client or remote based on properties file that is loaded in base class BaseDelegate. Now how do i instantiate local or remote using @EJB annotation. please help me urgent.

Thanks
vipul Kumar.



Thanks
Vipul Kumar
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

Though I am not sure if this answers your query, here is my try:

1. There should be two session beans, each implementing local and remote interfaces respectively.
E.g


2. Above bean classes should use @Stateless annotation with mappedName parameter.
E.g


3. Above step should bind the session beans with the given JNDI names after successful deployment on the server.

4. In the delegate code, there should be two bean look-ups as follows:


5. Appropriate bean (local or remote) can then be used for further processing depending on the result of properties file configuration.

Please let me know if this helps.

Regards,
Prajakta
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks For Reply Acharya,

we are having nearly 30 to 40 session beans. Your solution is good but for our project situation , not efficient. can we inject like this and use ?



based on the type, local and remote both get instantiated. and based on properties file i can use required local or remote object. Is this feasible?


Thanks
vipul kumar.
Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

May be I am not understanding the scenario properly

Are there x number of beans implementing x interfaces (local and remote)? Some of the beans can be accessed locally while some are available as remote beans?

Could you explain your scenario a little more?
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
May be I am not understanding the scenario properly

Are there x number of beans implementing x interfaces (local and remote)? Some of the beans can be accessed locally while some are available as remote beans?



Yes . we are having 'n' number of beans. some beans are accessed locally and some are remotely. mostly in future we make everything remote. so , we generated local and remote business interfaces that are implemented by session beans.

In base delegate class we mention local or remote using properties file. In the actual delegate class we access session bean using local or remote.

Please see the code posted above, my first post. what i want is, using dependency injection local or client has to be injected. presently what i am doing is i am injecting both and using as per properties file.


Thanks
Vipul Kumar.


Prajakta Acharya
Ranch Hand

Joined: Nov 08, 2012
Posts: 138

If I am not wrong, you want to inject an EJB conditionally into AdminBeanLocal or AdminBeanRemote interfaces. As per properties file, if the bean is available locally, inject it in AdminBeanLocal and do further processing.
I think conditional EJB injection is not possible, though not sure.

Just an idea....if all the EJBs are placed remotely, remote look-up of each of them would be an overhead.
If business delegate uses some kind of ServiceLocator located on the same machine as the EJBs, it can look-up all the EJBs locally. Delegate only has to get a reference to Service Locator remotely.

Do let me know how you proceed further...that would definitely add to my knowledge!!!

Thanks.
 
Don't get me started about those stupid light bulbs.
 
subject: confused in annotations