Developing Apama Applications > Writing Correlator Plug-ins > Writing Correlator Plug-ins in Java > Sample plug-ins in Java > A simple plug-in
A simple plug-in
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 simple_plugin
{
public static final String TEST_STRING = "Hello, World";
public static String test(String arg)
{
System.out.println("simple_plugin 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>simple_plugin</plugin-name>
<plugin-class>simple_plugin</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 "simple_plugin" 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 © 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.