@@ -3,7 +3,6 @@ title: Gateway
33category : Structural
44language : en
55tag :
6- - Gang of Four
76- Decoupling
87
98---
@@ -38,7 +37,7 @@ The main class in our example is the `ExternalService` that contains items.
3837class ExternalServiceA implements Gateway {
3938 @Override
4039 public void execute () throws Exception {
41- System . out . println (" Executing Service A" );
40+ LOGGER . info (" Executing Service A" );
4241 // Simulate a time-consuming task
4342 Thread . sleep(1000 );
4443 }
@@ -50,7 +49,7 @@ class ExternalServiceA implements Gateway {
5049class ExternalServiceB implements Gateway {
5150 @Override
5251 public void execute () throws Exception {
53- System . out . println (" Executing Service B" );
52+ LOGGER . info (" Executing Service B" );
5453 // Simulate a time-consuming task
5554 Thread . sleep(1000 );
5655 }
@@ -62,7 +61,7 @@ class ExternalServiceB implements Gateway {
6261class ExternalServiceC implements Gateway {
6362 @Override
6463 public void execute () throws Exception {
65- System . out . println (" Executing Service C" );
64+ LOGGER . info (" Executing Service C" );
6665 // Simulate a time-consuming task
6766 Thread . sleep(1000 );
6867 }
@@ -100,7 +99,7 @@ public class App {
10099 serviceB. execute();
101100 serviceC. execute();
102101 } catch (ThreadDeath e) {
103- System . out . println (" Interrupted!" + e);
102+ LOGGER . info (" Interrupted!" + e);
104103 throw e;
105104 }
106105 }
0 commit comments