Skip to content

Commit

Permalink
testing modules
Browse files Browse the repository at this point in the history
  • Loading branch information
verhas committed Dec 14, 2017
0 parents commit d0edad7
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitignore
@@ -0,0 +1,29 @@
# Created by .ignore support plugin (hsz.mobi)
### Java template
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/ServiceInterface/jscriptbasic-integrationTest.iml
/moduleTest.iml
*.iml
.idea/
target
34 changes: 34 additions & 0 deletions Consumer/pom.xml
@@ -0,0 +1,34 @@
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>javax0</groupId>
<artifactId>Consumer</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>javax0</groupId>
<artifactId>ServiceInterface</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax0</groupId>
<artifactId>Provider</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency> </dependencies>
</project>
16 changes: 16 additions & 0 deletions Consumer/src/main/java/javax0/serviceconsumer/Consumer.java
@@ -0,0 +1,16 @@
package javax0.serviceconsumer;

import javax0.serviceinterface.ServiceInterface;

import java.util.ServiceLoader;

public class Consumer {

public static void main(String[] args) {
ServiceLoader<ServiceInterface> loader = ServiceLoader.load(ServiceInterface.class);
for (final ServiceInterface service : loader) {
System.out.println("The service " + service.getClass().getSimpleName() + " answers " + service.theAnswer());
}
}

}
4 changes: 4 additions & 0 deletions Consumer/src/main/java/module-info.java
@@ -0,0 +1,4 @@
module Consumer {
requires ServiceInterface;
uses javax0.serviceinterface.ServiceInterface;
}
30 changes: 30 additions & 0 deletions Provider/pom.xml
@@ -0,0 +1,30 @@
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>javax0</groupId>
<artifactId>Provider</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>javax0</groupId>
<artifactId>ServiceInterface</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
10 changes: 10 additions & 0 deletions Provider/src/main/java/javax0/serviceprovider/Provider.java
@@ -0,0 +1,10 @@
package javax0.serviceprovider;

import javax0.serviceinterface.ServiceInterface;

public class Provider implements ServiceInterface {
@Override
public int theAnswer() {
return 42;
}
}
5 changes: 5 additions & 0 deletions Provider/src/main/java/module-info.java
@@ -0,0 +1,5 @@
module Provider {
requires ServiceInterface;
exports javax0.serviceprovider;
provides javax0.serviceinterface.ServiceInterface with javax0.serviceprovider.Provider;
}
23 changes: 23 additions & 0 deletions ServiceInterface/pom.xml
@@ -0,0 +1,23 @@
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>javax0</groupId>
<artifactId>ServiceInterface</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
@@ -0,0 +1,7 @@
package javax0.serviceinterface;

public interface ServiceInterface {

int theAnswer();

}
3 changes: 3 additions & 0 deletions ServiceInterface/src/main/java/module-info.java
@@ -0,0 +1,3 @@
module ServiceInterface {
exports javax0.serviceinterface;
}
41 changes: 41 additions & 0 deletions pom.xml
@@ -0,0 +1,41 @@
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>javax0</groupId>
<artifactId>moduleTest</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>ServiceInterface</module>
<module>Provider</module>
<module>Consumer</module>
</modules>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.9</source>
<target>1.9</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

0 comments on commit d0edad7

Please sign in to comment.