[jbpm-commits] JBoss JBPM SVN: r3168 - in jbpm3/trunk/modules/integration: spec/src/main/java/org/jbpm/integration/spec/model and 3 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Dec 2 12:28:00 EST 2008
Author: thomas.diesler at jboss.com
Date: 2008-12-02 12:28:00 -0500 (Tue, 02 Dec 2008)
New Revision: 3168
Added:
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionContextServiceImpl.java
Removed:
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java
Modified:
jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java
jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
Log:
Add ExecutionContextService
Modified: jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/jboss42/src/main/etc/jboss-beans.xml 2008-12-02 17:28:00 UTC (rev 3168)
@@ -15,6 +15,7 @@
<set elementClass="org.jboss.bpm.api.service.Service">
<inject bean="BPMDeploymentService"/>
<inject bean="BPMDialectHandlerService"/>
+ <inject bean="BPMExecutionContextService"/>
<inject bean="BPMExecutionService"/>
<inject bean="BPMIdentityService"/>
<inject bean="BPMProcessBuilderService"/>
@@ -51,6 +52,7 @@
<!-- Other Services -->
<bean name="BPMDeploymentService" class="org.jbpm.integration.spec.service.DeploymentServiceImpl" />
+ <bean name="BPMExecutionContextService" class="org.jbpm.integration.spec.service.ExecutionContextServiceImpl" />
<bean name="BPMExecutionService" class="org.jbpm.integration.spec.service.ExecutionServiceImpl" />
<bean name="BPMIdentityService" class="org.jbpm.integration.spec.service.IdentityServiceImpl" />
<bean name="BPMProcessBuilderService" class="org.jbpm.integration.spec.service.ProcessBuilderServiceImpl" />
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/model/ProcessImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -35,13 +35,14 @@
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.builder.ObjectNameFactory;
import org.jboss.bpm.api.runtime.Attachments;
+import org.jboss.bpm.api.runtime.ExecutionContext;
import org.jboss.bpm.api.runtime.Token;
import org.jboss.bpm.api.runtime.Attachments.Key;
import org.jboss.bpm.api.runtime.Token.TokenStatus;
+import org.jboss.bpm.api.service.ExecutionContextService;
import org.jboss.bpm.api.service.ProcessService;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.integration.spec.runtime.TokenImpl;
-import org.jbpm.integration.spec.service.ContextWrapper;
/**
* An integration wrapper
@@ -167,7 +168,9 @@
// @Override
public Token startProcess(Attachments contextData)
{
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
// Register the Process
@@ -196,7 +199,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
}
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/runtime/TokenImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -35,12 +35,13 @@
import org.jboss.bpm.api.model.Process.ProcessStatus;
import org.jboss.bpm.api.model.builder.ObjectNameFactory;
import org.jboss.bpm.api.runtime.Attachments;
+import org.jboss.bpm.api.runtime.ExecutionContext;
import org.jboss.bpm.api.runtime.Token;
+import org.jboss.bpm.api.service.ExecutionContextService;
import org.jbpm.context.exe.ContextInstance;
import org.jbpm.graph.def.Transition;
import org.jbpm.integration.spec.model.NodeImpl;
import org.jbpm.integration.spec.model.ProcessImpl;
-import org.jbpm.integration.spec.service.ContextWrapper;
/**
* An integration wrapper
@@ -166,7 +167,8 @@
private void signalInternal(String name)
{
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
// Make sure we have a current node
@@ -209,7 +211,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
}
Deleted: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ContextWrapper.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -1,103 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.integration.spec.service;
-
-// $Id$
-
-import javax.management.ObjectName;
-
-import org.jboss.bpm.api.client.ProcessEngine;
-import org.jbpm.JbpmConfiguration;
-import org.jbpm.JbpmContext;
-import org.jbpm.integration.spec.client.ProcessEngineImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A wrapper arround the jBPM contaxt that maintains a client count.
- *
- * @author thomas.diesler at jboss.com
- * @since 30-Nov-2008
- */
-public class ContextWrapper
-{
- // Provide logging
- final static Logger log = LoggerFactory.getLogger(ContextWrapper.class);
-
- private static ThreadLocal<ContextWrapper> contextAssociation = new ThreadLocal<ContextWrapper>();
- private JbpmContext jbpmContext;
- private int clientCount;
-
- /**
- * Get a thread local association of the JbpmContext. If there is no context associated, it
- * creates the association. The ContextWrapper must always be closed in a finally clause.
- *
- * Never close the underlying JbpmContext directly.
- */
- public static ContextWrapper getInstance(ProcessEngine engine)
- {
- ContextWrapper currContext = contextAssociation.get();
- if (currContext == null)
- {
- ProcessEngineImpl engineImpl = (ProcessEngineImpl)engine;
- JbpmConfiguration jbpmConfig = engineImpl.getJbpmConfiguration();
- JbpmContext jbpmContext = jbpmConfig.createJbpmContext();
- currContext = new ContextWrapper(jbpmContext);
- contextAssociation.set(currContext);
- }
- currContext.clientCount++;
- return currContext;
- }
-
- private ContextWrapper(JbpmContext jbpmContext)
- {
- this.jbpmContext = jbpmContext;
- }
-
- public JbpmContext getJbpmContext()
- {
- return jbpmContext;
- }
-
- public Long adaptKey(ObjectName key)
- {
- String id = key.getKeyProperty("id");
- if (id == null)
- throw new IllegalStateException("Cannot obtain id property from: " + key);
-
- return new Long(id);
- }
-
- public void close()
- {
- clientCount--;
-
- if (clientCount < 0)
- throw new IllegalStateException("PersistenceContext already closed");
-
- if (clientCount == 0)
- {
- contextAssociation.set(null);
- jbpmContext.close();
- }
- }
-}
\ No newline at end of file
Added: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionContextServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionContextServiceImpl.java (rev 0)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionContextServiceImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -0,0 +1,101 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.integration.spec.service;
+
+// $Id$
+
+import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.runtime.BasicAttachments;
+import org.jboss.bpm.api.runtime.ExecutionContext;
+import org.jboss.bpm.api.service.internal.AbstractExecutionContextService;
+import org.jbpm.JbpmContext;
+import org.jbpm.integration.spec.client.ProcessEngineImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The ExecutionContextService is the entry point to create or get an ExecutionContext.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 02-Dec-2008
+ */
+public class ExecutionContextServiceImpl extends AbstractExecutionContextService implements MutableService
+{
+ // Provide logging
+ final static Logger log = LoggerFactory.getLogger(ExecutionContextServiceImpl.class);
+
+ private static ThreadLocal<ExecutionContextImpl> contextAssociation = new ThreadLocal<ExecutionContextImpl>();
+
+ @Override
+ public void setProcessEngine(ProcessEngine engine)
+ {
+ super.setProcessEngine(engine);
+ }
+
+ public ExecutionContext createExecutionContext()
+ {
+ ProcessEngineImpl engineImpl = (ProcessEngineImpl)getProcessEngine();
+ JbpmContext jbpmContext = engineImpl.getJbpmConfiguration().createJbpmContext();
+ ExecutionContextImpl currContext = new ExecutionContextImpl(jbpmContext);
+ contextAssociation.set(currContext);
+ return currContext;
+ }
+
+ public ExecutionContext getExecutionContext(boolean create)
+ {
+ ExecutionContextImpl currContext = contextAssociation.get();
+
+ if (currContext == null && create == true)
+ currContext = (ExecutionContextImpl)createExecutionContext();
+
+ if (currContext != null)
+ currContext.clientCount++;
+
+ return currContext;
+ }
+
+ class ExecutionContextImpl extends BasicAttachments implements ExecutionContext
+ {
+ private JbpmContext jbpmContext;
+ private int clientCount;
+
+ ExecutionContextImpl(JbpmContext jbpmContext)
+ {
+ this.jbpmContext = jbpmContext;
+ addAttachment(JbpmContext.class, jbpmContext);
+ }
+
+ public void close()
+ {
+ clientCount--;
+
+ if (clientCount < 0)
+ throw new IllegalStateException("PersistenceContext already closed");
+
+ if (clientCount == 0)
+ {
+ contextAssociation.set(null);
+ jbpmContext.close();
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ExecutionContextServiceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/InvocationProxy.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.integration.spec.service;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import org.jboss.bpm.api.client.ProcessEngine;
-
-/**
- * Decorates management invocations with common system aspects.
- *
- * @author Heiko.Braun <heiko.braun at jboss.com>
- * @author Thomas.Diesler at jboss.com
- */
-public class InvocationProxy implements InvocationHandler
-{
- private ProcessEngine engine;
- private Object obj;
-
- @SuppressWarnings("unchecked")
- public static Object newInstance(ProcessEngine engine, Object obj, Class[] interfaces)
- {
- return Proxy.newProxyInstance(obj.getClass().getClassLoader(), interfaces, new InvocationProxy(engine, obj));
- }
-
- private InvocationProxy(ProcessEngine engine, Object obj)
- {
- this.engine = engine;
- this.obj = obj;
- }
-
- public Object invoke(Object proxy, Method m, Object[] args) throws Throwable
- {
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(engine);
- try
- {
- return m.invoke(obj, args);
- }
- finally
- {
- ctxWrapper.close();
- }
- }
-}
\ No newline at end of file
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessDefinitionServiceImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -31,6 +31,8 @@
import org.jboss.bpm.api.client.ProcessEngine;
import org.jboss.bpm.api.model.ProcessDefinition;
+import org.jboss.bpm.api.runtime.ExecutionContext;
+import org.jboss.bpm.api.service.ExecutionContextService;
import org.jboss.bpm.api.service.ProcessService;
import org.jboss.bpm.api.service.internal.AbstractProcessDefinitionService;
import org.jbpm.JbpmContext;
@@ -59,11 +61,13 @@
public ProcessDefinition getProcessDefinition(ObjectName procDefID)
{
ProcessDefinition procDef = null;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- Long id = ctxWrapper.adaptKey(procDefID);
- GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ Long id = adaptKey(procDefID);
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
org.jbpm.graph.def.ProcessDefinition oldProcDef = graphSession.getProcessDefinition(id);
if (oldProcDef != null)
{
@@ -72,7 +76,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return procDef;
}
@@ -80,10 +84,12 @@
public Set<ObjectName> getProcessDefinitions()
{
Set<ObjectName> procDefs = new HashSet<ObjectName>();
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
for (Object item : graphSession.findAllProcessDefinitions())
{
org.jbpm.graph.def.ProcessDefinition oldProcDef = (org.jbpm.graph.def.ProcessDefinition)item;
@@ -92,7 +98,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return Collections.unmodifiableSet(procDefs);
}
@@ -101,19 +107,20 @@
{
log.debug("registerProcessDefinition: " + procDef);
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
if (getProcessDefinition(procDef.getKey()) != null)
throw new IllegalStateException("Process definition already registered: " + procDef);
- JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
+ JbpmContext jbpmContext = bpmContext.getAttachment(JbpmContext.class);
ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
jbpmContext.deployProcessDefinition(procDefImpl.getOldProcessDefinition());
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return procDef;
@@ -122,7 +129,9 @@
public boolean unregisterProcessDefinition(ObjectName procDefID)
{
boolean removed = false;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
ProcessDefinition procDef = getProcessDefinition(procDefID);
@@ -137,15 +146,25 @@
ProcessDefinitionImpl procDefImpl = (ProcessDefinitionImpl)procDef;
long oldID = procDefImpl.getOldProcessDefinition().getId();
- ctxWrapper.getJbpmContext().getGraphSession().deleteProcessDefinition(oldID);
+ JbpmContext jbpmContext = bpmContext.getAttachment(JbpmContext.class);
+ jbpmContext.getGraphSession().deleteProcessDefinition(oldID);
removed = true;
}
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return removed;
}
+
+ private Long adaptKey(ObjectName key)
+ {
+ String id = key.getKeyProperty("id");
+ if (id == null)
+ throw new IllegalStateException("Cannot obtain id property from: " + key);
+
+ return new Long(id);
+ }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/ProcessServiceImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -35,9 +35,11 @@
import org.jboss.bpm.api.model.Process;
import org.jboss.bpm.api.model.ProcessDefinition;
import org.jboss.bpm.api.model.Process.ProcessStatus;
+import org.jboss.bpm.api.runtime.ExecutionContext;
+import org.jboss.bpm.api.service.ExecutionContextService;
import org.jboss.bpm.api.service.ProcessDefinitionService;
-import org.jboss.bpm.api.service.internal.AbstractProcessDefinitionService;
import org.jboss.bpm.api.service.internal.AbstractProcessService;
+import org.jbpm.JbpmContext;
import org.jbpm.db.GraphSession;
import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.integration.spec.model.ProcessImpl;
@@ -85,11 +87,13 @@
public Process getProcess(ObjectName procID)
{
Process proc = null;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- Long id = ctxWrapper.adaptKey(procID);
- GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ Long id = adaptKey(procID);
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
ProcessInstance oldProc = graphSession.getProcessInstance(id);
if (oldProc != null)
{
@@ -98,7 +102,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return proc;
}
@@ -110,14 +114,16 @@
public Set<ObjectName> getProcesses()
{
Set<ObjectName> procs = new HashSet<ObjectName>();
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
ProcessDefinitionService pdService = getProcessEngine().getService(ProcessDefinitionService.class);
for (ObjectName procDefID : pdService.getProcessDefinitions())
{
- Long id = ctxWrapper.adaptKey(procDefID);
- GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ Long id = adaptKey(procDefID);
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
for (Object item : graphSession.findProcessInstances(id))
{
ProcessInstance oldProc = (ProcessInstance)item;
@@ -127,7 +133,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return Collections.unmodifiableSet(procs);
}
@@ -143,11 +149,13 @@
public Set<ObjectName> getProcesses(ObjectName procDefID, ProcessStatus status)
{
Set<ObjectName> procs = new HashSet<ObjectName>();
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- Long id = ctxWrapper.adaptKey(procDefID);
- GraphSession graphSession = ctxWrapper.getJbpmContext().getGraphSession();
+ Long id = adaptKey(procDefID);
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
for (Object item : graphSession.findProcessInstances(id))
{
ProcessInstance oldProc = (ProcessInstance)item;
@@ -158,7 +166,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return Collections.unmodifiableSet(procs);
}
@@ -171,7 +179,9 @@
log.debug("registerProcess: " + proc);
ObjectName procID;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
if (getProcess(proc.getKey()) != null)
@@ -190,14 +200,14 @@
procDefService.registerProcessDefinition(procDef);
// Save the Process instance
- ctxWrapper.getJbpmContext().save(procImpl.getOldProcessInstance());
+ bpmContext.getAttachment(JbpmContext.class).save(procImpl.getOldProcessInstance());
procImpl.setProcessStatus(ProcessStatus.Ready);
procID = proc.getKey();
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return procID;
@@ -209,7 +219,9 @@
public boolean unregisterProcess(ObjectName procID)
{
boolean removed = false;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
Process proc = getProcess(procID);
@@ -218,13 +230,14 @@
log.debug("unregisterProcess: " + proc);
ProcessImpl procImpl = (ProcessImpl)proc;
- ctxWrapper.getJbpmContext().getGraphSession().deleteProcessInstance(procImpl.getOldProcessInstance());
+ GraphSession graphSession = bpmContext.getAttachment(JbpmContext.class).getGraphSession();
+ graphSession.deleteProcessInstance(procImpl.getOldProcessInstance());
removed = true;
}
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return removed;
@@ -247,4 +260,13 @@
}
return itor;
}
+
+ private Long adaptKey(ObjectName key)
+ {
+ String id = key.getKeyProperty("id");
+ if (id == null)
+ throw new IllegalStateException("Cannot obtain id property from: " + key);
+
+ return new Long(id);
+ }
}
\ No newline at end of file
Modified: jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/java/org/jbpm/integration/spec/service/TaskServiceImpl.java 2008-12-02 17:28:00 UTC (rev 3168)
@@ -29,6 +29,8 @@
import javax.management.ObjectName;
import org.jboss.bpm.api.client.ProcessEngine;
+import org.jboss.bpm.api.runtime.ExecutionContext;
+import org.jboss.bpm.api.service.ExecutionContextService;
import org.jboss.bpm.api.service.internal.AbstractTaskService;
import org.jboss.bpm.api.task.Task;
import org.jbpm.JbpmContext;
@@ -58,10 +60,11 @@
{
Task task = null;
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
+ JbpmContext jbpmContext = bpmContext.getAttachment(JbpmContext.class);
TaskInstance oldTask = jbpmContext.getTaskInstance(adaptKey(taskID));
task = new TaskImpl(getProcessEngine(), oldTask);
}
@@ -71,7 +74,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return task;
@@ -81,10 +84,11 @@
{
List<Task> tasks = new ArrayList<Task>();
- ContextWrapper ctxWrapper = ContextWrapper.getInstance(getProcessEngine());
+ ExecutionContextService ctxService = getProcessEngine().getService(ExecutionContextService.class);
+ ExecutionContext bpmContext = ctxService.getExecutionContext(true);
try
{
- JbpmContext jbpmContext = ctxWrapper.getJbpmContext();
+ JbpmContext jbpmContext = bpmContext.getAttachment(JbpmContext.class);
for (TaskInstance oldTask : (List<TaskInstance>)jbpmContext.getTaskList(actor))
{
tasks.add(new TaskImpl(getProcessEngine(), oldTask));
@@ -96,7 +100,7 @@
}
finally
{
- ctxWrapper.close();
+ bpmContext.close();
}
return tasks;
Modified: jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml
===================================================================
--- jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-12-02 17:26:20 UTC (rev 3167)
+++ jbpm3/trunk/modules/integration/spec/src/main/resources/jbpm-cfg-beans.xml 2008-12-02 17:28:00 UTC (rev 3168)
@@ -15,6 +15,7 @@
<set elementClass="org.jboss.bpm.api.service.Service">
<inject bean="BPMDeploymentService"/>
<inject bean="BPMDialectHandlerService"/>
+ <inject bean="BPMExecutionContextService"/>
<inject bean="BPMExecutionService"/>
<inject bean="BPMIdentityService"/>
<inject bean="BPMProcessBuilderService"/>
@@ -51,6 +52,7 @@
<!-- Other Services -->
<bean name="BPMDeploymentService" class="org.jbpm.integration.spec.service.DeploymentServiceImpl" />
+ <bean name="BPMExecutionContextService" class="org.jbpm.integration.spec.service.ExecutionContextServiceImpl" />
<bean name="BPMExecutionService" class="org.jbpm.integration.spec.service.ExecutionServiceImpl" />
<bean name="BPMIdentityService" class="org.jbpm.integration.spec.service.IdentityServiceImpl" />
<bean name="BPMProcessBuilderService" class="org.jbpm.integration.spec.service.ProcessBuilderServiceImpl" />
More information about the jbpm-commits
mailing list