The entity bean handle dilemma

The entity bean handle dilemma

 

The entity bean handle dilemma
Paul Perrone

Enterprise Java beans provide a lot of advantages, but there are difficulties as well. This tip, which is excerpted from InformIT, offers a discussion of the problem with entity bean handles, and offers some remedies.

Paul Perrone is the co-author of Building Java Enterprise Systems with J2EE.


You might have heard or seen publications mention that you can encounter certain issues when providing an excessive number of handles to remote interfaces for entity beans. For example, suppose that you have an entity bean that encapsulates a product in some e-commerce application. Now suppose that this product EJB's home interface provides some finder method that can look up products based on stock status. As you can imagine, for a large-scale commerce site with many products, an enormous number of products might be located using such finder operations. Now multiply such finder lookup operations by a thousand or more concurrent client requests under a heavily trafficked site.

Believe me, despite any hype about scalability from a vendor, this can cripple an EJB application server. I've attended talks and read articles from vendors, EJB/J2EE expert

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on recent service-oriented architecture (SOA) and SOA-related topics such as integration, governance, Web services, Cloud and more.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSOA.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSOA.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

authors, and even a few EJB/J2EE expert consultants; after the talks or in private communication with these folks, I start asking questions about example scalability scenarios in which they've run such applications. About 75% of the time, their responses reveal the minimalist scenarios in which they've deployed their EJB applications. I even sat in on a talk in which one guy harped on about how scalable and well-performing such EJB application servers are -- afterward, however, I discovered that he was running the "Pet Store Demo" that is associated with the J2EE reference implementation, and he was running it on an intranet with two other colleagues.

One way around such a dilemma is to create a mechanism by which entity bean data is serialized and sent back to the client that requests such data. Various patterns discuss this approach. The approach basically revolves around providing a session bean that receives the client request, formulates the entity bean home interface finder call, receives the response, and manages how data from the entity bean remote interfaces is serialized into a response to the client. In fact, this leads to a very common pattern in which session beans act as the primary interface for clients to the application server, and the session beans handle all access to the data tier via entity beans. This pattern leads to an architecture in which session beans represent the business objects and managers for collections of entities.

Such a pattern is great for data retrieval, but when data must be updated, created, or deleted, a different set of problems must be considered. The session bean front-line interface for clients can still be maintained as the pattern, of course. However, for creates or deletes, the session bean simply might provide an extra amount of overhead because it will largely delegate the creation or removal call to the entity-bean tier. The new EJB v2.0 "local interface" can partially alleviate this problem because local interfaces help avoid the remote method invocation overhead from the session bean interaction with the entity bean. As for updates, if a session bean has serialized the entity bean data, it will have to perform another lookup on the EJB home interface for the entity bean to perform the update.


To read the article from which this tip was excerpted, click over to InformIT. You have to register there, but the registration is free.


This was first published in November 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.