activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r538126 - in /activemq/camel/trunk: ./ camel-bam/ camel-bam/src/main/java/org/apache/camel/bam/ camel-bam/src/main/java/org/apache/camel/bam/model/ camel-bam/src/test/java/org/apache/camel/bam/ camel-bam/src/test/resources/ camel-bam/src/te...
Date Tue, 15 May 2007 10:40:29 GMT
Author: jstrachan
Date: Tue May 15 03:40:26 2007
New Revision: 538126

URL: http://svn.apache.org/viewvc?view=rev&rev=538126
Log:
got the basic BAM persistence working

Added:
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/Activity.java
      - copied, changed from r538075, activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEventHandler.java
      - copied, changed from r538075, activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java
    activemq/camel/trunk/camel-bam/src/test/resources/org/
    activemq/camel/trunk/camel-bam/src/test/resources/org/apache/
    activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/
    activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/
    activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml   (with
props)
Removed:
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java
Modified:
    activemq/camel/trunk/camel-bam/pom.xml
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java
    activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java
    activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java
    activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties
    activemq/camel/trunk/camel-spring/pom.xml
    activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
    activemq/camel/trunk/pom.xml

Modified: activemq/camel/trunk/camel-bam/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/pom.xml?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/pom.xml (original)
+++ activemq/camel/trunk/camel-bam/pom.xml Tue May 15 03:40:26 2007
@@ -42,13 +42,6 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-spring</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-      <type>test-jar</type>
-      <optional>true</optional>
-      <scope>test</scope>
-    </dependency>
 
     <dependency>
       <groupId>org.springframework</groupId>
@@ -69,12 +62,25 @@
     <dependency>
       <groupId>org.apache.openjpa</groupId>
       <artifactId>openjpa-persistence-jdbc</artifactId>
-      <!--<version>0.9.7-incubating-SNAPSHOT</version>-->
       <!-- mandatory dependency for the enhancer! -->
       <!--<scope>test</scope>-->
     </dependency>
 
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+      <type>test-jar</type>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-spring</artifactId>
+      <type>test-jar</type>
+      <optional>true</optional>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.derby</groupId>
       <artifactId>derby</artifactId>
       <scope>test</scope>
@@ -123,27 +129,28 @@
                 </taskdef>
 
                 <mkdir dir="${basedir}/target/jpa-classes"/>
-                <mkdir dir="${basedir}/target/jpa-test-classes"/>
-
                 <openjpac directory="${basedir}/target/jpa-classes">
                   <classpath refid="cp"/>
                   <fileset dir="${basedir}/target/classes">
-                    <include name="org/apache/camel/**/M*.class"/>
+                    <include name="org/apache/camel/bam/model/*.class"/>
                   </fileset>
                 </openjpac>
+                <copy overwrite="true" todir="${basedir}/target/classes">
+                  <fileset dir="${basedir}/target/jpa-classes"/>
+                </copy>
+
+<!--
+                <mkdir dir="${basedir}/target/jpa-test-classes"/>
                 <openjpac directory="${basedir}/target/jpa-test-classes">
                   <classpath refid="cp"/>
                   <fileset dir="${basedir}/target/test-classes">
                     <include name="org/apache/camel/examples/*.class"/>
                   </fileset>
                 </openjpac>
-
-                <copy overwrite="true" todir="${basedir}/target/classes">
-                  <fileset dir="${basedir}/target/jpa-classes"/>
-                </copy>
                 <copy overwrite="true" todir="${basedir}/target/test-classes">
                   <fileset dir="${basedir}/target/jpa-test-classes"/>
                 </copy>
+-->
               </tasks>
             </configuration>
             <goals>

