Skip to content

Commit

Permalink
Add skeleton for quartz-scheduler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
qtc-de committed Jan 21, 2024
1 parent 0abe94c commit c0905d4
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 0 deletions.
5 changes: 5 additions & 0 deletions plugins/quartz-scheduler/README.md
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/).
56 changes: 56 additions & 0 deletions plugins/quartz-scheduler/pom.xml
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>
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);
}
}
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;
}
}
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;
}

}
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();
}
}
}

0 comments on commit c0905d4

Please sign in to comment.