
As EasyBPEL is based on EasyVIPER, an extended behavior is expected to be developed for each extended activity in EasyBPEL.
First we consider an extended behavior is available (see the specific [how-to|easyviper:How to implement an extended behaviour in EasyVIPER?] on EasyVIPER page).
The following figure shows this principle of EasyBPEL activity mapped into an EasyVIPER behaviour. For the *Invoke* activity defined in the BPEL specification, a corresponding *Send* behavior has been implemented in EasyVIPER. In a same way, any extended activity defined at EasyBPEL level corresponds to an extended behavior at EasyVIPER level.
!extended_activity.gif|border=1,width=600!
First of all, an XSD schema must be created, corresponding to the extended activity. In particular, you must create a type that extends the Extended activity type defined in the BPEL 2.0 specification.
{code:xml|title=Excerpt of the extended activity schema.|borderStyle=solid}
<xsd:complexType name="tMyExtendedActivity">
<xsd:complexContent>
<xsd:extension base="bpel:tExtentedActivity">
<xsd:sequence>
<xsd:element ref="tns:myExtendedActivityElement" />
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="myExtendedActivityElement" type="..." />
{code}
This schema must be able to generate Java source code. The following excerpt is a way to do that thanks to a maven plugin:
{code:xml}
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<schemaDirectory>
${basedir}/src/main/resources
</schemaDirectory>
<schemaIncludes>
<include>MyExtendedActivity.xsd</include>
</schemaIncludes>
<bindingIncludes>
<include>binding.xjb</include>
</bindingIncludes>
</configuration>
</plugin>
{code}
Here is an example of binding.xjb:
{code:xml|title=binding.xjb|borderStyle=solid}
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<jaxb:bindings schemaLocation="InvokeAddressingActivity.xsd"
node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="mypackage.myextendedactivity..." />
</jaxb:schemaBindings>
</jaxb:bindings>
<jaxb:bindings schemaLocation="schema/bpel/2_0/ws-bpel_executable.xsd"
node="/xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.ebmwebsourcing.easybpel.model.bpel.executable" />
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
{code}
An extended activity implementation must then be composed of a JAVA interface extending the {{ExtendedActivity}} interface:
{code:title=MyExtendedActivity.java|borderStyle=solid}
import com.ebmwebsourcing.easybpel.model.bpel.api.activity.extension.ExtendedActivity;
public interface MyExtendedActivity extends ExtendedActivity {
//Some specific stuff related to MyExtendedActivity
}
{code}
An abstract class should be created, extending the {{AbstractExtendedActivityImpl}} abstract class and implementing the interface above.
Here is an example:
{code:title=AbstractExtendedActivityImpl.java|borderStyle=solid}
...
import com.ebmwebsourcing.easybpel.model.bpel.api.activity.extension.AbstractExtendedActivityImpl;
import com.ebmwebsourcing.easybpel.model.bpel.api.activity.extension.ExtensionActivity;
import com.ebmwebsourcing.easybpel.model.bpel.api.containers.SourcesImpl;
import com.ebmwebsourcing.easybpel.model.bpel.api.containers.TargetsImpl;
import com.ebmwebsourcing.easybpel.model.bpel.executable.TCondition;
import com.ebmwebsourcing.easybpel.model.bpel.executable.TSources;
import com.ebmwebsourcing.easybpel.model.bpel.executable.TTargets;
...
public abstract class MyExtendedActivityPackageExtendedActivityImpl<E extends TExtentedActivity> extends AbstractExtendedActivityImpl<E> implements MyExtendedActivity {
public MyExtendedActivityPackageExtendedActivityImpl(final QName name, final E model, final ExtensionActivity parent) throws BPELException {
super(name, model, parent);
copySourcesAndTargets(model);
}
public MyExtendedActivityPackageExtendedActivityImpl(QName tag, Element elmt,
ExtensionActivity parent) throws BPELException {
super(tag, elmt, parent);
copySourcesAndTargets(model);
}
private void copySourcesAndTargets(final E model) {
if(model != null) {
if(this.model.getSources() != null) {
TSources sources = new TSources();
sources.getOtherAttributes().putAll(this.model.getSources().getOtherAttributes());
sources.getSource().addAll((List)this.model.getSources().getSource());
sources.getAny().addAll(this.model.getSources().getAny());
this.sources = new SourcesImpl(sources, this);
}
if(this.model.getTargets() != null) {
TTargets targets = new TTargets();
targets.getOtherAttributes().putAll(this.model.getTargets().getOtherAttributes());
targets.getTarget().addAll((List)this.model.getTargets().getTarget());
targets.getAny().addAll(this.model.getTargets().getAny());
TCondition condition = new TCondition();
condition.getContent().addAll(this.model.getTargets().getJoinCondition().getContent());
condition.setExpressionLanguage(this.model.getTargets().getJoinCondition().getExpressionLanguage());
condition.getOtherAttributes().putAll(this.model.getTargets().getJoinCondition().getOtherAttributes());
targets.setJoinCondition(condition);
this.targets = new TargetsImpl(targets, this);
}
}
}
public boolean getSuppressJoinFailure() {
return Boolean.valueOf(this.model.getSuppressJoinFailure().value());
}
public String getName() {
return this.model.getName();
}
public void setName(String name) {
this.model.setName(name);
}
public void loadJaxbContext() throws BPELException {
try {
List<Class> list = new ArrayList<Class>();
list.add(mypackage.ObjectFactory.class);
SchemaJAXBContext.getInstance().addOtherObjectFactory(list);
this.jaxbContext = SchemaJAXBContext.getInstance().getJaxbContext();
} catch (final SchemaException e) {
throw new BPELException(e);
}