Creating a plug-in using Java
To create a Java class to use as a correlator plug-in:
1. In the Java class used as a plug-in, you need to have one or more public static methods that match the permitted signatures, which are described in Permitted signatures for methods. All calls from an Apama application will be made to these static methods from all contexts.
As the plug-in author you are responsible for any concurrency concerns.
2. Correlator plug-ins in Java are deployed using an Apama Java application and are packaged in a jar file. You need to create an Apama Java deployment descriptor file in the application's META-INF/jmon-jar.xml file. For the plug-in you need to add a <plugin> to the <application-classes> element.
For more information on Apama deployment descriptor files, see
Creating deployment descriptor files in
Developing Apama Applications in Java.
An example plug-in stanza looks like this:
<plugin>
<plugin-name>TestPlugin</plugin-name>
<plugin-class>test.TestPlugin</plugin-class>
<description>A test plugin</description>
</plugin>
plugin-name defines the name visible to EPL.
plugin-class indicates the class to load from the jar for this plugin.
description is a simple textual description that appears in log messages.
Instead of writing a deployment descriptor file manually, if you are using Apama Studio to create the plug-in you can annotate the plug-in class and have Studio automatically generate the descriptor file. Here is an example annotation:
@com.apama.epl.plugin.annotation.EPLPlugin(name="TestPlugin",
description="A test plugin")
class testplugin
{
...
}
3. Create a jar file for deploying the plug-in and add the Java class file and the deployment descriptor file META-INF/jmon-jar.xml to it. In Apama Studio when you create an Apama Java application, this is done automatically.
For applications that you plan to inject into a correlator, the recommendation is to create separate jar files for:
Java correlator plugins
Applications that use Apama’s in-process Java API
Although the mechanism for creating these jars and describing their meta-data is similar, the interactions of these two different uses of injected jars mean that they will often need to be injected into the correlator separately. The creation of separate jar files ensures that you can inject your application components in the correct order, which is typically:
1. Java correlator plugins
2. EPL monitors and events
3. Applications that use Apama’s in-process Java API
Copyright © 2013
Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or Terracotta Inc., San Francisco, CA, USA, and/or Software AG (Canada) Inc., Cambridge, Ontario, Canada, and/or, Software AG (UK) Ltd., Derby, United Kingdom, and/or Software A.G. (Israel) Ltd., Or-Yehuda, Israel and/or their licensors.