#89 Added comments to the example code
This commit is contained in:
@ -1,5 +1,20 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* The Business Delegate pattern adds an abstraction layer between presentation and business tiers.
|
||||||
|
* By using the pattern we gain loose coupling between the tiers. The Business Delegate encapsulates
|
||||||
|
* knowledge about how to locate, connect to, and interact with the business objects that make up
|
||||||
|
* the application.
|
||||||
|
*
|
||||||
|
* Some of the services the Business Delegate uses are instantiated directly, and some can be retrieved
|
||||||
|
* through service lookups. The Business Delegate itself may contain business logic too potentially tying
|
||||||
|
* together multiple service calls, exception handling, retrying etc.
|
||||||
|
*
|
||||||
|
* In this example the client (Client) utilizes a business delegate (BusinessDelegate) to execute a task.
|
||||||
|
* The Business Delegate then selects the appropriate service and makes the service call.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* BusinessDelegate separates presentation and business tiers
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BusinessDelegate {
|
public class BusinessDelegate {
|
||||||
|
|
||||||
private BusinessLookup lookupService = new BusinessLookup();
|
private BusinessLookup lookupService = new BusinessLookup();
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Class for performing service lookups
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class BusinessLookup {
|
public class BusinessLookup {
|
||||||
|
|
||||||
public BusinessService getBusinessService(ServiceType serviceType) {
|
public BusinessService getBusinessService(ServiceType serviceType) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Interface for service implementations
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface BusinessService {
|
public interface BusinessService {
|
||||||
|
|
||||||
void doProcessing();
|
void doProcessing();
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Client utilizes BusinessDelegate to call the business tier
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Client {
|
public class Client {
|
||||||
|
|
||||||
private BusinessDelegate businessDelegate;
|
private BusinessDelegate businessDelegate;
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Service EJB implementation
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class EjbService implements BusinessService {
|
public class EjbService implements BusinessService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Service JMS implementation
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class JmsService implements BusinessService {
|
public class JmsService implements BusinessService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package com.iluwatar;
|
package com.iluwatar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Enumeration for service types
|
||||||
|
*
|
||||||
|
*/
|
||||||
public enum ServiceType {
|
public enum ServiceType {
|
||||||
|
|
||||||
EJB, JMS;
|
EJB, JMS;
|
||||||
|
Reference in New Issue
Block a user