-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skeleton for quartz-scheduler plugin
- Loading branch information
Showing
6 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
### Quartz Scheduler | ||
|
||
---- | ||
|
||
A small plugin to interact with a remotely accessible [Quartz Scheduler](https://www.quartz-scheduler.org/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>eu.tneitzel</groupId> | ||
<artifactId>quartz-scheduler-rmg-plugin</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>eu.tneitzel</groupId> | ||
<artifactId>remote-method-guesser</artifactId> | ||
<version>5.1.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.quartz-scheduler</groupId> | ||
<artifactId>quartz</artifactId> | ||
<version>2.3.2</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<finalName>${project.artifactId}-${project.version}</finalName> | ||
<archive> | ||
<manifestEntries> | ||
<Built-By>Tobias Neitzel (@qtc_de)</Built-By> | ||
<RmgPluginClass>eu.tneitzel.rmg.plugin.Template</RmgPluginClass> | ||
</manifestEntries> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
18 changes: 18 additions & 0 deletions
18
plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Dispatcher.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package eu.tneitzel.rmg.plugin; | ||
|
||
import java.rmi.RemoteException; | ||
|
||
import org.quartz.core.RemotableQuartzScheduler; | ||
|
||
import eu.tneitzel.rmg.io.Logger; | ||
|
||
public class Dispatcher | ||
{ | ||
public static void dispatchVersion() throws RemoteException | ||
{ | ||
RemotableQuartzScheduler scheduler = Helpers.getScheduler(); | ||
String version = scheduler.getVersion(); | ||
|
||
Logger.printlnMixedYellow("Remote Quartz Scheduler version:", version); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Helpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package eu.tneitzel.rmg.plugin; | ||
|
||
import org.quartz.core.RemotableQuartzScheduler; | ||
|
||
import eu.tneitzel.rmg.internal.RMGOption; | ||
import eu.tneitzel.rmg.io.Logger; | ||
import eu.tneitzel.rmg.networking.RMIRegistryEndpoint; | ||
import eu.tneitzel.rmg.operations.RemoteObjectClient; | ||
import eu.tneitzel.rmg.utils.RMGUtils; | ||
|
||
public class Helpers | ||
{ | ||
private static RemotableQuartzScheduler scheduler = null; | ||
|
||
public static RemotableQuartzScheduler getScheduler() | ||
{ | ||
if (scheduler == null) | ||
{ | ||
if (RMGOption.TARGET_BOUND_NAME.isNull()) | ||
{ | ||
Logger.printlnMixedYellow("The", "--bound-name", "option is required for all quartz actions."); | ||
RMGUtils.exit(); | ||
} | ||
|
||
String host = RMGOption.TARGET_HOST.getValue(); | ||
int port = RMGOption.TARGET_PORT.getValue(); | ||
|
||
RMIRegistryEndpoint endpoint = new RMIRegistryEndpoint(host, port); | ||
RemoteObjectClient client = new RemoteObjectClient(endpoint, RMGOption.TARGET_BOUND_NAME.<String>getValue()); | ||
|
||
scheduler = client.createProxy(RemotableQuartzScheduler.class); | ||
} | ||
|
||
return scheduler; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/QuartzAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package eu.tneitzel.rmg.plugin; | ||
|
||
import eu.tneitzel.argparse4j.global.IAction; | ||
import eu.tneitzel.argparse4j.global.IOption; | ||
import eu.tneitzel.rmg.internal.RMGOption; | ||
|
||
public enum QuartzAction implements IAction | ||
{ | ||
VERSION("version", "get the version of the remote scheduler", new IOption[] { | ||
RMGOption.TARGET_HOST, | ||
RMGOption.TARGET_PORT, | ||
RMGOption.TARGET_BOUND_NAME, | ||
}); | ||
|
||
private final String name; | ||
private final String desc; | ||
private final IOption[] options; | ||
|
||
QuartzAction(String name, String desc, IOption[] options) | ||
{ | ||
this.name = name; | ||
this.desc = desc; | ||
this.options = options; | ||
} | ||
|
||
@Override | ||
public String getName() | ||
{ | ||
return name; | ||
} | ||
|
||
@Override | ||
public String getDescription() | ||
{ | ||
return desc; | ||
} | ||
|
||
@Override | ||
public IOption[] getOptions() | ||
{ | ||
return options; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Template.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package eu.tneitzel.rmg.plugin; | ||
|
||
import eu.tneitzel.argparse4j.global.IAction; | ||
import java.rmi.RemoteException; | ||
|
||
/** | ||
* The Template class represents a template to develop remote-method-guesser plugins. | ||
* It implements all the available plugin interfaces, but only uses placeholder implementations. | ||
* If you want to build a plugin from it, remove the interfaces and methods that you do not | ||
* intend to use. Other methods need to be overwritten with actual useful implementations. | ||
* | ||
* When changing the class name, make sure to also change the RmgPluginClass entry within the | ||
* pom.xml file. | ||
*/ | ||
public class Template implements IActionProvider | ||
{ | ||
@Override | ||
public IAction[] getActions() | ||
{ | ||
return QuartzAction.values(); | ||
} | ||
|
||
@Override | ||
public void dispatch(IAction action) | ||
{ | ||
try | ||
{ | ||
if (action == QuartzAction.VERSION) | ||
{ | ||
Dispatcher.dispatchVersion(); | ||
} | ||
} | ||
|
||
catch (RemoteException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |