• Post Reply Bookmark Topic Watch Topic
  • New Topic

Home and Remote interfaces  RSS feed

 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Why do we require two interfaces(EJBHome interface and EJBObject interface) in an EJB?
Why cant we have create and find methods and BusinessLogic methods together in a single interface?

Rgds,
Sree
 
vikassheel gupta
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dear
i think u dont know the architecture of EJB thats why u ask this thing we use these two interfaces because
home interface cant interact with the beans it will return the bean object
remoter interface doesnt make the object it will interact with the bean through that object which is generated by the home interface so thats why we need these two interfaces

i hope u got this thing
 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vikassheet

Thank you very much for your reply

Is this what u have explained?

Object obj=inctx.lookup("xyzJNDI);
MyHome mh=(MyHome)PortableRemoteObect.narrow(obj,MyHome.class);
MyRemote mr=mh.create(); (home interface cant interact with the beans
it will return the bean object )
int c=mr.myRemoteMethod(int a,intb);(remoter interface doesnt make
the object it will interact with the
bean through that object which is
generated by the home interface so
thats why we need these two interfaces)


But unfortunately this is not the answer which i expected. My Question is is actually what is the benefit of haveing the architecture like the one which EJB has.
for eg: whiat if we have an architecture in which i can do the above thing as follows

Object obj=inctx.lookup("xyzJNDI);
MyHome mh=(MyHome)PortableRemoteObect.narrow(obj,MyHome.class);(let the
bean object be returned here itself)
int c=mh.myRemoteMethod(int a,intb);(I am calling my remotemethod with home
interface reference)


Rgds
Sree
 
Eddy Lee Sin Ti
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the mean of specifications and standards, each enterprise beans will have a remote/local, home, and bean definitions. The purposes of having these definitions are to ensure loose coupling and high cohesion of association between them. Thus, by this design, you can modify the each one of them in relatively independent way. Well defined role and modularization also preserved in this design.

Of course, there are criticism on the fact that implementing an enterprise bean to do something simple requires spending efforts on defining those interface definitions. Luckily we have existing tools such as xDoclet to assist us in automating their creation.

The reason of why we need factory design pattern, MVC architecture, etc contribute some of reason of why the EJB architecture being designed like that.
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sree,

Hi Sree,


Why do we require two interfaces(EJBHome interface and EJBObject interface) in an EJB?
Why cant we have create and find methods and BusinessLogic methods together in a single interface?

Because the EJBHome acts like an object creation factory and it is not associated with any ejb instance. From a design-relation perspective is like having a relationship course-students and having a method changeStudentAddress on the course class. Does it make much sense? Which student will be actually updated? Isn�t it more natural to have this method on the student Class? Having business methods on the creation factory class will raise the same dilemma.
However the real question is why this entire Home, Remote jndi lookup scenario for EJBs? Why in fact should EJB be components at all? I tried for a while to understand why Sun had chosen this component-based architecture for EJbs. Their main reason seems to be that one can reuse business components in a similar way .NET developer can use GUI objects through OLE-COM-DCOM technology. Well in my opinion this doesn�t stand since (arguable) in practice business components (unlike GUI components) are almost never reused (I personally never saw this happening). I read once a posting from a gentlemen and it made sense to me. He said that Sun hired some of the Microsoft engineer that implemented COM+ and MTS and they tried to implement a similar architecture for Java � EJB components. You have to understand that before EJBs there were only TCP and implicit middleware services is a concept introduced by Microsoft in late 90s. Comparing with TCP, EJB looked like a dazzling and shinning architecture. However looking at what software development should be these days, the component based architecture is far from the best choice (I�d say only one word: POJO). It took over 5 years to J2EE community in order to figure this one out and questions like yours are more then entitled. I don�t know whether to laugh or cry, but I know companies that paid millions and millions of dollars in last 5 years, to implement system base on the cutting technology edge. After five years and so much money spent they discovered that their old legacy system was replaced by another newer legacy system that should be refactored soon :-)
Regards.
 
Sree kanth
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much

could you please send me a link or name of books which describes EJB architecture and JNDI indetail?

Thanks in advance

Rgds Sree
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two of them that are free and I would recommend:
  • Sun�s J2EE tutorial: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
  • Ed Roman�s Mastering EJB: http://www.theserverside.com/books/wiley/masteringEJB/


  • And by the way, you�re very welcome Sree
     
    Pradeep bhatt
    Ranch Hand
    Posts: 8933
    Firefox Browser Java Spring
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Valentin Tanase:
    Hi Sree,

    Hi Sree,


    Because the EJBHome acts like an object creation factory and it is not associated with any ejb instance. From a design-relation perspective is like having a relationship course-students and having a method changeStudentAddress on the course class. Does it make much sense? Which student will be actually updated? Isn�t it more natural to have this method on the student Class? Having business methods on the creation factory class will raise the same dilemma.
    However the real question is why this entire Home, Remote jndi lookup scenario for EJBs? Why in fact should EJB be components at all? I tried for a while to understand why Sun had chosen this component-based architecture for EJbs. Their main reason seems to be that one can reuse business components in a similar way .NET developer can use GUI objects through OLE-COM-DCOM technology. Well in my opinion this doesn�t stand since (arguable) in practice business components (unlike GUI components) are almost never reused (I personally never saw this happening). I read once a posting from a gentlemen and it made sense to me. He said that Sun hired some of the Microsoft engineer that implemented COM+ and MTS and they tried to implement a similar architecture for Java � EJB components. You have to understand that before EJBs there were only TCP and implicit middleware services is a concept introduced by Microsoft in late 90s. Comparing with TCP, EJB looked like a dazzling and shinning architecture. However looking at what software development should be these days, the component based architecture is far from the best choice (I�d say only one word: POJO). It took over 5 years to J2EE community in order to figure this one out and questions like yours are more then entitled. I don�t know whether to laugh or cry, but I know companies that paid millions and millions of dollars in last 5 years, to implement system base on the cutting technology edge. After five years and so much money spent they discovered that their old legacy system was replaced by another newer legacy system that should be refactored soon :-)
    Regards.


    Thanks for letting us know about how Sun designed EJB. When a new comer studied EJB he/she would have lot of questions but very few (or none) had convincing answer.
     
    Valentin Tanase
    Ranch Hand
    Posts: 704
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You're very welcome Pradip.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!