[ Team LiB ] |
B.4 Business Tier Interface Patterns
GoalEncapsulates knowledge of how to locate, connect to, and interact with business objects in the presentation tier (Figure B-7). Figure B-7. Classes in the Business Delegate patternParticipants
InteractionsA client calls a business method of the business delegate. The delegate locates the correct business service and connects to it. The business service grants the business delegate access to the relevant business objects. The business delegate manipulates the business objects and returns the result to the client. NotesBusiness delegates are part of the client's data model, not the business tier. In non-EJB implementations, delegates often use service adapters to connect to business services. In an EJB implementation, delegates may perform JNDI lookups and manipulate EJB home objects directly, or may use service locators or data access objects. Business delegates may be stateful or stateless. Business delegates may also be nested, allowing one delegate to use other delegates.
GoalSimplify instantiation and configuration of business delegates. Participants
InteractionsA client creates a new instance of a business delegate factory. The client sets attributes of the factory that control the type and options of the desired delegate. The factory generates a new instance of the requested delegate with the relevant parameters and returns it to the client. The client uses the delegate to interact with the business tier. NotesA business delegate factory may be stateful or stateless. If the factory is stateless, each call must contain all the required configuration parameters, but the factory can be a singleton.
GoalSimplify access to remote business data by adapting the data into Java objects. Participants
InteractionsThe client creates and initializes the service adapter. The client requests business data from the adapter, passing in Java objects as arguments. The adapter connects to the remote service using an appropriate protocol and translates any arguments to the correct form. The adapter receives the results and translates them into Java objects, which are returned to the client. NotesService adapters are most useful when business data is stored in a non-Java format. Adapters may also be used to impose desired semantics such as transactions onto services. For EJBs, service locators are usually more appropriate than service adapters.
GoalSimplify and centralize connections to remote services (Figure B-10). Figure B-10. Classes in the Service Locater patternParticipants
InteractionsThe client instantiates and configures the service locator. The client requests a remote service factory from the locator. The locator looks up and optionally caches the service factory. The client uses the factory to generate an instance of the business service. The client uses the business service to manipulate business data. NotesIn J2EE, service locators can be used to encapsulate interactions with the JNDI directory. The service factories are EJB home objects, or JMS connection factories. EJB service locators frequently cache results of JNDI lookups such as EJB home objects.
GoalIncrease performance by organizing remote business data in the most efficient manner (Figure B-12). Figure B-12. Classes in the Session Façade patternParticipants
InteractionsThe client calls a business method of the remote session façade. The façade locates and manipulates business objects locally and returns the result to the client. NotesSession façades are most effective when using Session EJBs and EJB local home objects. This combination allows the façade to manipulate EJBs locally, significantly reducing network overhead. Façades usually communicate with clients using DTOs. |
[ Team LiB ] |