Copied: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/Activity.java (from
r538075, activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/Activity.java?view=diff&rev=538126&p1=activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java&r1=538075&p2=activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/Activity.java&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/Activity.java Tue May
15 03:40:26 2007
@@ -14,23 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.bam.model;
+package org.apache.camel.bam;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.bam.ProcessDefinition;
-
-import javax.persistence.Entity;
-import javax.persistence.NamedQuery;
+import org.apache.camel.bam.model.ActivityState;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * Represents a activity which is typically a system or could be an endpoint
  *
  * @version $Revision: $
  */
-@Entity
-@NamedQuery(name = "findByName",
-        query = "select x from org.apache.camel.bam.model.Activity where x.name = ?1")
 public class Activity {
+    private static final transient Log log = LogFactory.getLog(Activity.class);
+
     private int expectedMessages = 1;
     private String name;
     private ProcessDefinition process;
@@ -59,6 +57,10 @@
      * Perform any assertions after the state has been updated
      */
     public void process(ActivityState activityState, Exchange exchange) {
-        // TODO
+
+        log.info("Received state: " + activityState
+                + " message count " + activityState.getReceivedMessageCount()
+                + " started: " + activityState.getTimeStarted()
+                + " completed: " + activityState.getTimeCompleted());
     }
 }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java
Tue May 15 03:40:26 2007
@@ -20,7 +20,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
-import org.apache.camel.bam.model.Activity;
+import org.apache.camel.bam.Activity;
 import org.apache.camel.bam.model.ActivityState;
 import org.apache.camel.builder.ProcessorFactory;
 
@@ -36,7 +36,7 @@
     public ActivityBuilder(ProcessBuilder processBuilder, Endpoint endpoint) {
         this.processBuilder = processBuilder;
         this.endpoint = endpoint;
-        this.activity = new Activity(processBuilder.getProcess());
+        this.activity = new org.apache.camel.bam.Activity(processBuilder.getProcess());
         this.activity.setName(endpoint.getEndpointUri());
     }
 
@@ -89,7 +89,7 @@
         return correlationExpression;
     }
 
