It’s now time to turn our attention back to the client side of our session façade. In this section, we’ll first cover how to satisfy the requirements of our service interface with our session-bean implementation. We’ll then look at how to better manage the JNDI lookups and home and remote interface management inherent in being a remote client to an EJB.
As you saw when we defined the business
interface for the
Storefront session bean, we
still have some work to do to match it up to the Storefront service
interface. Our business interface doesn’t include
all the methods of
IStorefrontService, and the
methods that are declared include
in their throws clauses. We’ll address these
differences by going back to the Business Delegate pattern introduced
in Chapter 6. Recall that the purpose of this
pattern is to hide the business-service implementation from the
We’ll start out with a fairly straightforward Business Delegate implementation and then cover some specific ways to improve it. An initial implementation is shown in Example 13-7.
Example 13-7. A business delegate for the Storefront session bean
package com.oreilly.struts.storefront.service; import java.rmi.RemoteException; import java.util.Hashtable; import java.util.List; import javax.ejb.CreateException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; ...