File tree Expand file tree Collapse file tree 10 files changed +173
-0
lines changed
core-java-modules/core-java-jpms/decoupling-pattern2
com/baeldung/consumermodule
com/baeldung/providermodule
com/baeldung/servicemodule Expand file tree Collapse file tree 10 files changed +173
-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"
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+ <parent >
6+ <artifactId >com.baeldung.decoupling-pattern2</artifactId >
7+ <groupId >decoupling-pattern2</groupId >
8+ <version >1.0-SNAPSHOT</version >
9+ </parent >
10+ <modelVersion >4.0.0</modelVersion >
11+
12+ <groupId >com.baeldung.consumermodule</groupId >
13+ <artifactId >consumermodule</artifactId >
14+ <version >1.0</version >
15+
16+ <dependencies >
17+ <dependency >
18+ <groupId >com.baeldung.servicemodule</groupId >
19+ <artifactId >servicemodule</artifactId >
20+ <version >1.0</version >
21+ </dependency >
22+ <dependency >
23+ <groupId >com.baeldung.providermodule</groupId >
24+ <artifactId >providermodule</artifactId >
25+ <version >1.0</version >
26+ </dependency >
27+ </dependencies >
28+
29+ <build >
30+ <plugins >
31+ <plugin >
32+ <groupId >org.apache.maven.plugins</groupId >
33+ <artifactId >maven-compiler-plugin</artifactId >
34+ </plugin >
35+ </plugins >
36+ </build >
37+
38+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .consumermodule ;
2+
3+ import com .baeldung .servicemodule .TextService ;
4+
5+ import java .util .ServiceLoader ;
6+
7+ public class Application {
8+
9+ public static void main (String [] args ) {
10+ ServiceLoader <TextService > services = ServiceLoader .load (TextService .class );
11+ for (final TextService service : services ) {
12+ System .out .println ("The service " + service .getClass ().getSimpleName () + " says: " + service .parseText ("Hello from Baeldung!" ));
13+ }
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .consumermodule {
2+ requires com .baeldung .servicemodule ;
3+ uses com .baeldung .servicemodule .TextService ;
4+ }
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+
7+ <groupId >com.baeldung.decoupling-pattern2</groupId >
8+ <artifactId >decoupling-pattern2</artifactId >
9+ <version >1.0-SNAPSHOT</version >
10+ <packaging >pom</packaging >
11+
12+ <modules >
13+ <module >servicemodule</module >
14+ <module >providermodule</module >
15+ <module >consumermodule</module >
16+ </modules >
17+
18+ <build >
19+ <pluginManagement >
20+ <plugins >
21+ <plugin >
22+ <groupId >org.apache.maven.plugins</groupId >
23+ <artifactId >maven-compiler-plugin</artifactId >
24+ <version >3.8.0</version >
25+ <configuration >
26+ <source >11</source >
27+ <target >11</target >
28+ </configuration >
29+ </plugin >
30+ </plugins >
31+ </pluginManagement >
32+ </build >
33+
34+ </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"
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+
6+ <modelVersion >4.0.0</modelVersion >
7+ <groupId >com.baeldung.providermodule</groupId >
8+ <artifactId >providermodule</artifactId >
9+ <version >1.0</version >
10+
11+ <parent >
12+ <artifactId >com.baeldung.decoupling-pattern2</artifactId >
13+ <groupId >decoupling-pattern2</groupId >
14+ <version >1.0-SNAPSHOT</version >
15+ </parent >
16+
17+ <dependencies >
18+ <dependency >
19+ <groupId >com.baeldung.servicemodule</groupId >
20+ <artifactId >servicemodule</artifactId >
21+ <version >1.0</version >
22+ </dependency >
23+ </dependencies >
24+
25+ <build >
26+ <plugins >
27+ <plugin >
28+ <groupId >org.apache.maven.plugins</groupId >
29+ <artifactId >maven-compiler-plugin</artifactId >
30+ </plugin >
31+ </plugins >
32+ </build >
33+
34+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .providermodule ;
2+
3+ import com .baeldung .servicemodule .TextService ;
4+
5+ public class LowercaseTextService implements TextService {
6+ @ Override
7+ public String parseText (String text ) {
8+ return text .toLowerCase ();
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .providermodule {
2+ requires com .baeldung .servicemodule ;
3+ provides com .baeldung .servicemodule .TextService with com .baeldung .providermodule .LowercaseTextService ;
4+ }
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+ <parent >
7+ <artifactId >>com.baeldung.decoupling-pattern2</artifactId >
8+ <groupId >decoupling-pattern2</groupId >
9+ <version >1.0-SNAPSHOT</version >
10+ </parent >
11+
12+ <groupId >com.baeldung.servicemodule</groupId >
13+ <artifactId >servicemodule</artifactId >
14+ <version >1.0</version >
15+
16+ <build >
17+ <plugins >
18+ <plugin >
19+ <groupId >org.apache.maven.plugins</groupId >
20+ <artifactId >maven-compiler-plugin</artifactId >
21+ </plugin >
22+ </plugins >
23+ </build >
24+
25+ </project >
Original file line number Diff line number Diff line change 1+ package com .baeldung .servicemodule ;
2+
3+ public interface TextService {
4+
5+ String parseText (String text );
6+ }
Original file line number Diff line number Diff line change 1+ module com .baeldung .servicemodule {
2+ exports com .baeldung .servicemodule ;
3+ }
You can’t perform that action at this time.
0 commit comments