• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Can a Bean have local and remote interface together?

 
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
About Head First EJB Page 157, it say, even a given bean can expose both a remote and local client view, you can't mix local and remote interfaces together?
It's hard to understand what is "you can't mix local and remote interfaces together"
For example, local interface has method getLocalPrice(), while remote interface has method called getRemotePrice(), and one Bean called PriceBean, does this mean PriceBean either implement getLocalPrice() or getRemotePrice(), cannot implement both of them?
Thanks a lot in advance!

Hai
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Hai,

I'm just reading it actually and from my basic understanding, I think that your example should be this way :

You have a Bean, named PriceBean, with the business method getPrice(). No getLocalPrice() or getRemotePrice(). What would be the goal for ? Is the price different for a local or remote perspective ? Don't you find that it doesn't make sense ?

So, I think HDEJB want to say that you can have :

EJBLocalObject, EJBObject, EBJHome EJBLocalHome interfaces

Since the naming convention, you will have :
- Price extends EJBObject
- PriceLocal extends EJBLocalObject
- PriceHome extends EJBHome
- PriceLocalHome extends EBJLocalHome

and you can choose whatever you want to create a REMOTE object or LOCAL object to, finally, come to the same result : running your business method.

I don't remember the exact page in the book but they say to keep in mind what is your primary goal : running the Bus. Method.

Hope this will help !

[ August 04, 2004: Message edited by: Frederic Filiatrault ]
 
Ranch Hand
Posts: 393
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YES EJB can be local as well as remote.As Frederic have written you need to extends interfaces if the EJB is remote or local.

If you have any other doubt,let me know.

Regards,
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes!!
The bean can have (in fact should have)both the remote and the local interface :- One important scenario is :--

Suppose one of your session bean (say sessionBeanA) needs to refer
another session bean (say sessionBeanB). And also, a java bean which is in the web-tier needs to access the sessionBeanB (which is ofcourse,in EJB-tier).

In such a case, you should use the local interface of the sessionBeanB, to access it within the EJB-tier from the sessionBeanA.
And the remote interface to access from the java-Bean (Web -tier).
Although, using just remote interface every where can solve the purpose, but it can cause performance issue, and also, when you have got the things local to you, there is not any point using the remote one.

Hope it helps:-
 
Hai Lin
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your good answer, guys!

Hai
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic