Content deleted Content added
Shevonsilva (talk | contribs) ←Created page with ''''Business delegate''' is a Java EE design pattern. <ref name=":o_cjp">{{Cite web|url = http://www.oracle.com/technetwork/...' |
|||
(21 intermediate revisions by 15 users not shown) | |||
Line 1:
'''Business delegate''' is a [[Java Platform, Enterprise Edition|Java EE]] design pattern.
<ref name=":o_cjp">{{Cite web|url = http://www.oracle.com/technetwork/java/businessdelegate-137562.html|title = Core J2EE Patterns
==Structure==
Requests to access underlying business services are sent from clients, and lookup services are used by business delegates to locate the business service components.<ref name=":o_cjp"/>
===Components===
Basic components are Business delegate, Lookup service and business service.
====Business delegate====
Control and protection are provided through business delegate which can have two types of
====Lookup
Business service is located by lookup service which is used by the business delegate.
====Business service====
This a business-tier component, such as an enterprise bean or a JMS component, which provides the required service to the client.<ref name=":o_cjp"/>
==Consequences==
Some consequences are as follows:
* More flexibility and
* Business delegate exposes a uniform API to the
==Concerns==
* Maintenance due to the extra layer that
* Business delegate should take care of the changes of the remote business object interfaces, and these types of changes are rare.<ref name=":pjeesp"/>
==Sample code==
A sample code for a Professional Services Application (PSA), where a Web-tier
Resource Delegate:
<
public class ResourceDelegate {
// Remote reference for Session Facade
private ResourceSession session;
// Class for Session Facade's Home object
private static final Class homeClazz =
corepatterns.apps.psa.ejb.ResourceSessionHome.class;
// Default Constructor. Looks up home and connects
// to session by creating a new one
public ResourceDelegate() throws ResourceException {
try {
ResourceSessionHome home = (ResourceSessionHome)
ServiceLocator.getInstance().getHome(
"Resource", homeClazz);
session = home.create();
} catch (ServiceLocatorException ex) {
// Translate Service Locator exception into
// application exception
throw new ResourceException(...);
} catch (CreateException ex) {
// Translate the Session create exception into
// application exception
throw new ResourceException(...);
} catch (RemoteException ex) {
// Translate the Remote exception into
// application exception
throw new ResourceException(...);
}
}
public BusinessDelegate(String id)
throws ResourceException {
super();
}
return ServiceLocator.getId(session);
// Throw an application
}
public void reconnect(String id)
throws ResourceException {
session = (ResourceSession)ServiceLocator.getService(id);
} catch (RemoteException ex) {
// Translate the Remote exception into
// application exception
throw new ResourceException(...);
}
public ResourceTO
String resourceId)
throws ResourceException {
try {
return session.
} catch (RemoteException ex) {
// Translate the service exception into
// application exception
throw new ResourceException(...);
}
}
throws ResourceException {
try {
return session.getResourceDetails();
} catch (RemoteException ex) {
// Translate the service exception into
// application exception
throw new ResourceException(...);
}
}
public void setResourceDetails(ResourceTO vo)
throws ResourceException {
try {
session.setResourceDetails(vo);
} catch (RemoteException ex) {
throw new ResourceException(...);
}
}
public
throws ResourceException {
try {
session.addResource(vo);
} catch (RemoteException ex) {
throw new ResourceException(...);
}
}
// all other proxy method to session bean
...
}
</
==See also==
Line 259 ⟶ 147:
{{Design Patterns Patterns}}
[[Category:Software design patterns]]
[[Category:Articles with example Java code]]
|