alright Al,
I think what you want to do is this:
import org.jbpm.api.Configuration;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;
import org.jbpm.api.task.Task;
import org.jbpm.pvm.internal.cmd.CommandService;
import org.jbpm.pvm.internal.cmd.GetTaskCmd;
import org.jbpm.pvm.internal.env.EnvironmentImpl;
import org.jbpm.pvm.internal.processengine.ProcessEngineImpl;
public class Start {
private static volatile ProcessEngineImpl engine;
public static void main(final String[] args) {
engine = (ProcessEngineImpl) new Configuration().setResource("jbpm4.jvm.cfg.xml").buildProcessEngine();
System.out.println("instanciated Engine in main: " + engine);
new Start().doSomeStuff();
}
private void doSomeStuff() {
try {
EnvironmentImpl environment = engine.openEnvironment();
System.out.println("environment is: " + environment);
RepositoryService repositoryService = EnvironmentImpl.getFromCurrent(RepositoryService.class);
System.out.println("RepositoryService is : " + repositoryService);
long pdCount = repositoryService.createProcessDefinitionQuery().count();
System.out.println("pdcount is: " + pdCount);
CommandService commandService = EnvironmentImpl.getFromCurrent(CommandService.class);
System.out.println("commandService is : " + commandService);
Task task = commandService.execute(new GetTaskCmd("4711"));
System.out.println("task 4711 is : " + task);
} finally {
engine.close();
}
}
}
jbpm4.jvm.cfg.xml example file:
<?xml version="1.0" encoding="UTF-8"?>
<jbpm-configuration>
<process-engine-context>
<task-service />
<repository-service />
<command-service />
<command-service name="txRequiredCommandService">
<skip-interceptor />
<retry-interceptor />
<environment-interceptor />
<standard-transaction-interceptor />
</command-service>
<command-service name="newTxRequiredCommandService">
<retry-interceptor />
<environment-interceptor policy="requiresNew" />
<standard-transaction-interceptor />
</command-service>
<hibernate-configuration annotations="enabled">
<properties resource="jbpm4.jvm.hibernate.properties" />
<cfg resource="hibernate3.cfg.xml" />
</hibernate-configuration>
<hibernate-session-factory />
</process-engine-context>
<transaction-context>
<repository-session />
<transaction />
<hibernate-session />
<db-session />
</transaction-context>
</jbpm-configuration>