6.29. Business representative model

发布时间 :2025-10-25 12:24:48 UTC      

The Business Representative pattern (Business Delegate Pattern) is used to decouple the presentation layer from the business layer. It is basically used to reduce communication or remote query capabilities for business layer code in the presentation layer code. We have the following entities in the business layer.

  • 客户端(Client) The presentation layer code can be JSP, servlet, or UI java code.

  • 业务代表(Business Delegate) -an entry class for client entities that provides access to business service methods.

  • 查询服务(LookUp Service) -the lookup service object is responsible for obtaining the relevant business implementation and providing access to the business representative object.

  • 业务服务(Business Service) -Business service interface. The entity class of the business service is implemented and the actual business implementation logic is provided.

6.29.1. Realize

We will create Client BusinessDelegate BusinessService LookUpService JMSService And EJBService To represent the various entities in the business representative model.

BusinessDelegatePatternDemo Class usage BusinessDelegate And Client To demonstrate the use of the business representative model.

业务代表模式的 UML 图

6.29.2. Step 1

Create a BusinessService interface.

BusinessService.java

publicinterfaceBusinessService{publicvoiddoProcessing();}

6.29.3. Step 2

Create an entity service class.

EJBService.java

publicclassEJBServiceimplementsBusinessService{@OverridepublicvoiddoProcessing(){System.out.println("Processing
task by invoking EJB Service");}}

JMSService.java

publicclassJMSServiceimplementsBusinessService{@OverridepublicvoiddoProcessing(){System.out.println("Processing
task by invoking JMS Service");}}

6.29.4. Step 3

Create a business query service.

BusinessLookUp.java

publicclassBusinessLookUp{publicBusinessServicegetBusinessService(StringserviceType){if(serviceType.equalsIgnoreCase("EJB")){returnnewEJBService();}else{returnnewJMSService();}}}

6.29.5. Step 4

Create a business representative.

BusinessDelegate.java

publicclassBusinessDelegate{privateBusinessLookUplookupService=newBusinessLookUp();privateBusinessServicebusinessService;privateStringserviceType;publicvoidsetServiceType(StringserviceType){this.serviceType=serviceType;}publicvoiddoTask(){businessService=lookupService.getBusinessService(serviceType);businessService.doProcessing();}}

6.29.6. Step 5

Create a client.

Client.java

publicclassClient{BusinessDelegatebusinessService;publicClient(BusinessDelegatebusinessService){this.businessService=businessService;}publicvoiddoTask(){businessService.doTask();}}

6.29.7. Step 6

Use the BusinessDelegate and Client classes to demonstrate the business representative pattern.

BusinessDelegatePatternDemo.java

publicclassBusinessDelegatePatternDemo{publicstaticvoidmain(String[]args){BusinessDelegatebusinessDelegate=newBusinessDelegate();businessDelegate.setServiceType("EJB");Clientclient=newClient(businessDelegate);client.doTask();businessDelegate.setServiceType("JMS");client.doTask();}}

6.29.8. Step 7

Execute the program and output the result:

Processing task by invoking EJB Service
Processing task by invoking JMS Service
Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.