Delegate Design Patterns

Business Delegate Pattern is used to decouple presentation tier and business tier. It is basically use to reduce communication or remote lookup functionality to business tier code in presentation tier code. In business tier we have following entities.

  • Client - Presentation tier code may be JSP, servlet or UI java code.

  • Business Delegate - A single entry point class for client entities to provide access to Business Service methods.

  • LookUp Service - Lookup service object is responsible to get relative business implementation and provide business object access to business delegate object.

  • Business Service - Business Service interface. Concrete classes implement this business service to provide actual business implementation logic.


We are going to create a Client, BusinessDelegate, BusinessService, LookUpService, JMSService and EJBService representing various entities of Business Delegate patterns.

BusinessDelegatePatternDemo, our demo class, will use BusinessDelegate and Client to demonstrate use of Business Delegate pattern.


Step 1

Create BusinessService Interface.
public interface BusinessService {
   public void doProcessing();

Step 2
Create concrete Service classes

public class EJBService implements BusinessService {

   public void doProcessing() {
      System.out.println("Processing task by invoking EJB Service");

public class JMSService implements BusinessService {

   public void doProcessing() {
      System.out.println("Processing task by invoking JMS Service");

Step 3
Create Business Lookup Service.

public class BusinessLookUp {
   public BusinessService getBusinessService(String serviceType){
         return new EJBService();
      else {
         return new JMSService();

Step 4
Create Business Delegate.

public class BusinessDelegate {
   private BusinessLookUp lookupService = new BusinessLookUp();
   private BusinessService businessService;
   private String serviceType;

   public void setServiceType(String serviceType){
      this.serviceType = serviceType;

   public void doTask(){
      businessService = lookupService.getBusinessService(serviceType);

Step 5
Create Client.

public class Client {
   BusinessDelegate businessService;

   public Client(BusinessDelegate businessService){
      this.businessService  = businessService;

   public void doTask(){		

Step 6
Use BusinessDelegate and Client classes to demonstrate Business Delegate pattern.

public class BusinessDelegatePatternDemo {
   public static void main(String[] args) {

      BusinessDelegate businessDelegate = new BusinessDelegate();

      Client client = new Client(businessDelegate);


Step 7
Verify the output.
Processing task by invoking EJB Service
Processing task by invoking JMS Service

While this seemingly just abstracts away some of the functionality into another class, the real power of this pattern comes when there are multiple delegates. The delegator typically has a method for each delegate that will convert the delegator to use that delegate.

It is useful for understanding to compare the delegation pattern to inheritance. Both are powerful reuse techniques with a few of key differences; inheritance is directly supported by today’s object-oriented programming languages and enables the use of polymorphism, whereas the delegation pattern allows the delegate to be changed at run-time.

  • Clearly separates the different sets of functionality
  • Run-time flexibility
  • Not as trivial as implementing inheritance