Skip to content

Commit f8b0f25

Browse files
author
Mahdi
committed
Add first module 01-basic
1 parent f20ab43 commit f8b0f25

5 files changed

Lines changed: 79 additions & 41 deletions

File tree

01-basic/pom.xml

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?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"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

77
<parent>
88
<groupId>ir.moke</groupId>
9-
<artifactId>example_projects</artifactId>
9+
<artifactId>example-modules</artifactId>
1010
<version>1.0-SNAPSHOT</version>
1111
</parent>
1212

@@ -23,5 +23,43 @@
2323
<artifactId>slf4j-api</artifactId>
2424
</dependency>
2525
</dependencies>
26-
27-
</project>
26+
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-jar-plugin</artifactId>
32+
<version>2.3.1</version>
33+
<configuration>
34+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
35+
</configuration>
36+
</plugin>
37+
<plugin>
38+
<artifactId>maven-dependency-plugin</artifactId>
39+
<executions>
40+
<execution>
41+
<phase>install</phase>
42+
<goals>
43+
<goal>copy-dependencies</goal>
44+
</goals>
45+
<configuration>
46+
<outputDirectory>${project.build.directory}/lib</outputDirectory>
47+
</configuration>
48+
</execution>
49+
</executions>
50+
</plugin>
51+
<plugin>
52+
<groupId>ir.moke.jpkg</groupId>
53+
<artifactId>maven-jpkg</artifactId>
54+
<version>1.0</version>
55+
<configuration>
56+
<name>01-basic</name>
57+
<version>0.1</version>
58+
<description>This is very simple basic jos module</description>
59+
<maintainer>Mahdi Sheikh Hosseini</maintainer>
60+
</configuration>
61+
</plugin>
62+
</plugins>
63+
</build>
64+
65+
</project>

01-basic/src/main/java/com/sample/module/LogService.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@
33
import org.slf4j.Logger;
44
import org.slf4j.LoggerFactory;
55

6-
import java.util.concurrent.ExecutorService;
7-
86
public class LogService {
97
private static final Logger logger = LoggerFactory.getLogger(LogService.class);
108

11-
public static void generateLog(ExecutorService es) {
12-
while (!es.isShutdown()) {
13-
es.execute(LogService::sendInfoLog);
14-
es.execute(LogService::sendWarnLog);
15-
es.execute(LogService::sendDebugLog);
16-
es.execute(LogService::sendErrorLog);
17-
es.execute(LogService::sendTraceLog);
9+
public static void generateLog() {
10+
while (true) {
11+
sleep();
12+
sendInfoLog();
13+
sendWarnLog();
14+
sendDebugLog();
15+
sendErrorLog();
16+
sendTraceLog();
1817
}
1918
}
2019

@@ -37,4 +36,12 @@ public static void sendErrorLog() {
3736
public static void sendTraceLog() {
3837
logger.trace("This is trace log");
3938
}
39+
40+
public static void sleep() {
41+
try {
42+
Thread.sleep(1000);
43+
} catch (InterruptedException e) {
44+
throw new RuntimeException(e);
45+
}
46+
}
4047
}

01-basic/src/main/java/com/sample/module/ModuleRunner.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,15 @@
22

33
import ir.moke.jos.api.JModule;
44

5-
import java.util.concurrent.ExecutorService;
6-
import java.util.concurrent.Executors;
7-
85
public class ModuleRunner implements JModule {
9-
private static final ExecutorService es = Executors.newVirtualThreadPerTaskExecutor();
106

117
@Override
128
public void start() {
13-
LogService.generateLog(es);
9+
LogService.generateLog();
1410
}
1511

16-
/**
17-
* Always should stop threads when module stopped
18-
*/
1912
@Override
2013
public void stop() {
21-
es.shutdown();
14+
// In this module is not usable !
2215
}
2316
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module p01_basic {
2+
requires jos.api;
3+
requires org.slf4j;
4+
exports com.sample.module;
5+
provides ir.moke.jos.api.JModule with com.sample.module.ModuleRunner;
6+
}

pom.xml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,39 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>ir.moke</groupId>
7-
<artifactId>example_projects</artifactId>
7+
<artifactId>example-modules</artifactId>
88
<packaging>pom</packaging>
99
<version>1.0-SNAPSHOT</version>
10-
<name>example_projects</name>
10+
<name>example-modules</name>
1111

1212
<modules>
1313
<module>01-basic</module>
1414
</modules>
1515

1616
<dependencyManagement>
1717
<dependencies>
18+
<!-- JOS Api -->
1819
<dependency>
1920
<groupId>ir.moke.jos</groupId>
2021
<artifactId>jos-api</artifactId>
2122
<version>1.0</version>
2223
<scope>provided</scope>
2324
</dependency>
2425

25-
<!-- Google Gson -->
26-
<dependency>
27-
<groupId>com.google.code.gson</groupId>
28-
<artifactId>gson</artifactId>
29-
<version>2.10.1</version>
30-
</dependency>
31-
3226
<!-- Log -->
3327
<dependency>
3428
<groupId>org.slf4j</groupId>
3529
<artifactId>slf4j-api</artifactId>
3630
<version>2.0.13</version>
3731
<scope>provided</scope>
3832
</dependency>
33+
34+
<!-- Google Gson -->
35+
<dependency>
36+
<groupId>com.google.code.gson</groupId>
37+
<artifactId>gson</artifactId>
38+
<version>2.10.1</version>
39+
</dependency>
3940
</dependencies>
4041
</dependencyManagement>
4142

@@ -53,16 +54,9 @@
5354
<pluginManagement>
5455
<plugins>
5556
<plugin>
56-
<groupId>ir.moke.yaja</groupId>
57-
<artifactId>maven-yaja</artifactId>
57+
<groupId>ir.moke.jpkg</groupId>
58+
<artifactId>maven-jpkg</artifactId>
5859
<version>1.0</version>
59-
<executions>
60-
<execution>
61-
<goals>
62-
<goal>archive</goal>
63-
</goals>
64-
</execution>
65-
</executions>
6660
</plugin>
6761
</plugins>
6862
</pluginManagement>

0 commit comments

Comments
 (0)