[jbpm-commits] JBoss JBPM SVN: r3698 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/db.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jan 21 14:18:15 EST 2009
Author: alex.guizar at jboss.com
Date: 2009-01-21 14:18:15 -0500 (Wed, 21 Jan 2009)
New Revision: 3698
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
Log:
prevent unnecessary invocation of JbpmSession
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/GraphSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -48,17 +48,17 @@
*/
public class GraphSession {
- JbpmSession jbpmSession = null;
- Session session = null;
+ final Session session;
+ final JbpmSession jbpmSession;
public GraphSession(JbpmSession jbpmSession) {
- this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
+ this.jbpmSession = jbpmSession;
}
public GraphSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
// process definitions //////////////////////////////////////////////////////
@@ -95,8 +95,7 @@
session.save(processDefinition);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't save process definition '" + processDefinition + "'", e);
}
}
@@ -111,8 +110,7 @@
return (ProcessDefinition) session.load(ProcessDefinition.class, new Long(processDefinitionId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process definition '" + processDefinitionId + "'", e);
}
}
@@ -127,8 +125,7 @@
return (ProcessDefinition) session.get(ProcessDefinition.class, new Long(processDefinitionId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process definition '" + processDefinitionId + "'", e);
}
}
@@ -145,8 +142,7 @@
processDefinition = (ProcessDefinition) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process definition with name '"
+ name
+ "' and version '"
@@ -168,8 +164,7 @@
processDefinition = (ProcessDefinition) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find process definition '" + name + "'", e);
}
return processDefinition;
@@ -193,8 +188,7 @@
return result;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find latest versions of process definitions", e);
}
}
@@ -215,8 +209,7 @@
return CollectionUtil.checkList(query.list(), ProcessDefinition.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't find all process definitions", e);
}
}
@@ -260,8 +253,7 @@
session.delete(processDefinition);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't delete process definition '"
+ processDefinition.getId()
+ "'", e);
@@ -305,8 +297,7 @@
return processInstance;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instance '" + processInstanceId + "'", e);
}
}
@@ -322,8 +313,7 @@
return processInstance;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process instance '" + processInstanceId + "'", e);
}
}
@@ -340,8 +330,7 @@
return token;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load token '" + tokenId + "'", e);
}
}
@@ -357,8 +346,7 @@
return token;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get token '" + tokenId + "'", e);
}
}
@@ -378,8 +366,7 @@
session.lock(processInstance, LockMode.UPGRADE);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't lock process instance '" + processInstance.getId() + "'", e);
}
}
@@ -395,8 +382,7 @@
return CollectionUtil.checkList(query.list(), ProcessInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instances for process definition '"
+ processDefinitionId
+ "'", e);
@@ -466,8 +452,7 @@
session.delete(processInstance);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't delete process instance '" + processInstance.getId() + "'",
e);
}
@@ -590,8 +575,7 @@
return results;
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instances for process definition '"
+ processDefinitionId
+ "'", e);
@@ -605,8 +589,7 @@
return CollectionUtil.checkList(query.list(), Node.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't active nodes for process instance '"
+ processInstance
+ "'", e);
@@ -622,8 +605,7 @@
processInstance = (ProcessInstance) query.uniqueResult();
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process instance with key '" + key + "'", e);
}
return processInstance;
@@ -641,12 +623,17 @@
}
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process instance with key '" + key + "'", e);
}
return processInstance;
}
+ private void handle(Exception e) {
+ log.error(e);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(GraphSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/JobSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -41,7 +41,7 @@
public class JobSession {
- private Session session;
+ private final Session session;
public JobSession(Session session) {
this.session = session;
@@ -155,15 +155,6 @@
return CollectionUtil.checkList(criteria.list(), Job.class);
}
- private static Long[] toObjectArray(long[] array) {
- final int length = array.length;
- Long[] objects = new Long[length];
- for (int i = 0; i < length; i++) {
- objects[i] = array[i];
- }
- return objects;
- }
-
public Job getJob(long jobId) {
try {
return (Job) session.get(Job.class, new Long(jobId));
@@ -231,5 +222,14 @@
return CollectionUtil.checkList(query.list(), Job.class);
}
+ private static Long[] toObjectArray(long[] array) {
+ final int length = array.length;
+ Long[] objects = new Long[length];
+ for (int i = 0; i < length; i++) {
+ objects[i] = array[i];
+ }
+ return objects;
+ }
+
private static Log log = LogFactory.getLog(JobSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/LoggingSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -37,17 +37,17 @@
public class LoggingSession {
- JbpmSession jbpmSession;
- Session session;
+ final Session session;
+ final JbpmSession jbpmSession;
public LoggingSession(JbpmSession jbpmSession) {
+ this.session = jbpmSession.getSession();
this.jbpmSession = jbpmSession;
- this.session = jbpmSession.getSession();
}
public LoggingSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
/**
@@ -68,8 +68,7 @@
collectTokenLogs(tokenLogs, processInstance.getRootToken());
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get logs for " + processInstance, e);
}
return tokenLogs;
@@ -102,8 +101,7 @@
return CollectionUtil.checkList(query.list(), ProcessLog.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get logs for " + token, e);
}
}
@@ -116,8 +114,7 @@
session.save(processLog);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't save process log '" + processLog + "'", e);
}
}
@@ -131,8 +128,7 @@
processLog = (ProcessLog) session.load(ProcessLog.class, new Long(processLogId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't load process log '" + processLogId + "'", e);
}
return processLog;
@@ -147,12 +143,17 @@
processLog = (ProcessLog) session.get(ProcessLog.class, new Long(processLogId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get process log '" + processLogId + "'", e);
}
return processLog;
}
+ private void handle(Exception exception) {
+ log.error(exception);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(LoggingSession.class);
}
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-01-21 16:49:54 UTC (rev 3697)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/db/TaskMgmtSession.java 2009-01-21 19:18:15 UTC (rev 3698)
@@ -39,17 +39,17 @@
private static final long serialVersionUID = 1L;
- JbpmSession jbpmSession = null;
- Session session = null;
+ final Session session;
+ final JbpmSession jbpmSession;
public TaskMgmtSession(JbpmSession jbpmSession) {
- this.jbpmSession = jbpmSession;
this.session = jbpmSession.getSession();
+ this.jbpmSession = jbpmSession;
}
public TaskMgmtSession(Session session) {
this.session = session;
- this.jbpmSession = new JbpmSession(session);
+ this.jbpmSession = null;
}
/**
@@ -62,8 +62,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances list for actor '" + actorId + "'", e);
}
}
@@ -81,8 +80,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances list for actors '" + actorIds + "'", e);
}
}
@@ -105,8 +103,7 @@
return findTaskInstancesByIds(taskInstanceIds);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException(
"couldn't get pooled task instances list for actor '" + actorId + "'", e);
}
@@ -123,8 +120,7 @@
return findTaskInstancesByIds(taskInstanceIds);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get pooled task instances list for actors '"
+ actorIds
+ "'", e);
@@ -141,8 +137,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by token '" + tokenId + "'", e);
}
}
@@ -157,8 +152,7 @@
return CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by process instance '"
+ processInstance
+ "'", e);
@@ -174,8 +168,7 @@
taskInstance = (TaskInstance) session.load(TaskInstance.class, new Long(taskInstanceId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
@@ -190,8 +183,7 @@
taskInstance = (TaskInstance) session.get(TaskInstance.class, new Long(taskInstanceId));
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instance '" + taskInstanceId + "'", e);
}
return taskInstance;
@@ -209,13 +201,18 @@
result = CollectionUtil.checkList(query.list(), TaskInstance.class);
}
catch (Exception e) {
- log.error(e);
- jbpmSession.handleException();
+ handle(e);
throw new JbpmException("couldn't get task instances by ids '" + taskInstanceIds + "'", e);
}
}
return result;
}
+ private void handle(Exception exception) {
+ log.error(exception);
+ if (jbpmSession != null)
+ jbpmSession.handleException();
+ }
+
private static final Log log = LogFactory.getLog(TaskMgmtSession.class);
}
More information about the jbpm-commits
mailing list