-    public Activity getActivity() {
+    public org.apache.camel.bam.Activity getActivity() {
         return activity;
     }
 

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java
Tue May 15 03:40:26 2007
@@ -17,7 +17,7 @@
 package org.apache.camel.bam;
 
 import org.apache.camel.Exchange;
-import org.apache.camel.bam.model.Activity;
+import org.apache.camel.bam.Activity;
 import org.apache.camel.bam.model.ActivityState;
 import org.apache.camel.bam.model.ProcessInstance;
 

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java
Tue May 15 03:40:26 2007
@@ -19,6 +19,8 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import java.lang.reflect.Type;
 import java.lang.reflect.ParameterizedType;
@@ -30,6 +32,8 @@
  * @version $Revision: $
  */
 public abstract class BamProcessorSupport<T> implements Processor {
+    private static final transient Log log = LogFactory.getLog(BamProcessorSupport.class);
+
     private Class<T> entityType;
     private Expression<Exchange> correlationKeyExpression;
 
@@ -63,6 +67,9 @@
 
 
         T entity = loadEntity(exchange, key);
+
+        log.info("Correlation key: " + key + " with entity: " + entity);
+        
         //storeProcessInExchange(exchange, entity);
         processEntity(exchange, entity);
     }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java
Tue May 15 03:40:26 2007
@@ -20,12 +20,15 @@
 import org.apache.camel.bam.model.ProcessInstance;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.springframework.orm.jpa.JpaTemplate;
 
 /**
  * @version $Revision: $
  */
 public class JpaBamProcessor extends JpaBamProcessorSupport<ProcessInstance> {
+    private static final transient Log log = LogFactory.getLog(JpaBamProcessor.class);
 
     public JpaBamProcessor(Class<ProcessInstance> entitytype, Expression<Exchange>
correlationKeyExpression, Activity activity, JpaTemplate template) {
         super(entitytype, correlationKeyExpression, activity, template);
@@ -36,6 +39,8 @@
     }
 
     protected void processEntity(Exchange exchange, ProcessInstance process) throws Exception
{
+        log.info("Processing entity! - attempting to get the current state for process: "
+ process);
+
         ActivityState state = process.getActivityState(getActivity());
         if (state == null) {
             state = createActivityState(exchange, process);

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java
Tue May 15 03:40:26 2007
@@ -19,10 +19,12 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Expression;
-import org.apache.camel.bam.model.Activity;
+import org.apache.camel.bam.Activity;
 import org.apache.camel.util.IntrospectionSupport;
 import org.springframework.orm.jpa.JpaTemplate;
 
+import java.util.List;
+
 /**
  * @version $Revision: $
  */
@@ -30,7 +32,7 @@
     private Activity activity;
     private JpaTemplate template;
     private String findByKeyQuery;
-    private String keyPropertyName = "key";
+    private String keyPropertyName = "correlationKey";
 
     public JpaBamProcessorSupport(Class<T> entitytype, Expression<Exchange> correlationKeyExpression,
Activity activity, JpaTemplate template) {
         super(entitytype, correlationKeyExpression);
@@ -83,10 +85,15 @@
     // Implementatiom methods
     //-----------------------------------------------------------------------
     protected T loadEntity(Exchange exchange, Object key) {
-        T entity = (T) template.find(getFindByKeyQuery(), key);
+        List<T> list = template.find(getFindByKeyQuery(), key);
+        T entity = null;
+        if (!list.isEmpty()) {
+            entity = list.get(0);
+        }
         if (entity == null) {
             entity = createEntity(exchange, key);
             setKeyProperty(entity, key);
+            template.persist(entity);
         }
         return entity;
     }
@@ -117,6 +124,6 @@
     }
 
     protected String createFindByKeyQuery() {
-        return "select x from " + getEntityType().getName() + " where x." + getKeyPropertyName()
+ " = ?1";
+        return "select x from " + getEntityType().getName() + " x where x." + getKeyPropertyName()
+ " = ?1";
     }
 }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java
Tue May 15 03:40:26 2007
@@ -16,9 +16,14 @@
  */
 package org.apache.camel.bam;
 
+import static org.apache.camel.util.ObjectHelper.notNull;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.bam.model.ProcessInstance;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.builder.FromBuilder;
 import org.springframework.orm.jpa.JpaTemplate;
 
 import java.util.ArrayList;
@@ -30,11 +35,15 @@
  * @version $Revision: $
  */
 public abstract class ProcessBuilder extends RouteBuilder {
-    private List<ActivityBuilder> activityBuilders = new ArrayList<ActivityBuilder>();
-    private Class entityType = Process.class;
     private JpaTemplate jpaTemplate;
+    private List<ActivityBuilder> activityBuilders = new ArrayList<ActivityBuilder>();
+    private Class entityType = ProcessInstance.class;
     private ProcessDefinition process = new ProcessDefinition();
 
+    protected ProcessBuilder(JpaTemplate jpaTemplate) {
+        this.jpaTemplate = jpaTemplate;
+    }
+
     public ActivityBuilder activity(String endpointUri) {
         return activity(endpoint(endpointUri));
     }
@@ -55,6 +64,7 @@
 
 
     public Processor createActivityProcessor(ActivityBuilder activityBuilder) {
+        notNull(jpaTemplate, "jpaTemplate");
         return new JpaBamProcessor(getEntityType(), activityBuilder.getCorrelationExpression(),
activityBuilder.getActivity(), getJpaTemplate());
     }
 
@@ -81,4 +91,16 @@
     public ProcessDefinition getProcess() {
         return process;
     }
-}
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected void populateRoutes(List<Route> routes) throws Exception {
+        for (ActivityBuilder builder : activityBuilders) {
+            Endpoint from = builder.getEndpoint();
+            Processor processor = builder.createProcessor();
+            if (processor == null) {
+                throw new IllegalArgumentException("No processor created for ActivityBuilder:
" + builder);
+            }
+            routes.add(new Route(from, processor));
+        }
+    }}

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java
Tue May 15 03:40:26 2007
@@ -16,7 +16,7 @@
  */
 package org.apache.camel.bam;
 
-import org.apache.camel.bam.model.Activity;
+import org.apache.camel.bam.Activity;
 
 import java.util.Map;
 import java.util.HashMap;
@@ -25,7 +25,7 @@
  * @version $Revision: $
  */
 public class ProcessDefinition {
-    private Map<String, Activity> activitys = new HashMap<String, Activity>();
+    private Map<String, org.apache.camel.bam.Activity> activitys = new HashMap<String,
Activity>();
 
 
     

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java
Tue May 15 03:40:26 2007
@@ -18,7 +18,6 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
-import org.apache.camel.bam.model.Activity;
 
 /**
  * 
@@ -26,11 +25,11 @@
  */
 public class TimeExpression implements Expression<Exchange> {
 
-    private Activity activity;
+    private org.apache.camel.bam.Activity activity;
     private Expression expression;
 
 
-    public TimeExpression(Activity activity, Expression expression) {
+    public TimeExpression(org.apache.camel.bam.Activity activity, Expression expression)
{
         this.activity = activity;
         this.expression = expression;
     }

Copied: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEventHandler.java
(from r538075, activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEventHandler.java?view=diff&rev=538126&p1=activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java&r1=538075&p2=activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEventHandler.java&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEventHandler.java
Tue May 15 03:40:26 2007
@@ -14,7 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.bam.model;
+package org.apache.camel.bam;
+
+import org.apache.camel.bam.model.TimerEvent;
 
 /**
  * @version $Revision: $

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java
Tue May 15 03:40:26 2007
@@ -17,6 +17,8 @@
 package org.apache.camel.bam.model;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.bam.*;
+import org.apache.camel.bam.Activity;
 import org.apache.camel.util.ObjectHelper;
 
 import javax.persistence.CascadeType;
@@ -31,13 +33,11 @@
  */
 @Entity
 public class ActivityState extends TemporalEntity implements TimerEventHandler {
-
-    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
     private ProcessInstance process;
     private int receivedMessageCount;
     private String activityName;
 
-    public synchronized void process(Activity activity, Exchange exchange) throws Exception
{
+    public synchronized void process(org.apache.camel.bam.Activity activity, Exchange exchange)
throws Exception {
         int messageCount = getReceivedMessageCount() + 1;
         setReceivedMessageCount(messageCount);
 
@@ -72,6 +72,7 @@
 
     // Properties
     //-----------------------------------------------------------------------
+    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
     public ProcessInstance getProcess() {
         return process;
     }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java
Tue May 15 03:40:26 2007
@@ -24,10 +24,10 @@
  * @version $Revision: $
  */
 public class EntitySupport {
-    @Id
-    @GeneratedValue
     private Long id;
 
+    @Id
+    @GeneratedValue
     public Long getId() {
         return id;
     }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java
Tue May 15 03:40:26 2007
@@ -16,12 +16,15 @@
  */
 package org.apache.camel.bam.model;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import javax.persistence.CascadeType;
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.OneToMany;
 import java.util.HashSet;
-import java.util.Set;
+import java.util.Collection;
 
 /**
  * Represents a single business process
@@ -30,10 +33,15 @@
  */
 @Entity
 public class ProcessInstance extends TemporalEntity {
-    @OneToMany(mappedBy = "process", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
-    private Set<ActivityState> activityStates = new HashSet<ActivityState>();
-    private String key;
+    private static final transient Log log = LogFactory.getLog(ProcessInstance.class);
+    
+    private Collection<ActivityState> activityStates = new HashSet<ActivityState>();
+    private String correlationKey;
+
 
+    public String toString() {
+        return getClass().getName() + "[id: " + getId() + ", key: " + getCorrelationKey()
+ "]";
+    }
 
     /**
      * Returns the activity state for the given activity
@@ -42,8 +50,10 @@
      * @return the activity state or null if no state could be found for the
      *         given activity
      */
-    public ActivityState getActivityState(Activity activity) {
-        for (ActivityState activityState : activityStates) {
+    public ActivityState getActivityState(org.apache.camel.bam.Activity activity) {
+        log.info("About to iterate through the states: " + getActivityStates());
+
+        for (ActivityState activityState : getActivityStates()) {
             if (activityState.isActivity(activity)) {
                 return activityState;
             }
@@ -51,19 +61,20 @@
         return null;
     }
 
-    public Set<ActivityState> getActivityStates() {
+    @OneToMany(mappedBy = "process", fetch = FetchType.LAZY, cascade = {CascadeType.ALL})
+    public Collection<ActivityState> getActivityStates() {
         return activityStates;
     }
 
-    public void setActivityStates(Set<ActivityState> activityStates) {
+    public void setActivityStates(Collection<ActivityState> activityStates) {
         this.activityStates = activityStates;
     }
 
-    public String getKey() {
-        return key;
+    public String getCorrelationKey() {
+        return correlationKey;
     }
 
-    public void setKey(String key) {
-        this.key = key;
+    public void setCorrelationKey(String correlationKey) {
+        this.correlationKey = correlationKey;
     }
 }

Modified: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java
(original)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java
Tue May 15 03:40:26 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.bam.model;
 
+import org.apache.camel.bam.TimerEventHandler;
+
 import javax.persistence.Entity;
 import javax.persistence.ManyToOne;
 import javax.persistence.FetchType;

Modified: activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java (original)
+++ activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java Tue
May 15 03:40:26 2007
@@ -17,22 +17,44 @@
 package org.apache.camel.bam;
 
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.CamelContext;
+import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.spring.SpringTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import static org.apache.camel.builder.xml.XPathBuilder.xpath;
-import static org.apache.camel.util.Time.*;
+import static org.apache.camel.util.Time.seconds;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.orm.jpa.JpaTemplate;
 
 /**
  * @version $Revision: $
  */
-public class BamRouteTest extends ContextTestSupport {
+public class BamRouteTest extends SpringTestSupport {
     protected Object body = "<hello>world!</hello>";
+    protected JpaTemplate jpaTemplate;
 
     public void testRoute() throws Exception {
-        template.sendBody("direct:start", body);
+        template.sendBody("direct:a", body, "foo", "a");
+
+        //Thread.sleep(30000);
+    }
+
+    protected ClassPathXmlApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext("org/apache/camel/bam/spring.xml");
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        camelContext.addRoutes(createRouteBuilder());
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
-        return new ProcessBuilder() {
+        jpaTemplate = getMandatoryBean(JpaTemplate.class, "jpaTemplate");
+
+        return new ProcessBuilder(jpaTemplate) {
             public void configure() throws Exception {
 
                 ActivityBuilder a = activity("direct:a").name("a")
@@ -42,46 +64,47 @@
                         .correlate(header("foo"));
 
                 ActivityBuilder c = activity("direct:c").name("c")
-                        .correlate(xpath("/foo/bar"));
-
+                        .correlate(header("foo"));
 
                 b.starts().after(a.completes())
                         .expectWithin(seconds(1))
                         .errorIfOver(seconds(5));
 
-                        // TODO .errorIfBefore(a.starts())
-
-
                 /*
-                expect(b.starts().after(10).minutes().from(a.starts());
+        expect(b.starts().after(10).minutes().from(a.starts());
 
 
-                
 
-                process.activity("direct:a").name("a")
-                        .correlate(header("foo"))
-                        .expect(seconds(10)).afterProcess().starts();
-                        .expectedAfter(10).minutes();
-                        .errorAfter(30).minutes();
 
+        process.activity("direct:a").name("a")
+                .correlate(header("foo"))
+                .expect(seconds(10)).afterProcess().starts();
+                .expectedAfter(10).minutes();
+                .errorAfter(30).minutes();
 
-                process.activity("direct:b").name("b")
-                        .correlate(header("foo"))
-                        .expect(minutes(10)).after("a").completes();
 
+        process.activity("direct:b").name("b")
+                .correlate(header("foo"))
+                .expect(minutes(10)).after("a").completes();
 
-                BamBuilder bam = BamBuilder.monitor(this, "direct:a", "direct:b", "direct:c");
 
-                bam.process("direct:b",).expectedMesageCount(1)
-                        .expectedAfter().minutes(10)
-                        .errorAfter().minutes(30);
+        BamBuilder bam = BamBuilder.monitor(this, "direct:a", "direct:b", "direct:c");
 
-                bam.expects("direct:c").expectedMesageCount(1)
-                        .expectedAfter().minutes(10)
-                        .errorAfter().minutes(30);
+        bam.process("direct:b",).expectedMesageCount(1)
+                .expectedAfter().minutes(10)
+                .errorAfter().minutes(30);
 
-                        */
+        bam.expects("direct:c").expectedMesageCount(1)
+                .expectedAfter().minutes(10)
+                .errorAfter().minutes(30);
+
+                */
             }
         };
+    }
+
+    @Override
+    protected int getExpectedRouteCount() {
+        return 0;
     }
 }

Modified: activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties (original)
+++ activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties Tue May 15 03:40:26
2007
@@ -21,7 +21,8 @@
 log4j.rootLogger=INFO, out
 
 #log4j.logger.org.apache.activemq=DEBUG
-#log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.springframework=WARN
 
 # CONSOLE appender not used by default
 log4j.appender.out=org.apache.log4j.ConsoleAppender

Added: activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml?view=auto&rev=538126
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml (added)
+++ activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml Tue
May 15 03:40:26 2007
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
+
+  <bean id="tranactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
+    <property name="transactionManager">
+      <bean class="org.springframework.orm.jpa.JpaTransactionManager">
+        <property name="entityManagerFactory" ref="entityManagerFactory"/>
+      </bean>
+    </property>
+  </bean>
+
+  <bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
+    <property name="entityManagerFactory" ref="entityManagerFactory"/>
+  </bean>
+
+  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
+    <property name="persistenceUnitName" value="bam"/>
+  </bean>
+
+</beans>
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-bam/src/test/resources/org/apache/camel/bam/spring.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/camel-spring/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/pom.xml?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-spring/pom.xml (original)
+++ activemq/camel/trunk/camel-spring/pom.xml Tue May 15 03:40:26 2007
@@ -128,6 +128,18 @@
           </execution>
         </executions>
       </plugin>
+
+      <!-- lets distribute the test cases as a jar -->
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>

Modified: activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
(original)
+++ activemq/camel/trunk/camel-spring/src/test/java/org/apache/camel/spring/SpringTestSupport.java
Tue May 15 03:40:26 2007
@@ -17,14 +17,14 @@
  */
 package org.apache.camel.spring;
 
-import org.apache.camel.TestSupport;
-import org.apache.camel.Route;
-import org.apache.camel.Exchange;
 import org.apache.camel.CamelTemplate;
 import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Route;
+import org.apache.camel.TestSupport;
 import org.apache.camel.util.ObjectHelper;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import java.util.List;
 
@@ -47,6 +47,9 @@
 
         camelContext = createCamelContext();
         assertValidContext(camelContext);
+        if (!camelContext.isStarted()) {
+            camelContext.start();
+        }
 
         template = new CamelTemplate<Exchange>(camelContext);
     }
@@ -82,8 +85,11 @@
         assertNotNull("No context found!", context);
 
         List<Route> routes = context.getRoutes();
-        assertNotNull("Should have some routes defined", routes);
-        assertTrue("Should have at least one route", routes.size() >= getExpectedRouteCount());
+        int routeCount = getExpectedRouteCount();
+        if (routeCount > 0) {
+            assertNotNull("Should have some routes defined", routes);
+            assertTrue("Should have at least one route", routes.size() >= routeCount);
+        }
         log.debug("Camel Routes: " + routes);
     }
 
@@ -94,5 +100,4 @@
     protected SpringCamelContext createCamelContext() throws Exception {
         return SpringCamelContext.springCamelContext(applicationContext);
     }
-
 }

Modified: activemq/camel/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/pom.xml?view=diff&rev=538126&r1=538125&r2=538126
==============================================================================
--- activemq/camel/trunk/pom.xml (original)
+++ activemq/camel/trunk/pom.xml Tue May 15 03:40:26 2007
@@ -229,9 +229,18 @@
         <version>${camel-version}</version>
       </dependency>
 
+      <!-- testing jars -->
       <dependency>
         <groupId>org.apache.camel</groupId>
         <artifactId>camel-core</artifactId>
+        <type>test-jar</type>
+        <version>${camel-version}</version>
+        <optional>true</optional>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-spring</artifactId>
         <type>test-jar</type>
         <version>${camel-version}</version>
         <optional>true</optional>



Mime
View raw message