Implement two classes:
The minimal plugin class can be implemented as:
package com.alpha.pineapple.plugin.helloworld;
import com.alpha.pineapple.plugin.Plugin;
@Plugin()
public class PluginImpl {}
The plugin only support a single operation, "hello-world" which greets the world. The minimal plugin class can be implement as:
package com.alpha.pineapple.plugin.helloworld;
import com.alpha.pineapple.plugin.Operation;
import com.alpha.pineapple.plugin.PluginOperation;
import com.alpha.pineapple.session.Session;
@PluginOperation("hello-world")
public class HelloWorldOperation implements Operation {
public void execute(Object content, Session session, ExecutionResult result) {
System.out.println("Hello world");
}
The pineapple-test-utils project contains an extended hello-world plugin. The plugin is located in the package com.alpha.pineapple.plugin.helloworld and is indented to be used for testing purposes.
The plugin is minimal, just a simple POJO with a single @Plugin annotation.
package com.alpha.pineapple.plugin.helloworld;
import com.alpha.pineapple.plugin.Plugin;
@Plugin()
public class PluginImpl {}
The plugin only support a single operation, "hello-world" which greets the world. The class is implemented as:
/**
* Simple hello world operation.
*/
@PluginOperation(TestUtilsTestConstants.helloWorldOperation)
public class HelloWorldOperationImpl implements Operation
{
/**
* Logger object.
*/
Logger logger = Logger.getLogger( this.getClass().getName() );
public void execute( Object content, Session session, ExecutionResult result ) throws PluginExecutionFailedException
{
// log debug message
if (logger.isDebugEnabled()) {
StringBuilder message = new StringBuilder();
message.append( "Operation invoked with content <" );
message.append( content.toString() );
message.append( "> and session <" );
message.append( session.toString() );
message.append( ">." );
logger.debug( message.toString() );
}
}
}
The operation class extends the initial example with these trivial points: