Developing Apama Applications > Writing Correlator Plug-ins > Writing Correlator Plug-ins in Java > Sample plug-ins in Java > A simple plug-in in Java
A simple plug-in in Java
The simple plug-in sample is comparable to the similar C and C++ simple plug-in samples.
The Java code for the simple_plugin class contains the public static test method. (Methods that will be called from EPL code need to be public and static.)
public class SimplePlugin
{
public static final String TEST_STRING = "Hello, World";
public static String test(String arg)
{
System.out.println("SimplePlugin function test called");
System.out.println("arg = "+arg);
System.out.println("return value = "+TEST_STRING);
return TEST_STRING;
}
}
The deployment descriptor file contains the following <plugin> stanza that illustrates how to specify the plug-in.
<application-classes>
<plugin>
<plugin-name>SimplePlugin</plugin-name>
<plugin-class>SimplePlugin</plugin-class>
<description>A test plugin</description>
</plugin>
</application-classes>
The EPL code imports the plug-in and calls the test method.
monitor SimplePluginTest {
// Load the plugin
import "SimplePlugin" as simple;

// To hold the return value
string ret;
string arg;

action onload {
// Call plugin function
arg := "Hello, Simple Plugin";
ret := simple.test(arg);

// Print out return value
log "simple.test = " + ret at INFO;
log "arg = " + arg at INFO;
}
}
Copyright © Software AG, Darmstadt, Germany and/or Software AG USA Inc., Reston, VA, USA, and/or its Subsidiaries and or/its Affiliates and/or their licensors.
Use, reproduction, transfer, publication or disclosure is prohibited except as specifically provided for in your License Agreement with Software AG.