diff --git a/plugins/quartz-scheduler/README.md b/plugins/quartz-scheduler/README.md new file mode 100644 index 0000000..1a3724c --- /dev/null +++ b/plugins/quartz-scheduler/README.md @@ -0,0 +1,5 @@ +### Quartz Scheduler + +---- + +A small plugin to interact with a remotely accessible [Quartz Scheduler](https://www.quartz-scheduler.org/). diff --git a/plugins/quartz-scheduler/pom.xml b/plugins/quartz-scheduler/pom.xml new file mode 100644 index 0000000..8eea803 --- /dev/null +++ b/plugins/quartz-scheduler/pom.xml @@ -0,0 +1,56 @@ + + 4.0.0 + eu.tneitzel + quartz-scheduler-rmg-plugin + 1.0.0 + + + UTF-8 + 1.8 + 1.8 + + + + + eu.tneitzel + remote-method-guesser + 5.1.0 + provided + + + + org.quartz-scheduler + quartz + 2.3.2 + + + + + + + maven-assembly-plugin + + + package + + single + + + + + ${project.artifactId}-${project.version} + + + Tobias Neitzel (@qtc_de) + eu.tneitzel.rmg.plugin.Template + + + + jar-with-dependencies + + + + + + + diff --git a/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Dispatcher.java b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Dispatcher.java new file mode 100644 index 0000000..e53fbe0 --- /dev/null +++ b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Dispatcher.java @@ -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); + } +} diff --git a/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Helpers.java b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Helpers.java new file mode 100644 index 0000000..4c490d1 --- /dev/null +++ b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Helpers.java @@ -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.getValue()); + + scheduler = client.createProxy(RemotableQuartzScheduler.class); + } + + return scheduler; + } +} diff --git a/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/QuartzAction.java b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/QuartzAction.java new file mode 100644 index 0000000..7919123 --- /dev/null +++ b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/QuartzAction.java @@ -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; + } + +} diff --git a/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Template.java b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Template.java new file mode 100644 index 0000000..a66f391 --- /dev/null +++ b/plugins/quartz-scheduler/src/main/java/eu/tneitzel/rmg/plugin/Template.java @@ -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(); + } + } +}