Workflow Engine
The Imixs JEE Workflow provides a set of JEE specific plugins which implement container typical functions. In general you can use all standard plugins as described in the Imixs Workflow API.
Please note that there is no need to use a JEE plugin if the plugin make not use of JEE specific api.
Most JEE Plugins extend the Abstract JEE Plugin which provides a general function set to be used by specific plugins. If you like to implement you own JEE Workflow Plugin it is a good starting point to subclass the class
org.imixs.workflow.jee.plugins.AbstractPlugin
This abstract class implements a basic set of functions for implementing plugins with interfaces to JEE API. All JEE plugins should extend these abstract plugin class.
The plugin provides the following methods:
returns the current user name of the caller principal from the JEE session object.
Replaces joker values inside a given string
UNIQUEID/ will be replaced with the $uniqueid
FIELDxxx/FIELD will be replaced with the value of a field inside the workitem.
Implementing a Imixs Workflow Plugin is an easy way to extend the behivor of a WorklfowManagement System. A Plugin is a simple Java Class (POJO). This makes it easy to implement a new Plugin Class. But you can not make use of the injection Feature from EJB 3.0 because the Plugin Class is typical not part of the Servlet Context nor its an Session EJB. This is the reason why it not possible to inject an Session EJB with an annotation like it is typical used in EJB 3.0:
@EJB
org.imixs.workflow.jee.ejb.EntityService entityService;
To get a reference to a existing EJB in Plugin Class it is necessary to do a JNDI Lookup. The JNDI Lookup feches the EJB from the EJB Container provided by the JEE Appliction Server. So this is the typical way to get an EJB Instance inside a POJO Class. In Imixs Worklfow Plugin you can overwrite teh init() method do get a reference to an EJB:
public void init(WorkflowContext actx) throws Exception {
super.init(actx);
String jndiName="java:comp/env/ejb/EntityService";
InitialContext ictx = new InitialContext();
Context ctx = (Context) ictx.lookup("java:comp/env");
jndiName="ejb/EntityServiceBean";
entityService= (org.imixs.workflow.jee.ejb.EntityService)ctx.lookup(jndiName);
}
In this case a reference to the EntityService Interface was created by JNDI Lookup. The Lookup feches an EJB Reference with the name "ejb/EntityServiceBean". To get this Interface returned from the JNDI Context you need to add this reference to the WorkflowManager EJB which is calling the Plugin. So you need to extend the ejb definition of the WorkflowServiceBean in the ejb-jar.xml file:
<session>
<ejb-name>WorkflowServiceBean</ejb-name>
<ejb-class>org.imixs.workflow.jee.ejb.WorkflowServiceBean</ejb-class>
<session-type>Stateless</session-type>
<ejb-ref>
<ejb-ref-name>ejb/EntityServiceBean</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<remote>org.imixs.workflow.jee.ejb.EntityService</remote>
</ejb-ref>
</session>