View Source

As EasyVIPER is an extensible engine, it provides a way to implement new behaviours, in addition of the existing ones.
To create a new behaviour, you have to extend the {{com.ebmwebsourcing.easyviper.core.service.extended.behaviour.api.ExtendedBehaviour}} interface.
A good way to process is to perform the following steps:
* Create an interface that extends the {{ExtendedBehaviour}} interface:

{code:title=MyBehaviour.java|borderStyle=solid}
import com.ebmwebsourcing.easyviper.core.service.extended.behaviour.api.ExtendedBehaviour;

public interface MyBehaviour extends ExtendedBehaviour {

QName name = new QName(ExtendedBehaviour.name.getNamespaceURI(), "MyBehaviour");
}
{code}

* Create an implementation that implements this interface and extends the utility abstract class {{AbstractExtendedBehaviourImpl}}:

{code:title=MyBehaviourImpl.java|borderStyle=solid}
...
import com.ebmwebsourcing.easyviper.core.service.extended.behaviour.api.AbstractExtendedBehaviourImpl;
import mypackage.MyBehaviour;
import com.ebmwebsourcing.easycommons.sca.helper.api.SCAException;
import com.ebmwebsourcing.easyviper.core.api.CoreException;
import com.ebmwebsourcing.easyviper.core.api.engine.Node;
...

@Scope("COMPOSITE")
@Service(value=MyBehaviour.class,names="service")
@PolicySets("frascati:scaEasyPrimitive")
public class MyBehaviourImpl extends AbstractExtendedBehaviourImpl implements MyBehaviour {

@Reference(name="node",required=false)
protected Node node;

@Override
protected void executeOnInactive() throws CoreException {
// Some specific stuff

}

@Override
protected void executeOnStarted() throws CoreException {
// Some specific stuff

}

@Override
protected void executeOnEnded() throws CoreException {
// Some specific stuff

}
}
{code}

The main method to fill is {{executeOnInactive()}}. It is the one that will be executed when the execution token crosses over the behaviour.