Access beans

WebSphere Commerce commands interact with access beans rather than directly with entity beans. EJB access beans can greatly simplify client access to enterprise beans and alleviate the performance problems that are associated with remote calls for multiple enterprise bean attributes.

Access beans are Java™ bean representations of enterprise beans. In WebSphere Commerce, access beans are used in Controller commands and Task commands. Access beans shield you from the complexities of managing enterprise bean lifecycles. This means that you can program to enterprise beans as easily as you can program to Java beans. This greatly simplifies your enterprise bean client programs and helps reduce your overall development time.

To understand how access beans solve the problem of performance degradation in client-to-enterprise bean interactions, it is helpful to review how a client program typically accesses an enterprise bean:
  • Client obtains a context to the name server (name service context).
  • Client looks up the home of the enterprise bean with the name service context.
  • Client creates an enterprise bean instance from the enterprise bean home, which returns an enterprise bean proxy object.
  • Client accesses the remote methods of the enterprise bean instance through an enterprise bean proxy object with a remote call.
Since each client call to an enterprise bean proxy object is a remote call, performance declines. If an enterprise bean has numerous attributes and multiple remote calls are made to set or get the attributes. Access beans solve the performance problem by simply caching server-side data, such as entity data, on the client side. A local cache of enterprise bean attributes significantly improves access speed to an enterprise bean.
Note: On the access bean, the get and set methods are not automatically cached. Only the methods that are part of the copy helper object are cached. The getters and setters on the remote interface are invoked when called.

In most cases, a program that uses enterprise beans must deal with the Java Naming and Directory Interface (JNDI) as well as the home and remote interfaces of enterprise beans. To simplify the programming model, an access bean for each enterprise bean is generated. There are three types of access beans: Data class, Copy helper, and bean wrapper. We use the Copy helper for Entity beans and we use the Java bean wrapper for Session beans. When you create your own enterprise beans, you can use WebSphere Commerce Developer to generate this access bean.

The following diagram displays the interaction between commands, access beans, entity beans, and the database.

Diagram showing the interaction between commands, access beans, entity beans, and the database, as detailed in the previous paragraph.