[jbpm-commits] JBoss JBPM SVN: r2169 - in jbpm3/trunk/modules: enterprise/jar/src/main/java/org/jbpm/ejb and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Sep 10 20:18:39 EDT 2008


Author: alex.guizar at jboss.com
Date: 2008-09-10 20:18:38 -0400 (Wed, 10 Sep 2008)
New Revision: 2169

Modified:
   jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
   jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java
   jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java
   jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java
   jbpm3/trunk/modules/enterprise/jar/src/main/resources/META-INF/ejb-jar.xml
Log:
[JBPM-1708] revised ejb queries to address entity not found exceptions

Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java	2008-09-10 23:48:04 UTC (rev 2168)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/jpdl/xml/JpdlXmlReader.java	2008-09-11 00:18:38 UTC (rev 2169)
@@ -70,12 +70,15 @@
   protected String initialNodeName = null;
   protected Collection unresolvedTransitionDestinations = null;
   protected Collection unresolvedActionReferences = null;
-  
+
   /**
    * the parsed process definition as DOM tree (available after readProcessDefinition)
    */
   protected Document document;
-  
+
+  /** for autonumbering anonymous timers. */
+  private int timerNumber;
+
   public JpdlXmlReader(InputSource inputSource) {
     this.inputSource = inputSource;
   }
@@ -540,6 +543,7 @@
 
   protected void readNodeTimer(Element timerElement, Node node) {
     String name = timerElement.attributeValue("name", node.getName());
+    if (name == null) name = generateTimerName();
     
     CreateTimerAction createTimerAction = new CreateTimerAction();
     createTimerAction.read(timerElement, this);
@@ -551,7 +555,11 @@
     cancelTimerAction.setTimerName(name);
     addAction(node, Event.EVENTTYPE_NODE_LEAVE, cancelTimerAction);
   }
-  
+
+  private String generateTimerName() {
+    return "timer-" + (timerNumber++); 
+  }
+
   protected void readTaskTimers(Element taskElement, Task task) {
     Iterator iter = taskElement.elementIterator();
     while (iter.hasNext()) {
@@ -566,8 +574,8 @@
 
   protected void readTaskTimer(Element timerElement, Task task) {
     String name = timerElement.attributeValue("name", task.getName());
-    if (name==null) name = "timer-for-task-"+task.getId();
-    
+    if (name==null) name = generateTimerName();
+
     CreateTimerAction createTimerAction = new CreateTimerAction();
     createTimerAction.read(timerElement, this);
     createTimerAction.setTimerName(name);

Modified: jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java
===================================================================
--- jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java	2008-09-10 23:48:04 UTC (rev 2168)
+++ jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/LocalTimerEntityHome.java	2008-09-11 00:18:38 UTC (rev 2169)
@@ -10,12 +10,10 @@
 
 	public LocalTimerEntity create() throws CreateException;
 
-	public LocalTimerEntity findByPrimaryKey(Long key) throws FinderException;
+	public LocalTimerEntity findByPrimaryKey(Long timerId) throws FinderException;
 
-	public Collection findByTokenId(Long key) throws FinderException;
-
-	public Collection findByTokenIdAndName(Long key, String name)
+	public Collection findByNameAndTokenId(String name, Long tokenId)
 			throws FinderException;
 
-	public Collection findByProcessInstanceId(Long key) throws FinderException;
+	public Collection findByProcessInstanceId(Long processInstanceId) throws FinderException;
 }

Modified: jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java
===================================================================
--- jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java	2008-09-10 23:48:04 UTC (rev 2168)
+++ jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/ejb/impl/TimerEntityBean.java	2008-09-11 00:18:38 UTC (rev 2169)
@@ -74,9 +74,9 @@
 
 	public abstract void setProcessInstanceId(Long processInstanceId);
 
-	public abstract char getDiscriminator();
+	public abstract String getDiscriminator();
 
-	public abstract void setDiscriminator(char discriminator);
+	public abstract void setDiscriminator(String discriminator);
 
 	public void ejbActivate() {
     try {

Modified: jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java
===================================================================
--- jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java	2008-09-10 23:48:04 UTC (rev 2168)
+++ jbpm3/trunk/modules/enterprise/jar/src/main/java/org/jbpm/scheduler/ejbtimer/EntitySchedulerService.java	2008-09-11 00:18:38 UTC (rev 2169)
@@ -64,13 +64,7 @@
 
   public void deleteTimersByName(String timerName, Token token) {
 		try {
-		  Collection timerEntities;
-			if(timerName == null || timerName.equals("")) {
-				timerEntities = timerEntityHome.findByTokenId(new Long(token.getId()));
-			}
-			else {
-				timerEntities = timerEntityHome.findByTokenIdAndName(new Long(token.getId()), timerName);
-			}
+		  Collection timerEntities = timerEntityHome.findByNameAndTokenId(timerName, new Long(token.getId()));
 			log.debug("found " + timerEntities.size() + " timer entities by name '" + timerName +  "' for " + token);
 			for (Iterator i = timerEntities.iterator(); i.hasNext();) {
 				LocalTimerEntity timerEntity = (LocalTimerEntity) i.next();

Modified: jbpm3/trunk/modules/enterprise/jar/src/main/resources/META-INF/ejb-jar.xml
===================================================================
--- jbpm3/trunk/modules/enterprise/jar/src/main/resources/META-INF/ejb-jar.xml	2008-09-10 23:48:04 UTC (rev 2168)
+++ jbpm3/trunk/modules/enterprise/jar/src/main/resources/META-INF/ejb-jar.xml	2008-09-11 00:18:38 UTC (rev 2169)
@@ -247,37 +247,22 @@
       </ejb-local-ref>
 
       <query>
-        <description>Retrieve all timers by token identifier</description>
+        <description>Retrieve all timers by name and token identifier</description>
         <query-method>
-          <method-name>findByTokenId</method-name>
+          <method-name>findByNameAndTokenId</method-name>
           <method-params>
+            <method-param>java.lang.String</method-param>
             <method-param>java.lang.Long</method-param>
           </method-params>
         </query-method>
         <ejb-ql><![CDATA[
           select object(obj)
           from TimerEntityBean obj
-          where obj.tokenId = ?1 and obj.discriminator = 84
+          where obj.name = ?1 and obj.tokenId = ?2 and obj.discriminator = 'T'
         ]]></ejb-ql>
       </query>
 
       <query>
-        <description>Retrieve all timers by token identifier and name</description>
-        <query-method>
-          <method-name>findByTokenIdAndName</method-name>
-          <method-params>
-            <method-param>java.lang.Long</method-param>
-            <method-param>java.lang.String</method-param>
-          </method-params>
-        </query-method>
-        <ejb-ql><![CDATA[
-          select object(obj)
-          from TimerEntityBean obj
-          where obj.tokenId = ?1 and obj.name = ?2 and obj.discriminator = 84
-        ]]></ejb-ql>
-      </query>
-
-      <query>
         <description>Retrieve all timers by process instance identifier</description>
         <query-method>
           <method-name>findByProcessInstanceId</method-name>
@@ -288,7 +273,7 @@
         <ejb-ql><![CDATA[
           select object(obj)
           from TimerEntityBean obj
-          where obj.processInstanceId = ?1 and obj.discriminator = 84
+          where obj.processInstanceId = ?1 and obj.discriminator = 'T'
         ]]></ejb-ql>
       </query>
     </entity>




More information about the jbpm-commits mailing list