Discussions

J2EE patterns: Use local interfaces with entities

  1. Use local interfaces with entities (35 messages)

    An entity bean is a data object, not a business process object. Accessing an entity bean directly over the network is expensive, due to:

    The stub
    The skeleton
    Marshaling/demarshaling
    The network call
    The EJB object interceptor

    You can minimize these expensive calls to entity beans by wrapping them with session beans. The session beans perform bulk CRUD (create, read, update, delete) operations on behalf of remote clients. You can also wrap entity beans with other entity beans.

    Since entity beans should not be called directly from remote clients, but rather should be called from objects located in the same process, we'd like to access entity beans in a high-performing way. Therefore,

    Call entity beans through their local interfaces.

    EJB 2.0 defines the local interface as a high-performing way to access an enterprise bean. The local interface removes most of the overhead associated with calling an EJB component. Local interfaces empower developers to make enterprise beans more fine-grained, and are perfect for accessing entity beans.

    Threaded Messages (35)

  2. Use local interfaces with entities[ Go to top ]

    I agree. In fact, I wonder why the specs didn't go as far as to abolish remote interfaces for entity beans altogether. It's counterintuitive to access an entity bean directly through a remote interface and then access its related objects through value objects. Doing away with the remote interfaces for entity beans would have forced a design decision on the developer but it'd have removed a lot of unnecessary confusion.

    Satadru
  3. An EJB 2.0 compliant container still has to be backward compatible with EJB 1.1 code does it not?
  4. No, it has to support both the 1.1 and 2.0 spec, but that doesn't mean you can't use the 2.0 features of a "2.0 bean."

    I suspect that the vendor specific deployment tools (where they exist) will have a "is this a 1.1 or a 2.0" bean flag somewhere! :)

    Chz

    Tony
  5. Use local interfaces with entities[ Go to top ]

    its true that we should always be using Local Interfaces for EB to EB relations, but what are the clustering issues.

    Moreover, if we use CMR, then the target EB need to provide LocalInterfaces. Do LocalInterfaces allow clustering. And if they do, then there is a possibility that the JNDI will return a reference to an object on the other member of the cluster, then how CMR is going to work.

    Ranit
  6. Use local interfaces with entities[ Go to top ]

    Hi ranit,
    Its true when your using local object the ejbs in the relationship should be in the same server.If you have to go for clustering ,go for EJBObject & EJBHome instead of EJBLocalObject & EJBLocalHome ,use seperate jar & ejb-jar for each of the ejb's involved.
  7. Use local interfaces with entities[ Go to top ]

    In this case, we choose that one session bean wraps multiple entity beans.
    Yihua he
  8. Use local interfaces with entities[ Go to top ]

    Do any EJB vendors currently support this feature (local interfaces) of the EBJ 2.0 proposed spec?
  9. This feature is available in the latest version (6.5) of the PowerTier app server from Persistence. This feature is referred to as "collocation optimization". Using this feature, we have seen a 30% reduction in execution time for some of our bean intensive operations.
  10. It's really interesting..
    And I am just wondering that..Local interfaces were only announced a couple weeks ago and this feature is available in PowerTier app server!!!?? Great!!!

    Parithi
  11. Is the PowerTier feature simply a container optimization on the use of collocated remote interfaces? That's what WebLogic Server does...
  12. Do any EJB vendors currently support this

    > feature (local interfaces) of the EBJ 2.0
    > proposed spec?

    Weblogic 6.1 will support local interfaces (beta available soon).

    --
    Cedric
  13. This sounds very interesting. Is it somehting that can be done now using EJB 1.1 or do we need a container which supports EJB 2.0. Could we have code example please
  14. I haven't seen any code example of using Local interfaces. Can someone provide it? Also, currently atleast BEA WLS6.0 is not supporting it.
  15. Man... you guys are awfully demanding -- I like that. :-) Local interfaces were only announced a couple weeks ago, so no vendors support it just yet.

    Local interfaces will be supported in WebLogic Server in the near future, but I can't comment as to exactly when -- it will be soon, though.

    Tyler

  16. Tyler said:

    Local interfaces will be supported in WebLogic Server in the near future, but I can't comment as to exactly when -- it will be soon, though.

    ----------

    Tyler, since you seem to be up on local interfaces, maybe you can explain to me what the benefit of local interfaces is (from your's or Weblogic's point of view), specifically:

      I've heard that the Weblogic container already optimizes intra-vm calls, but that those calls use pass by reference instead of pass by value semantics. Why can't the container just make copies of the arguments if it makes a local call. This would

      a) keep remote semantics intact
      b) improve performance over remote calls
      c) keep developers from having to deal with YAEC (yet another ejb complexity - the addition of local interfaces to the mix)

    What do local interfaces give us beyond what this sort of optimization already gives us?

    God bless,
    -Toby Reyelts

  17. Hi... Sorry to take so long to respond.

    Well, my personal feelings are truly mixed about whether or not pass-by-reference should even be allowed in a container. Toby, you make some excellent points about optimizing calls but maintaining pass-by value semantics.

    However, the performance of pass-by-value will always be in question and vendors want pass by reference.

    Let's think of this another way, though. We have become so ingrained with thinking about EJBs as only having remote interfaces, we are shocked to think of local interfaces. I don't think it's so shocking. All developers begin learning the Java language by understanding pass by reference semnatics and the performance benefits within a same VM. One could argue that a system should be designed with nothing but local interfaces internally and then expose only certain services with a remote interface or a SOAP web service. I think if this were done initially with the EJB specification, it would force developers to 1) design their components correctly for granularity and 2) come up with appropriate remote interfaces that don't have a lot of silly accessor / utility methods that shouldn't be exposed.

    So, that's one argument. Another argument for having pass-by-reference is that EJBs will be able to pass objects that can't be passed by value. For example, Reflection objects are not serializable and can't be passed over RMI, but they can be passed as an input parameter to a local method.

    Tyler
  18. Use local interfaces with entities[ Go to top ]

    The Weblogic6.1 documentation shows that local-reference calling of a Bean is possible which is not the same with Weblogic6.0 . Any idea about any patch-ups which would make the local-reference call possible for 6.0 version ?
  19. Use local interfaces with entities[ Go to top ]

    The Weblogic6.1 documentation shows that local-reference calling of a Bean is possible which is not the same with Weblogic6.0 . Any idea about any patch-ups which would make the local-reference call possible for 6.0 version ?
  20. But WLS already uses call-by-reference even from 5.1. It basically is same thing as the local interface.

    minjiang
  21. Use local interfaces with entities[ Go to top ]

    Weblogic 6.1 supports Ejb 2.0 specification ie,cmp,cmr etc...also has GUI for administration .The cluster can be set up in 2 minutes using the weblogic 6.1 leaving other app server vendors far behind.
  22. can anybody explain what is the difference between
    dependent object of draft 1 of EJB 2.0
    and local interfaces of draft 2 of EJB 2.0 ..
    I failed to locate any explanation as why
    dependent objects is dropped from Draft 2 of EJB 2.0




  23. Use local interfaces with entities[ Go to top ]

    Outside of having entity beans as data objects, this type
    of bean seems that has been designed for remote access.
    Ok. I agree and I welcome this.
    But... I actually can't find any reason for mapping relational data as EJB (with remote accessibility) and after that suggesting use of "local interface" by local session beans calls so that optimizes accessibility.

    Doesn't this look like
    something comes when you go ?????

    Comparing all that with traditional way of mapping data to regular java beans and following with an access layer from session beans, does anybody see some run-time differences between theme.

    I mean run-time differences anything that doesn't concern the design time commodity
    (easy graphical mapping with xml, not writing jdbc and anything else like that).
      
  24. Which begs the question: What is the point of Entity EJBs?

    We have done a complete design / implementation cycle on our app using Weblogic 5.1, and the only benefit that we can see is the following:

    The advantage of an Entity EJB is that when an application is distributed and a session bean accesses an entity bean located on a different machine, it will get the instance of the entity bean on that machine. Therefore if, during the same transaction, two session beans located on different machines access the same entity bean at different times during the transaction, they will access the same cached bean and therefore intermediate, non-committed changes to the database will be reflected properly. That is, changes to the entity bean's attributes that have not yet been saved to the database will be maintained throughout the entire transaction.

    Is this a correct conclusion? If so, doesn't this usefulness become insignificant given that weblogic (don't know about others) recommends that instead of deploying the EJBs on different machines, they should all be deployed on each machine and clustering should be used for fail-over/load balancing?

    Thanx for your help.


  25. I agree with Gerald!

    In addition:

    An entity bean's sole purpose in life is to hide the details of database access, to access the database in a simular fashion and to reduce dependency on learning SQL. You also can minimize your connections to the database on a session by session basis, but with the amount of overhead all this implies it seems counterproductive. I have always used entity beans in a limited fashion, using them for complex transactions but always masked by a session bean. This has always given us the best performance.

    rich
  26. Local Interfaces and Clustering[ Go to top ]

    Hi ServerSiders.
    Here is a new member in your group with lot of queries for u....

    well...

    i m working on EJB 2.0 using Weblogic 6...i'll be heavily using local interfaces for beans communication and clustering has be implemented in my system.....

    could anybody focus on behaviour of local interfaces in clustered environment?

    thanx..
  27. This gets me re-thinking EJBs. Given some of the "issues" with entity beans (performance, bulk cacheing & optimistic locking "work arounds", clustering, vendor locking) my take it that the above pattern degenerates to "standardized" DAOs.

    From that, I go to EJBs degenerating to session beans + DAO. Which I am quite happy with since I *do* trust the database for reliability/clustering/cacheing/etc and I am then thankful for what *I* really want in EJB session beans --- easy-to-use transaction support.

    *But* if I had a *really* nice pattern (or implementation) for easy-to-use transaction support, I would be happy with servlets/beans/JSP/JMS + txn support + standardized DAO. System would be faster and "lighter" without all those EJB layers. Is this all sacrilegious?
  28. Use local interfaces with entities[ Go to top ]

    JBoss 2.4 BETA supports local interfaces. Thanks to a contribution by Dan O'Connor.

  29. hi,

    i'm interested in hearing what you guys suggest in the following scenario. i am coding to the EJB2.0 spec using JBoss 2.4 Beta with the persistence manager from MVCSoft.
    I am using local entities with cmp and cmr (container managed relationships). Now lets say i have a complex object tree like that shown below. How is this graph of objects best passed back and forth between the client and the session facade. How do you best handle updates of a deeply nested object i.e if a client changes the address of a customer on one of the orders how should that change get reflected on the server - does the whole graph have to be passed back. Should the session facade provide fine grained update methods...
    i guess i'm assuming a session facade for handling the CompositeOrders only - would it be better to have more fine grained session facades.


    regards,
    Colin Daly.


    CompositeOrder
      Salesperson salesperson
      Collection orders

    Order
      Customer customer
      Collection lineItems

    LineItem
      Product product
      double quantity

    Customer
      ContactInfo contactInfo
      Address billingAddress
      Address shippingAddress



     
  30. Use local interfaces with entities[ Go to top ]

    I am getting compilation errors when i tried to create ejb jar ..My bean is entity bean with local interface..It works fine if the interface is remote..

    ..._xfd0ny_ELOImpl.java:53: Wrong number of arguments in constructor.
                  throw new javax.ejb.EJBException("Unexpected exception in " +
  31. Hi There,

    I am facing problem while compiling the CMP Entity Bean.
    Following is the error message.

    D:\ADDezai\J2EEExamples\ejbcgen\com\bean\entity\UserBean_p3h65u_ELOImpl.java:53: Wrong number of arguments in constructor.
    throw new javax.ejb.EJBException("Unexpected exception in " +
    .............................

    Please let me know anybuddy has work around on this.
    You can directoly mail me on addezai at gmail dot com for quick response.

    Regards,

    Amit Desai
  32. Use local interfaces with entities[ Go to top ]

    How does the App Server handles the clustering if we use the local interfaces for entity beans?
  33. who can tell me how to test local interface entitybean?
    you'd better answer the question with code,thank you.
  34. To test the Local Interface you can use the cactus framework.
  35. **** off
  36. Use local interfaces with entities[ Go to top ]

    As per EJB2.0 specification if you used CMR, their is a restriction that you need to use Local objects.