File tree Expand file tree Collapse file tree 10 files changed +153
-0
lines changed
core-java-modules/core-java-jpms/decoupling-pattern1
com/baeldung/consumermodule
com/baeldung/servicemodule Expand file tree Collapse file tree 10 files changed +153
-0
lines changed Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .consumermodule {
2+ requires com .baeldung .servicemodule ;
3+ }
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 1+ package com .baeldung .servicemodule .external ;
2+
3+ public interface TextService {
4+
5+ String processText (String text );
6+
7+ }
Original file line number Diff line number Diff line change 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 number Diff line number Diff line change 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 number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .servicemodule {
2+ exports com .baeldung .servicemodule .external ;
3+ }
You can’t perform that action at this time.
0 commit comments