From 1096fed2d4c0d564de2b82c6a55b3b10ad6f31e9 Mon Sep 17 00:00:00 2001 From: Cristiano Nicolai Date: Fri, 11 Feb 2011 10:41:32 +1000 Subject: [PATCH 2/2] Refactoring on jbpm-gwt-console-server to use only JPA --- .../jbpm/integration/console/CommandDelegate.java | 19 ++++------ .../console/graph/GraphViewerPluginImpl.java | 7 ++-- .../src/main/resources/META-INF/hibernate.cfg.xml | 39 -------------------- 3 files changed, 12 insertions(+), 53 deletions(-) delete mode 100644 jbpm-gwt/jbpm-gwt-server-war/src/main/resources/META-INF/hibernate.cfg.xml diff --git a/jbpm-gwt/jbpm-gwt-console/src/main/java/org/jbpm/integration/console/CommandDelegate.java b/jbpm-gwt/jbpm-gwt-console/src/main/java/org/jbpm/integration/console/CommandDelegate.java index 839a1be..d149fd5 100644 --- a/jbpm-gwt/jbpm-gwt-console/src/main/java/org/jbpm/integration/console/CommandDelegate.java +++ b/jbpm-gwt/jbpm-gwt-console/src/main/java/org/jbpm/integration/console/CommandDelegate.java @@ -51,9 +51,9 @@ import org.drools.runtime.process.ProcessInstance; import org.drools.runtime.process.ProcessRuntimeFactory; import org.jbpm.bpmn2.BPMN2ProcessProviderImpl; import org.jbpm.marshalling.impl.ProcessMarshallerFactoryServiceImpl; -import org.jbpm.process.audit.ProcessInstanceDbLog; +import org.jbpm.process.audit.JPAProcessInstanceDbLog; +import org.jbpm.process.audit.JPAWorkingMemoryDbLogger; import org.jbpm.process.audit.ProcessInstanceLog; -import org.jbpm.process.audit.WorkingMemoryDbLogger; import org.jbpm.process.builder.ProcessBuilderFactoryServiceImpl; import org.jbpm.process.core.context.variable.VariableScope; import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl; @@ -64,6 +64,7 @@ import org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl; public class CommandDelegate { private static StatefulKnowledgeSession ksession; + private static JPAProcessInstanceDbLog log = new JPAProcessInstanceDbLog(); public CommandDelegate() { getSession(); @@ -121,7 +122,7 @@ public class CommandDelegate { } StatefulKnowledgeSession ksession = null; EntityManagerFactory emf = Persistence.createEntityManagerFactory( - "org.drools.persistence.jpa"); + "org.jbpm.persistence.jpa"); Environment env = KnowledgeBaseFactory.newEnvironment(); env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf); Properties properties = new Properties(); @@ -157,7 +158,7 @@ public class CommandDelegate { throw e; } } - new WorkingMemoryDbLogger(ksession); + new JPAWorkingMemoryDbLogger(ksession); CommandBasedWSHumanTaskHandler handler = new CommandBasedWSHumanTaskHandler(ksession); properties = new Properties(); try { @@ -222,16 +223,16 @@ public class CommandDelegate { } public ProcessInstanceLog getProcessInstanceLog(String processInstanceId) { - return ProcessInstanceDbLog.findProcessInstance(new Long(processInstanceId)); + return log.findProcessInstance(new Long(processInstanceId)); } public List getProcessInstanceLogsByProcessId(String processId) { - return ProcessInstanceDbLog.findProcessInstances(processId); + return log.findProcessInstances(processId); } public ProcessInstanceLog startProcess(String processId, Map parameters) { long processInstanceId = ksession.startProcess(processId, parameters).getId(); - return ProcessInstanceDbLog.findProcessInstance(processInstanceId); + return log.findProcessInstance(processInstanceId); } public void abortProcessInstance(String processInstanceId) { @@ -287,8 +288,4 @@ public class CommandDelegate { .signalEvent("signal", signal); } - public static void main(String[] args) { - new CommandDelegate(); - } - } diff --git a/jbpm-gwt/jbpm-gwt-graph/src/main/java/org/jbpm/integration/console/graph/GraphViewerPluginImpl.java b/jbpm-gwt/jbpm-gwt-graph/src/main/java/org/jbpm/integration/console/graph/GraphViewerPluginImpl.java index 6d37295..d76f029 100644 --- a/jbpm-gwt/jbpm-gwt-graph/src/main/java/org/jbpm/integration/console/graph/GraphViewerPluginImpl.java +++ b/jbpm-gwt/jbpm-gwt-graph/src/main/java/org/jbpm/integration/console/graph/GraphViewerPluginImpl.java @@ -52,8 +52,8 @@ import org.jboss.bpm.console.client.model.DiagramNodeInfo; import org.jboss.bpm.console.server.plugin.GraphViewerPlugin; import org.jbpm.bpmn2.BPMN2ProcessProviderImpl; import org.jbpm.marshalling.impl.ProcessMarshallerFactoryServiceImpl; +import org.jbpm.process.audit.JPAProcessInstanceDbLog; import org.jbpm.process.audit.NodeInstanceLog; -import org.jbpm.process.audit.ProcessInstanceDbLog; import org.jbpm.process.audit.ProcessInstanceLog; import org.jbpm.process.builder.ProcessBuilderFactoryServiceImpl; import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl; @@ -64,14 +64,15 @@ import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl; public class GraphViewerPluginImpl implements GraphViewerPlugin { private KnowledgeBase kbase; + private JPAProcessInstanceDbLog log = new JPAProcessInstanceDbLog(); public List getActiveNodeInfo(String instanceId) { - ProcessInstanceLog processInstance = ProcessInstanceDbLog.findProcessInstance(new Long(instanceId)); + ProcessInstanceLog processInstance = log.findProcessInstance(new Long(instanceId)); if (processInstance == null) { throw new IllegalArgumentException("Could not find process instance " + instanceId); } Map nodeInstances = new HashMap(); - for (NodeInstanceLog nodeInstance: ProcessInstanceDbLog.findNodeInstances(new Long(instanceId))) { + for (NodeInstanceLog nodeInstance: log.findNodeInstances(new Long(instanceId))) { if (nodeInstance.getType() == NodeInstanceLog.TYPE_ENTER) { nodeInstances.put(nodeInstance.getNodeInstanceId(), nodeInstance); } else { diff --git a/jbpm-gwt/jbpm-gwt-server-war/src/main/resources/META-INF/hibernate.cfg.xml b/jbpm-gwt/jbpm-gwt-server-war/src/main/resources/META-INF/hibernate.cfg.xml deleted file mode 100644 index 6a2de84..0000000 --- a/jbpm-gwt/jbpm-gwt-server-war/src/main/resources/META-INF/hibernate.cfg.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - org.h2.Driver - jdbc:h2:tcp://localhost/~/test - - sa - - - - 1 - - - org.hibernate.dialect.H2Dialect - - - thread - - - org.hibernate.cache.NoCacheProvider - - - false - - - create - - - - - - \ No newline at end of file -- 1.7.3.4