Hi all,
I've modified Sarasvati for working with JBoss 7.
To achieve this result you have to patch some sources ( see attachment src.diff, apply to src directory ), change hibernate libraries ( use the one from JBoss modules directory ) in lib:
hibernate-commons-annotations-4.0.1.Final.jar
hibernate-core-4.0.1.Final.jar
hibernate-entitymanager-4.0.1.Final.jar
hibernate-infinispan-4.0.1.Final.jar
hibernate-jpa-2.0-api-1.0.1.Final.jar
and then recompile ( ant dist ).
Use the resulting library for creating Jboss 7 module:
- create a directory $JBOSS_HOME/modules/com/googlecode/sarasvati/main
- use the module.xml in the attachment and add libraries from lib directory as described in the module.xml
Now you are ready to create you EJB project:
Prepare a persistence.xml and jbpm-deployment-structure.xml as the one in the attachment ( provide your own datasource ).
Use sarasvati as in the following example:
-- Don't worry about schema update ( JPA will update the schema ).
package biz.opengate.testsarasvati;
import java.io.File;
import javax.annotation.PostConstruct;
import javax.ejb.LocalBean;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.hibernate.Session;
import com.googlecode.sarasvati.Graph;
import com.googlecode.sarasvati.GraphProcess;
import com.googlecode.sarasvati.hib.HibEngine;
/**
* Session Bean implementation class Mai
*/
@Singleton
@LocalBean
@Startup
public class Main {
@PersistenceContext(unitName = "TestSarasvati")
private EntityManager em;
/**
* Default constructor.
*/
public Main() {
// TODO Auto-generated constructor stub
}
@PostConstruct
public void postConstruct() {
HibEngine engine = new HibEngine(em.unwrap(Session.class));
File file = new File(this.getClass().getResource("helloworld.wf.xml").getFile());
engine.getLoader().load( file );
Graph graph = engine.getRepository().getLatestGraph( "hello-world" );
GraphProcess process = engine.startProcess( graph );
}
}