X Tutup
Skip to content

Commit 642cf92

Browse files
committed
iluwatar#89 Added comments to the example code
1 parent 61573e9 commit 642cf92

File tree

8 files changed

+50
-0
lines changed

8 files changed

+50
-0
lines changed

business-delegate/src/main/java/com/iluwatar/App.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* The Business Delegate pattern adds an abstraction layer between presentation and business tiers.
6+
* By using the pattern we gain loose coupling between the tiers. The Business Delegate encapsulates
7+
* knowledge about how to locate, connect to, and interact with the business objects that make up
8+
* the application.
9+
*
10+
* Some of the services the Business Delegate uses are instantiated directly, and some can be retrieved
11+
* through service lookups. The Business Delegate itself may contain business logic too potentially tying
12+
* together multiple service calls, exception handling, retrying etc.
13+
*
14+
* In this example the client (Client) utilizes a business delegate (BusinessDelegate) to execute a task.
15+
* The Business Delegate then selects the appropriate service and makes the service call.
16+
*
17+
*/
318
public class App {
419

520
public static void main(String[] args) {

business-delegate/src/main/java/com/iluwatar/BusinessDelegate.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* BusinessDelegate separates presentation and business tiers
6+
*
7+
*/
38
public class BusinessDelegate {
49

510
private BusinessLookup lookupService = new BusinessLookup();

business-delegate/src/main/java/com/iluwatar/BusinessLookup.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Class for performing service lookups
6+
*
7+
*/
38
public class BusinessLookup {
49

510
public BusinessService getBusinessService(ServiceType serviceType) {

business-delegate/src/main/java/com/iluwatar/BusinessService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Interface for service implementations
6+
*
7+
*/
38
public interface BusinessService {
49

510
void doProcessing();

business-delegate/src/main/java/com/iluwatar/Client.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Client utilizes BusinessDelegate to call the business tier
6+
*
7+
*/
38
public class Client {
49

510
private BusinessDelegate businessDelegate;

business-delegate/src/main/java/com/iluwatar/EjbService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Service EJB implementation
6+
*
7+
*/
38
public class EjbService implements BusinessService {
49

510
@Override

business-delegate/src/main/java/com/iluwatar/JmsService.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Service JMS implementation
6+
*
7+
*/
38
public class JmsService implements BusinessService {
49

510
@Override

business-delegate/src/main/java/com/iluwatar/ServiceType.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.iluwatar;
22

3+
/**
4+
*
5+
* Enumeration for service types
6+
*
7+
*/
38
public enum ServiceType {
49

510
EJB, JMS;

0 commit comments

Comments
 (0)
X Tutup