Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Business delegate pattern

From Wikipedia, the free encyclopedia

Business delegate is aJava EE design pattern.[1] This pattern is directed towards reducing thecoupling in between business services and the connected presentation tier, and to hide the implementation details of services (including lookup and accessibility ofEJB architecture).[1][2] Business delegates acts as an adaptor to invoke business objects from the presentation tier.[3]

Structure

[edit]

Requests to access underlying business services are sent from clients, and lookup services are used by business delegates to locate the business service components.[1]

Components

[edit]

Basic components are Business delegate, Lookup service and business service.

Business delegate

[edit]

Control and protection are provided through business delegate which can have two types of structures, without ID and with ID, where ID is a string version of the reference to a remote object such as EJBHome or EJBObject.[1]

Lookup service

[edit]

Business service is located by lookup service which is used by the business delegate. The implementation details of business service lookup is encapsulated by lookup service.[1]

Business service

[edit]

This a business-tier component, such as an enterprise bean or a JMS component, which provides the required service to the client.[1]

Consequences

[edit]

Some consequences are as follows:

  • More flexibility and maintainability as intermediate business delegate layer decouples the business layer from the presentation layer.
  • Business delegate exposes a uniform API to the presentation tier to access business logic.[1][3]

Concerns

[edit]

Following concerns can be considered:

  • Maintenance due to the extra layer that increases the number of classes in the application.
  • Business delegate should take care of the changes of the remote business object interfaces, and these types of changes are rare.[3]

Sample code

[edit]

A sample code for a Professional Services Application (PSA), where a Web-tier client needs to access a session bean that implements the session facade pattern, is provided below.

Resource Delegate:

publicclassResourceDelegate{// Remote reference for Session FacadeprivateResourceSessionsession;// Class for Session Facade's Home objectprivatestaticfinalClasshomeClazz=corepatterns.apps.psa.ejb.ResourceSessionHome.class;// Default Constructor. Looks up home and connects// to session by creating a new onepublicResourceDelegate()throwsResourceException{try{ResourceSessionHomehome=(ResourceSessionHome)ServiceLocator.getInstance().getHome("Resource",homeClazz);session=home.create();}catch(ServiceLocatorExceptionex){// Translate Service Locator exception into// application exceptionthrownewResourceException(...);}catch(CreateExceptionex){// Translate the Session create exception into// application exceptionthrownewResourceException(...);}catch(RemoteExceptionex){// Translate the Remote exception into// application exceptionthrownewResourceException(...);}}publicBusinessDelegate(Stringid)throwsResourceException{super();reconnect(id);}publicStringgetID(){try{returnServiceLocator.getId(session);}catch(Exceptione){// Throw an application exception}}publicvoidreconnect(Stringid)throwsResourceException{try{session=(ResourceSession)ServiceLocator.getService(id);}catch(RemoteExceptionex){// Translate the Remote exception into// application exceptionthrownewResourceException(...);}}publicResourceTOsetCurrentResource(StringresourceId)throwsResourceException{try{returnsession.setCurrentResource(resourceId);}catch(RemoteExceptionex){// Translate the service exception into// application exceptionthrownewResourceException(...);}}publicResourceTOgetResourceDetails()throwsResourceException{try{returnsession.getResourceDetails();}catch(RemoteExceptionex){// Translate the service exception into// application exceptionthrownewResourceException(...);}}publicvoidsetResourceDetails(ResourceTOvo)throwsResourceException{try{session.setResourceDetails(vo);}catch(RemoteExceptionex){thrownewResourceException(...);}}publicvoidaddNewResource(ResourceTOvo)throwsResourceException{try{session.addResource(vo);}catch(RemoteExceptionex){thrownewResourceException(...);}}// all other proxy method to session bean...}

[1]

See also

[edit]

References

[edit]
  1. ^abcdefgh"Core J2EE Patterns – Business Delegate".Oracle. Oracle. Retrieved22 June 2016.
  2. ^Screening Technical Design Document – Version 2.0. Indiana, USA: Indiana state. p. 7.
  3. ^abcKayal, D. (2008).Pro Java EE Spring Patterns. New York: Apress. pp. 161–166.
Gang of Four
patterns
Creational
Structural
Behavioral
Concurrency
patterns
Architectural
patterns
Other
patterns
Books
People
Communities
See also
Retrieved from "https://en.wikipedia.org/w/index.php?title=Business_delegate_pattern&oldid=1271812331"
Category:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp