Skip to content

Commit a94e708

Browse files
author
Dev-Bjorn
committed
V1.0.0: Initial Commit
0 parents  commit a94e708

36 files changed

+4355
-0
lines changed

.gitignore

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2023 Devoxist, Dev-Bjorn
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Module Scheduler
2+
3+
[![Maven Central](https://img.shields.io/maven-central/v/nl.devoxist/module-scheduler.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22nl.devoxist%22%20AND%20a:%22module-scheduler%22)
4+
[![GitHub license](https://img.shields.io/github/license/Devoxist/module-scheduler)](https://github.com/Devoxist/module-scheduler/blob/master/LICENSE)
5+
6+
### Getting Started
7+
8+
How to install this API? For all possible options to install this API [maven
9+
central](https://search.maven.org/artifact/nl.devoxist/module-scheduler) and select the version.
10+
11+
#### Maven
12+
13+
Add this to your `pom.xml`.
14+
15+
```xml
16+
17+
<dependency>
18+
<groupId>nl.devoxist</groupId>
19+
<artifactId>module-scheduler</artifactId>
20+
<version>1.0.0</version>
21+
</dependency>
22+
```
23+
24+
### Usage
25+
26+
This API can be used to automatically order tasks/modules in the correct order.
27+
28+
### How to use this API?
29+
30+
Firstly create as class that implements `ModuleScheduler`. This is the controller of all the modules.
31+
32+
```java
33+
public class ModuleSchedulerProcess implements ModuleScheduler {
34+
35+
@Override
36+
public void updateSettings(@NotNull ModuleSchedulerSettings settings) {
37+
}
38+
39+
40+
@Override
41+
public void beforeModuleExecute(Module module) {
42+
// Put here your stuff
43+
}
44+
45+
@Override
46+
public void afterModuleExecute(Module module) {
47+
// Put here your stuff
48+
}
49+
}
50+
```
51+
52+
Then you want to add some modules to the controllers. The modules can be created by implementing `Module`.
53+
54+
```java
55+
public class ModuleA implements Module {
56+
57+
@Override
58+
public void onExecute() {
59+
// Put here your stuff
60+
}
61+
}
62+
```
63+
64+
To mark a dependency link to another module use the `@Dependency` annotation above the class of the `Module`. This
65+
annotation is needed to order the Modules.
66+
67+
```java
68+
69+
@Dependency(ModuleA.class)
70+
public class ModuleB implements Module {
71+
72+
public ModuleB(ModuleA moduleA) {
73+
// Put here your stuff
74+
}
75+
76+
77+
@Override
78+
public void onExecute() {
79+
// Put here your stuff
80+
}
81+
}
82+
```
83+
84+
To mark a multiple dependency links to another module use the `@Dependency` annotation above the class of the `Module`.
85+
This annotation is needed to order the Modules.
86+
87+
```java
88+
89+
@Dependency({ModuleB.class, ModuleA.class})
90+
public class ModuleC implements Module {
91+
92+
public ModuleC(ModuleA moduleA, ModuleB moduleB) {
93+
// Put here your stuff
94+
}
95+
96+
@Override
97+
public void onExecute() {
98+
// Put here your stuff
99+
}
100+
}
101+
```
102+
103+
How to add modules to the controller, the scheduler? This can be done to change the content of the
104+
method, `ModuleScheduler#updateSettings`. Add a line with `ModuleSchedulerSettings#addModule`. It is important to add
105+
all the tasks/modules that need to be loaded. Only the modules that are added can be loaded.
106+
107+
```java
108+
@Override
109+
public void updateSettings(@NotNull ModuleSchedulerSettings settings){
110+
settings.addModule(ModuleA.class);
111+
settings.addModule(ModuleB.class);
112+
settings.addModule(ModuleC.class);
113+
}
114+
```
115+
116+
How to start the process? Construct the `Scheduler` class with the inherited `ModuleScheduler` that you want to load.
117+
After calling this construction the modules will automatically be runned in correct order. These methods will run, when
118+
a module is being executed, in the following
119+
order `ModuleScheduler#beforeModuleExecute` -> `Module#onExecute` -> `ModuleScheduler#afterModuleExecute`.
120+
121+
```java
122+
new Scheduler(new ModuleSchedulerProcess());
123+
```
124+
125+
126+
### Contributors
127+
128+
+ Dev-Bjorn

example/example1/ModuleA.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package modules;
2+
3+
import nl.devoxist.modulescheduler.Module;
4+
5+
public class ModuleA implements Module {
6+
7+
8+
@Override
9+
public void onExecute() {
10+
// Put here your stuff
11+
}
12+
}

example/example1/ModuleB.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2023 Devoxist, Dev-Bjorn
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package modules;
24+
25+
import nl.devoxist.modulescheduler.Module;
26+
import nl.devoxist.modulescheduler.annotation.Dependency;
27+
28+
@Dependency(ModuleA.class)
29+
public class ModuleB implements Module {
30+
31+
public ModuleB(ModuleA moduleA) {
32+
// Put here your stuff
33+
}
34+
35+
36+
@Override
37+
public void onExecute() {
38+
// Put here your stuff
39+
}
40+
}

example/example1/ModuleC.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2023 Devoxist, Dev-Bjorn
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in all
12+
* copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*/
22+
23+
package modules;
24+
25+
import nl.devoxist.modulescheduler.Module;
26+
import nl.devoxist.modulescheduler.annotation.Dependency;
27+
28+
@Dependency({ModuleB.class, ModuleA.class})
29+
public class ModuleC implements Module {
30+
31+
public ModuleC(ModuleA moduleA, ModuleB moduleB) {
32+
// Put here your stuff
33+
}
34+
35+
@Override
36+
public void onExecute() {
37+
// Put here your stuff
38+
}
39+
}

0 commit comments

Comments
 (0)