Click here to watch in Youtube : https://www.youtube.com/watch?v=qBGmTIRAlBM
Click the below Image to Enlarge
Business Delegate Design Pattern - Implementation - Class Diagram |
BusinessService.java
public interface BusinessService
{
public void doProcessing();
}
EJBService.java
public class EJBService implements BusinessService
{
@Override
public void doProcessing()
{
System.out.println("Processing task by invoking EJB Service");
}
}
JMSService.java
public class JMSService implements BusinessService
{
@Override
public void doProcessing()
{
System.out.println("Processing task by invoking JMS Service");
}
}
BusinessLookUp.java
public class BusinessLookUp
{
public BusinessService getBusinessService( String serviceType )
{
if( serviceType.equalsIgnoreCase("EJB") )
{
return new EJBService();
}
else if( serviceType.equalsIgnoreCase("JMS") )
{
return new JMSService();
}
return null;
}
}
BusinessDelegate.java
public class BusinessDelegate
{
private BusinessLookUp lookupService = new BusinessLookUp();
private BusinessService businessService;
public void doTask( String serviceType )
{
businessService = lookupService.getBusinessService(serviceType);
System.out.println(businessService.toString() + " : Got business service object after do the look up");
businessService.doProcessing();
}
}
Client.java
public class Client
{
public static void main( String[] args )
{
BusinessDelegate businessDelegate = new BusinessDelegate();
System.out.println("Invoke the business delegate by passing service type as EJB");
businessDelegate.doTask("EJB");
System.out.println("");
System.out.println("Invoke the business delegate by passing service type as JMS");
businessDelegate.doTask("JMS");
}
}
Output
Invoke the Service Locator by passing service type as EJB
EJBService@42719c : Got business service object after do the look up
Processing task by invoking EJB Service
Invoke the Service Locator by passing service type as JMS
JMSService@119298d : Got business serve object after do the look up
Processing task by invoking JMS Service
Nice blog, Thank you for sharing this helpful content with us. If you are looking free guest posting site for backlinks, Here is an updated list of the best guest blog SEO opportunities. Even newer SEO sites allow paid guest posting, with most of these sites offering free guest writing opportunities.
ReplyDeleteFor more info visit us:- Guest posting Site List
Thank you for this clear and concise explanation of the Business Delegate design pattern! Your breakdown of its structure and benefits, especially in decoupling presentation-tier clients from business services, makes the concept easy to grasp. It’s a helpful reminder of how essential design patterns are for creating scalable and maintainable applications. Do you have any examples or scenarios where implementing the Business Delegate pattern significantly improved a project’s architecture? Thanks again for sharing your expertise
ReplyDeleteEpicforce Tech