Skip to content

Commit 31d9ebf

Browse files
Initial Commit
1 parent adb8759 commit 31d9ebf

File tree

10 files changed

+153
-0
lines changed

10 files changed

+153
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<artifactId>mainappmodule</artifactId>
5+
<packaging>jar</packaging>
6+
<version>1.0</version>
7+
8+
<parent>
9+
<groupId>com.baeldung.decoupling-pattern1</groupId>
10+
<artifactId>com.baeldung.decoupling-pattern1</artifactId>
11+
<version>1.0</version>
12+
</parent>
13+
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<groupId>org.apache.maven.plugins</groupId>
18+
<artifactId>maven-compiler-plugin</artifactId>
19+
</plugin>
20+
</plugins>
21+
</build>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>com.baeldung.servicemodule</groupId>
26+
<artifactId>servicemodule</artifactId>
27+
<version>1.0</version>
28+
</dependency>
29+
</dependencies>
30+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.baeldung.consumermodule;
2+
3+
import com.baeldung.servicemodule.external.TextService;
4+
import com.baeldung.servicemodule.external.TextServiceFactory;
5+
6+
public class Application {
7+
8+
public static void main(String args[]) {
9+
TextService textService = TextServiceFactory.getTextService("lowercase");
10+
System.out.println(textService.processText("Hello from Baeldung!"));
11+
}
12+
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module com.baeldung.consumermodule {
2+
requires com.baeldung.servicemodule;
3+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.baeldung.decoupling-pattern1</groupId>
7+
<artifactId>decoupling-pattern1</artifactId>
8+
<version>1.0</version>
9+
<packaging>pom</packaging>
10+
11+
<modules>
12+
<module>servicemodule</module>
13+
<module>consumermodule</module>
14+
</modules>
15+
16+
<build>
17+
<pluginManagement>
18+
<plugins>
19+
<plugin>
20+
<groupId>org.apache.maven.plugins</groupId>
21+
<artifactId>maven-compiler-plugin</artifactId>
22+
<version>3.8.0</version>
23+
<configuration>
24+
<source>11</source>
25+
<target>11</target>
26+
</configuration>
27+
</plugin>
28+
</plugins>
29+
</pluginManagement>
30+
</build>
31+
32+
<properties>
33+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
</properties>
35+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>com.baeldung.servicemodule</groupId>
6+
<artifactId>servicemodule</artifactId>
7+
<packaging>jar</packaging>
8+
9+
<parent>
10+
<groupId>com.baeldung.decoupling-pattern1</groupId>
11+
<artifactId>decoupling-pattern1</artifactId>
12+
<version>1.0</version>
13+
</parent>
14+
15+
<build>
16+
<plugins>
17+
<plugin>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-compiler-plugin</artifactId>
20+
</plugin>
21+
</plugins>
22+
</build>
23+
24+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.baeldung.servicemodule.external;
2+
3+
public interface TextService {
4+
5+
String processText(String text);
6+
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.servicemodule.external;
2+
3+
import com.baeldung.servicemodule.internal.LowercaseTextService;
4+
import com.baeldung.servicemodule.internal.UppercaseTextService;
5+
6+
public class TextServiceFactory {
7+
8+
private TextServiceFactory() {}
9+
10+
public static TextService getTextService(String name) {
11+
return name.equalsIgnoreCase("lowercase") ? new LowercaseTextService(): new UppercaseTextService();
12+
}
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.servicemodule.internal;
2+
3+
import com.baeldung.servicemodule.external.TextService;
4+
5+
public class LowercaseTextService implements TextService {
6+
7+
@Override
8+
public String processText(String text) {
9+
return text.toLowerCase();
10+
}
11+
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.baeldung.servicemodule.internal;
2+
3+
import com.baeldung.servicemodule.external.TextService;
4+
5+
public class UppercaseTextService implements TextService {
6+
7+
@Override
8+
public String processText(String text) {
9+
return text.toUpperCase();
10+
}
11+
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module com.baeldung.servicemodule {
2+
exports com.baeldung.servicemodule.external;
3+
}

0 commit comments

Comments
 (0)