You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2007/05/15 09:14:54 UTC
svn commit: r538073 - in /activemq/camel/trunk/camel-bam: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/camel/ src/main/java/org/apache/camel/bam/
src/main/java/org/apache/camel/bam/model/ src/ma...
Author: jstrachan
Date: Tue May 15 00:14:51 2007
New Revision: 538073
URL: http://svn.apache.org/viewvc?view=rev&rev=538073
Log:
added an early spike of a BAM engine hacked on the flights to and from JavaOne :)
Added:
activemq/camel/trunk/camel-bam/
activemq/camel/trunk/camel-bam/pom.xml
activemq/camel/trunk/camel-bam/src/
activemq/camel/trunk/camel-bam/src/main/
activemq/camel/trunk/camel-bam/src/main/java/
activemq/camel/trunk/camel-bam/src/main/java/org/
activemq/camel/trunk/camel-bam/src/main/java/org/apache/
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/
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/BamBuilder.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/NoCorrelationKeyException.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/ProcessExpressionSupport.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalBuilder.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalRule.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeBuilder.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/TimerEngine.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/
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/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/TemporalEntity.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java
activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java
activemq/camel/trunk/camel-bam/src/main/resources/
activemq/camel/trunk/camel-bam/src/test/
activemq/camel/trunk/camel-bam/src/test/java/
activemq/camel/trunk/camel-bam/src/test/java/org/
activemq/camel/trunk/camel-bam/src/test/java/org/apache/
activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/
activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/
activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java
activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/TimerTest.java
activemq/camel/trunk/camel-bam/src/test/resources/
activemq/camel/trunk/camel-bam/src/test/resources/META-INF/
activemq/camel/trunk/camel-bam/src/test/resources/META-INF/persistence.xml
activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties
Added: activemq/camel/trunk/camel-bam/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/pom.xml?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/pom.xml (added)
+++ activemq/camel/trunk/camel-bam/pom.xml Tue May 15 00:14:51 2007
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-bam</artifactId>
+ <name>Camel :: BAM</name>
+ <description>Camel BAM support</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+ <dependency>
+ <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>
+ <artifactId>spring</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+
+ <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.derby</groupId>
+ <artifactId>derby</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.2.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!-- lets enhance the classes for OpenJPA (shame it can't do it at runtime!) -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+
+ <executions>
+ <execution>
+ <phase>process-test-classes</phase>
+ <configuration>
+ <tasks>
+ <path id="cp">
+ <path refid="maven.test.classpath"/>
+ <path refid="maven.compile.classpath"/>
+ <path refid="maven.dependency.classpath"/>
+ </path>
+ <taskdef name="openjpac" classname="org.apache.openjpa.ant.PCEnhancerTask">
+ <classpath refid="cp"/>
+ </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"/>
+ </fileset>
+ </openjpac>
+ <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>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityBuilder.java Tue May 15 00:14:51 2007
@@ -0,0 +1,107 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Endpoint;
+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.model.ActivityState;
+import org.apache.camel.builder.ProcessorFactory;
+
+/**
+ * @version $Revision: $
+ */
+public class ActivityBuilder implements ProcessorFactory {
+ private ProcessBuilder processBuilder;
+ private Endpoint endpoint;
+ private Activity activity;
+ private Expression correlationExpression;
+
+ public ActivityBuilder(ProcessBuilder processBuilder, Endpoint endpoint) {
+ this.processBuilder = processBuilder;
+ this.endpoint = endpoint;
+ this.activity = new Activity(processBuilder.getProcess());
+ this.activity.setName(endpoint.getEndpointUri());
+ }
+
+ public Endpoint getEndpoint() {
+ return endpoint;
+ }
+
+ public Processor createProcessor() throws Exception {
+ return processBuilder.createActivityProcessor(this);
+ }
+
+ // Builder methods
+ //-----------------------------------------------------------------------
+ public ActivityBuilder correlate(Expression correlationExpression) {
+ this.correlationExpression = correlationExpression;
+ return this;
+ }
+
+ public ActivityBuilder name(String name) {
+ activity.setName(name);
+ return this;
+ }
+
+ /**
+ * Create a temporal rule for when this step starts
+ */
+ public TimeExpression starts() {
+ return createTimeExpression(new ActivityExpressionSupport(activity) {
+ protected Object evaluateState(Exchange exchange, ActivityState state) {
+ return state.getStartTime();
+ }
+ });
+ }
+
+ /**
+ * Create a temporal rule for when this step completes
+ */
+ public TimeExpression completes() {
+ return createTimeExpression(new ActivityExpressionSupport(activity) {
+ protected Object evaluateState(Exchange exchange, ActivityState state) {
+ return state.getCompleteTime();
+ }
+ });
+ }
+
+
+ // Properties
+ //-----------------------------------------------------------------------
+ public Expression getCorrelationExpression() {
+ return correlationExpression;
+ }
+
+ public Activity getActivity() {
+ return activity;
+ }
+
+ public ProcessBuilder getProcessBuilder() {
+ return processBuilder;
+ }
+
+ // Implementation methods
+ //-----------------------------------------------------------------------
+ protected TimeExpression createTimeExpression(ActivityExpressionSupport expression) {
+ return new TimeExpression(activity, expression);
+ }
+
+
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ActivityExpressionSupport.java Tue May 15 00:14:51 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.bam.model.Activity;
+import org.apache.camel.bam.model.ActivityState;
+import org.apache.camel.bam.model.ProcessInstance;
+
+/**
+ * @version $Revision: $
+ */
+public abstract class ActivityExpressionSupport extends ProcessExpressionSupport<ProcessInstance> {
+ private Activity activity;
+
+ protected ActivityExpressionSupport(Activity activity) {
+ super(ProcessInstance.class);
+ this.activity = activity;
+ }
+
+ protected Object evaluate(Exchange exchange, ProcessInstance processEntity) {
+ ActivityState state = processEntity.getActivityState(activity);
+ if (state != null) {
+ return evaluateState(exchange, state);
+ }
+ return null;
+ }
+
+ protected abstract Object evaluateState(Exchange exchange, ActivityState state);
+}
\ No newline at end of file
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamBuilder.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamBuilder.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamBuilder.java Tue May 15 00:14:51 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.Endpoint;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @version $Revision: $
+ */
+public class BamBuilder {
+
+ private List<Endpoint> endpoints = new ArrayList<Endpoint>();
+
+ public void endpoint(Endpoint endpoint) {
+ endpoints.add(endpoint);
+ }
+
+ public static BamBuilder monitor(RouteBuilder builder, String... uris) {
+ BamBuilder answer = new BamBuilder();
+
+ for (String uri : uris) {
+ Endpoint endpoint = builder.endpoint(uri);
+ answer.endpoint(endpoint);
+ }
+ return answer;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/BamProcessorSupport.java Tue May 15 00:14:51 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Processor;
+
+import java.lang.reflect.Type;
+import java.lang.reflect.ParameterizedType;
+
+/**
+ * A {@link Processor} for working on
+ * <a href="http://activemq.apache.org/camel/bam.html">BAM</a>
+ *
+ * @version $Revision: $
+ */
+public abstract class BamProcessorSupport<T> implements Processor {
+ private Class<T> entityType;
+ private Expression<Exchange> correlationKeyExpression;
+
+
+ protected BamProcessorSupport(Expression<Exchange> correlationKeyExpression) {
+ this.correlationKeyExpression = correlationKeyExpression;
+
+ Type type = getClass().getGenericSuperclass();
+ if (type instanceof ParameterizedType) {
+ ParameterizedType parameterizedType = (ParameterizedType) type;
+ Type[] arguments = parameterizedType.getActualTypeArguments();
+ if (arguments.length > 0) {
+ Type argumentType = arguments[0];
+ if (argumentType instanceof Class) {
+ this.entityType = (Class<T>) argumentType;
+ }
+ }
+ }
+ if (entityType == null) {
+ throw new IllegalArgumentException("Could not infer the entity type!");
+ }
+ }
+
+ protected BamProcessorSupport(Class<T> entitytype, Expression<Exchange> correlationKeyExpression) {
+ this.entityType = entitytype;
+ this.correlationKeyExpression = correlationKeyExpression;
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ Object key = getCorrelationKey(exchange);
+
+
+ T entity = loadEntity(exchange, key);
+ //storeProcessInExchange(exchange, entity);
+ processEntity(exchange, entity);
+ }
+
+ // Properties
+ //-----------------------------------------------------------------------
+ public Expression<Exchange> getCorrelationKeyExpression() {
+ return correlationKeyExpression;
+ }
+
+
+ public Class<T> getEntityType() {
+ return entityType;
+ }
+
+ // Implemenation methods
+ //-----------------------------------------------------------------------
+ protected abstract void processEntity(Exchange exchange, T entity) throws Exception;
+
+ protected abstract T loadEntity(Exchange exchange, Object key);
+
+
+ protected Object getCorrelationKey(Exchange exchange) throws NoCorrelationKeyException {
+ Object value = correlationKeyExpression.evaluate(exchange);
+ if (value == null) {
+ throw new NoCorrelationKeyException(this, exchange);
+ }
+ return value;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessor.java Tue May 15 00:14:51 2007
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.bam.model.*;
+import org.apache.camel.bam.model.ProcessInstance;
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.springframework.orm.jpa.JpaTemplate;
+
+/**
+ * @version $Revision: $
+ */
+public class JpaBamProcessor extends JpaBamProcessorSupport<ProcessInstance> {
+
+ public JpaBamProcessor(Class<ProcessInstance> entitytype, Expression<Exchange> correlationKeyExpression, Activity activity, JpaTemplate template) {
+ super(entitytype, correlationKeyExpression, activity, template);
+ }
+
+ public JpaBamProcessor(Expression<Exchange> correlationKeyExpression, Activity activity, JpaTemplate template) {
+ super(correlationKeyExpression, activity, template);
+ }
+
+ protected void processEntity(Exchange exchange, ProcessInstance process) throws Exception {
+ ActivityState state = process.getActivityState(getActivity());
+ if (state == null) {
+ state = createActivityState(exchange, process);
+ state.setProcess(process);
+ }
+ state.process(getActivity(), exchange);
+ }
+
+ protected ActivityState createActivityState(Exchange exchange, ProcessInstance process) {
+ return new ActivityState();
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/JpaBamProcessorSupport.java Tue May 15 00:14:51 2007
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+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.util.IntrospectionSupport;
+import org.springframework.orm.jpa.JpaTemplate;
+
+/**
+ * @version $Revision: $
+ */
+public class JpaBamProcessorSupport<T> extends BamProcessorSupport<T> {
+ private Activity activity;
+ private JpaTemplate template;
+ private String findByKeyQuery;
+ private String keyPropertyName = "key";
+
+ public JpaBamProcessorSupport(Class<T> entitytype, Expression<Exchange> correlationKeyExpression, Activity activity, JpaTemplate template) {
+ super(entitytype, correlationKeyExpression);
+ this.activity = activity;
+ this.template = template;
+ }
+
+ public JpaBamProcessorSupport(Expression<Exchange> correlationKeyExpression, Activity activity, JpaTemplate template) {
+ super(correlationKeyExpression);
+ this.activity = activity;
+ this.template = template;
+ }
+
+ public String getFindByKeyQuery() {
+ if (findByKeyQuery == null) {
+ findByKeyQuery = createFindByKeyQuery();
+ }
+ return findByKeyQuery;
+ }
+
+
+ public void setFindByKeyQuery(String findByKeyQuery) {
+ this.findByKeyQuery = findByKeyQuery;
+ }
+
+ public Activity getActivity() {
+ return activity;
+ }
+
+ public void setActivity(Activity activity) {
+ this.activity = activity;
+ }
+
+ public String getKeyPropertyName() {
+ return keyPropertyName;
+ }
+
+ public void setKeyPropertyName(String keyPropertyName) {
+ this.keyPropertyName = keyPropertyName;
+ }
+
+ public JpaTemplate getTemplate() {
+ return template;
+ }
+
+ public void setTemplate(JpaTemplate template) {
+ this.template = template;
+ }
+
+ // Implementatiom methods
+ //-----------------------------------------------------------------------
+ protected T loadEntity(Exchange exchange, Object key) {
+ T entity = (T) template.find(getFindByKeyQuery(), key);
+ if (entity == null) {
+ entity = createEntity(exchange, key);
+ setKeyProperty(entity, key);
+ }
+ return entity;
+ }
+
+ /**
+ * Sets the key property on the new entity
+ */
+ protected void setKeyProperty(T entity, Object key) {
+ IntrospectionSupport.setProperty(entity, getKeyPropertyName(), key);
+ }
+
+ /**
+ * Create a new instance of the entity for the given key
+ */
+ protected T createEntity(Exchange exchange, Object key) {
+ return (T) exchange.getContext().getInjector().newInstance(getEntityType());
+ }
+
+ protected void processEntity(Exchange exchange, T entity) throws Exception {
+ if (entity instanceof Processor) {
+ Processor processor = (Processor) entity;
+ processor.process(exchange);
+ }
+ else {
+ // TODO add other extension points - eg. passing in Activity
+ throw new IllegalArgumentException("No processor defined for this route");
+ }
+ }
+
+ protected String createFindByKeyQuery() {
+ return "select x from " + getEntityType().getName() + " where x." + getKeyPropertyName() + " = ?1";
+ }
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/NoCorrelationKeyException.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/NoCorrelationKeyException.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/NoCorrelationKeyException.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/NoCorrelationKeyException.java Tue May 15 00:14:51 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.CamelException;
+import org.apache.camel.Exchange;
+
+/**
+ * An exception thrown if no correlation key could be found for a message
+ * exchange preventing any particular orchestration or
+ * <a href="http://activemq.apache.org/camel/bam.html">BAM</a>
+ *
+ * @version $Revision: $
+ */
+public class NoCorrelationKeyException extends CamelException {
+ private BamProcessorSupport processor;
+ private Exchange exchange;
+
+ public NoCorrelationKeyException(BamProcessorSupport processor, Exchange exchange) {
+ super("No correlation key could be found for " + processor.getCorrelationKeyExpression()
+ + " on " + exchange);
+
+ this.processor = processor;
+ this.exchange = exchange;
+ }
+
+
+ public Exchange getExchange() {
+ return exchange;
+ }
+
+ public BamProcessorSupport getProcessor() {
+ return processor;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessBuilder.java Tue May 15 00:14:51 2007
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.springframework.orm.jpa.JpaTemplate;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A builder of a process definition
+ *
+ * @version $Revision: $
+ */
+public abstract class ProcessBuilder extends RouteBuilder {
+ private List<ActivityBuilder> activityBuilders = new ArrayList<ActivityBuilder>();
+ private Class entityType = Process.class;
+ private JpaTemplate jpaTemplate;
+ private ProcessDefinition process = new ProcessDefinition();
+
+ public ActivityBuilder activity(String endpointUri) {
+ return activity(endpoint(endpointUri));
+ }
+
+ public ActivityBuilder activity(Endpoint endpoint) {
+ ActivityBuilder answer = new ActivityBuilder(this, endpoint);
+ activityBuilders.add(answer);
+ return answer;
+ }
+
+ /**
+ * Sets the process entity type used to perform state management
+ */
+ public ProcessBuilder entityType(Class entityType) {
+ this.entityType = entityType;
+ return this;
+ }
+
+
+ public Processor createActivityProcessor(ActivityBuilder activityBuilder) {
+ return new JpaBamProcessor(getEntityType(), activityBuilder.getCorrelationExpression(), activityBuilder.getActivity(), getJpaTemplate());
+ }
+
+ // Properties
+ //-----------------------------------------------------------------------
+ public List<ActivityBuilder> getActivityBuilders() {
+ return activityBuilders;
+ }
+
+ public Class getEntityType() {
+ return entityType;
+ }
+
+
+ public JpaTemplate getJpaTemplate() {
+ return jpaTemplate;
+ }
+
+ public void setJpaTemplate(JpaTemplate jpaTemplate) {
+ this.jpaTemplate = jpaTemplate;
+ }
+
+
+ public ProcessDefinition getProcess() {
+ return process;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessDefinition.java Tue May 15 00:14:51 2007
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.bam.model.Activity;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * @version $Revision: $
+ */
+public class ProcessDefinition {
+ private Map<String, Activity> activitys = new HashMap<String, Activity>();
+
+
+
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessExpressionSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessExpressionSupport.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessExpressionSupport.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/ProcessExpressionSupport.java Tue May 15 00:14:51 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+
+/**
+ * @version $Revision: $
+ */
+public abstract class ProcessExpressionSupport<T> implements Expression<Exchange> {
+
+ public static final String PROCESS_PROPERTY = "org.apache.camel.bam.Process";
+
+ private Class<T> type;
+
+ protected ProcessExpressionSupport(Class<T> type) {
+ this.type = type;
+ }
+
+ public static <T> T getProcessEntity(Exchange exchange, Class<T> type) {
+ return exchange.getProperty(PROCESS_PROPERTY, type);
+ }
+
+ public static <T> void storeProcessEntity(Exchange exchange, T processEntity) {
+ exchange.setProperty(PROCESS_PROPERTY, processEntity);
+ }
+
+ public Object evaluate(Exchange exchange) {
+ T processEntity = getProcessEntity(exchange, type);
+ return evaluate(exchange, processEntity);
+ }
+
+ protected abstract Object evaluate(Exchange exchange, T processEntity);
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalBuilder.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalBuilder.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalBuilder.java Tue May 15 00:14:51 2007
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+/**
+ * @version $Revision: $
+ */
+public class TemporalBuilder {
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalRule.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalRule.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalRule.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TemporalRule.java Tue May 15 00:14:51 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.util.Time;
+
+/**
+ * A temporal rule
+ *
+ * @version $Revision: $
+ */
+public class TemporalRule {
+ private TimeExpression first;
+ private TimeExpression second;
+ private Time gap;
+
+ public TemporalRule(TimeExpression left, TimeExpression right) {
+ this.first = left;
+ this.second = right;
+ }
+
+ /*
+ public void process(Exchange exchange) {
+ Time firstTime = evaluateTime(exchange);
+ if (firstTime == null) {
+ // TODO add test that if second happes first
+ return;
+ }
+ Time secondTime = evaluateTime(exchange);
+ if (secondTime == null) {
+ // TODO add test that things have expired
+
+ }
+ else {
+ if (secondTime.delta(firstTime.plus(gap)) > 0) {
+ // TODO
+ }
+ }
+ }
+ */
+
+ public TemporalRule expectWithin(Time time) {
+ return this;
+ }
+
+ public TemporalRule errorIfOver(Time time) {
+ // TODO
+ return this;
+ }
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeBuilder.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeBuilder.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeBuilder.java Tue May 15 00:14:51 2007
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * A fluent builder of times
+ *
+ * @version $Revision: $
+ */
+public class TimeBuilder {
+ private long number;
+ private TimeUnit timeUnit = TimeUnit.MILLISECONDS;
+ private boolean configuredTime;
+
+ /**
+ * Creates a time which by default is in milliseconds unless
+ * specified using a time based builder method
+ */
+ public static TimeBuilder time(long number) {
+ return new TimeBuilder(number);
+ }
+
+ public TimeBuilder(long number) {
+ this.number = number;
+ }
+
+ public long toMillis() {
+ return timeUnit.toMillis(number);
+ }
+
+ public TimeBuilder millis() {
+ setTimeUnit(TimeUnit.MILLISECONDS);
+ return this;
+ }
+
+ public TimeBuilder nanos() {
+ setTimeUnit(TimeUnit.NANOSECONDS);
+ return this;
+ }
+
+ public TimeBuilder micros() {
+ setTimeUnit(TimeUnit.MICROSECONDS);
+ return this;
+ }
+
+ public TimeBuilder seconds() {
+ setTimeUnit(TimeUnit.SECONDS);
+ return this;
+ }
+
+ public TimeBuilder minutes() {
+ setTimeUnit(TimeUnit.SECONDS);
+ number = minutesAsSeconds(number);
+ return this;
+ }
+
+ public TimeBuilder hours() {
+ setTimeUnit(TimeUnit.SECONDS);
+ number = hoursAsSeconds(number);
+ return this;
+ }
+
+ public TimeBuilder days() {
+ setTimeUnit(TimeUnit.SECONDS);
+ number = daysAsSeconds(number);
+ return this;
+ }
+
+ public long getNumber() {
+ return number;
+ }
+
+ public TimeUnit getTimeUnit() {
+ return timeUnit;
+ }
+
+ public void setTimeUnit(TimeUnit timeUnit) {
+ if (configuredTime) {
+ throw new IllegalArgumentException("Cannot configure the time unit twice!");
+ }
+ else {
+ configuredTime = true;
+ }
+ this.timeUnit = timeUnit;
+ }
+
+ protected long minutesAsSeconds(long value) {
+ return value * 60;
+ }
+
+ protected long hoursAsSeconds(long value) {
+ return minutesAsSeconds(value) * 60;
+ }
+
+ protected long daysAsSeconds(long value) {
+ return hoursAsSeconds(value) * 24;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimeExpression.java Tue May 15 00:14:51 2007
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.bam.model.Activity;
+
+/**
+ *
+ * @version $Revision: $
+ */
+public class TimeExpression implements Expression<Exchange> {
+
+ private Activity activity;
+ private Expression expression;
+
+
+ public TimeExpression(Activity activity, Expression expression) {
+ this.activity = activity;
+ this.expression = expression;
+ }
+
+
+ public Object evaluate(Exchange exchange) {
+ return expression.evaluate(exchange);
+ }
+
+ /**
+ * Creates a new temporal rule on this expression and the other expression
+ */
+ public TemporalRule after(TimeExpression expression) {
+ return new TemporalRule(this, expression);
+ }
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEngine.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEngine.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEngine.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/TimerEngine.java Tue May 15 00:14:51 2007
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.bam.model.TimerEvent;
+import org.apache.camel.impl.ServiceSupport;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.orm.jpa.JpaCallback;
+import org.springframework.orm.jpa.JpaTemplate;
+
+import javax.persistence.EntityManager;
+import javax.persistence.LockModeType;
+import javax.persistence.PersistenceException;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * @version $Revision: $
+ */
+public class TimerEngine extends ServiceSupport implements Runnable {
+ private static final Log log = LogFactory.getLog(TimerEngine.class);
+
+ private JpaTemplate template;
+ private ExecutorService executor;
+ private long windowMillis = 1000L;
+ private Thread thread;
+
+ public void run() {
+ while (!isStopped()) {
+ long nextPoll = System.currentTimeMillis() + windowMillis;
+
+ Date window = new Date(nextPoll);
+ List<TimerEvent> list = template.find("select x from " + TimerEvent.class.getName() + " where x.time < ?1 order by x.time", window);
+ for (TimerEvent event : list) {
+ fireEvent(event);
+ }
+
+ long timeToSleep = nextPoll - System.currentTimeMillis();
+ if (timeToSleep > 0) {
+ log.debug("Sleeping for " + timeToSleep + " millis");
+ try {
+ Thread.sleep(timeToSleep);
+ }
+ catch (InterruptedException e) {
+ log.debug("Caught: " + e, e);
+ }
+ }
+ }
+ }
+
+ protected void fireEvent(final TimerEvent event) {
+ // lets try lock the object first
+
+ template.execute(new JpaCallback() {
+ public Object doInJpa(EntityManager entityManager) throws PersistenceException {
+ entityManager.lock(event, LockModeType.WRITE);
+ event.fire();
+ entityManager.remove(event);
+ return null;
+ }
+ });
+
+ }
+
+ protected void doStart() throws Exception {
+ thread = new Thread(this, "TimerEngine");
+ thread.start();
+ }
+
+ protected void doStop() throws Exception {
+ if (thread != null) {
+ thread = null;
+ }
+ }
+}
Added: 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/model/Activity.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/Activity.java Tue May 15 00:14:51 2007
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.bam.ProcessDefinition;
+
+import javax.persistence.Entity;
+import javax.persistence.NamedQuery;
+
+/**
+ * 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 int expectedMessages = 1;
+ private String name;
+ private ProcessDefinition process;
+
+ public Activity(ProcessDefinition process) {
+ this.process = process;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getExpectedMessages() {
+ return expectedMessages;
+ }
+
+ public void setExpectedMessages(int expectedMessages) {
+ this.expectedMessages = expectedMessages;
+ }
+
+ /**
+ * Perform any assertions after the state has been updated
+ */
+ public void process(ActivityState activityState, Exchange exchange) {
+ // TODO
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ActivityState.java Tue May 15 00:14:51 2007
@@ -0,0 +1,131 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.util.ObjectHelper;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+
+/**
+ * The default state for a specific activity within a process
+ *
+ * @version $Revision: $
+ */
+@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 {
+ int messageCount = getReceivedMessageCount() + 1;
+ setReceivedMessageCount(messageCount);
+
+ if (messageCount == 1) {
+ onFirstMessage(exchange);
+ }
+ int expectedMessages = activity.getExpectedMessages();
+ if (messageCount == expectedMessages) {
+ onExpectedMessage(exchange);
+ }
+ else if (messageCount > expectedMessages) {
+ onExcessMessage(exchange);
+ }
+
+ // now lets fire any assertions on the activity
+ activity.process(this, exchange);
+ }
+
+ /**
+ * Returns true if this state is for the given activity
+ */
+ public boolean isActivity(Activity activity) {
+ return ObjectHelper.equals(getActivityName(), activity.getName());
+ }
+
+ /**
+ * Invoked by the timer firing
+ */
+ public void onTimerEvent(TimerEvent event) {
+ // TODO do check on this entity
+ }
+
+ // Properties
+ //-----------------------------------------------------------------------
+ public ProcessInstance getProcess() {
+ return process;
+ }
+
+ public void setProcess(ProcessInstance process) {
+ this.process = process;
+ process.getActivityStates().add(this);
+ }
+
+ public String getActivityName() {
+ return activityName;
+ }
+
+ public void setActivityName(String activityName) {
+ this.activityName = activityName;
+ }
+
+ public int getReceivedMessageCount() {
+ return receivedMessageCount;
+ }
+
+ public void setReceivedMessageCount(int receivedMessageCount) {
+ this.receivedMessageCount = receivedMessageCount;
+ }
+
+ // Implementation methods
+ //-----------------------------------------------------------------------
+
+
+ /**
+ * Called when the first message is reached
+ */
+ protected void onFirstMessage(Exchange exchange) {
+ setTimeStarted(currentTime());
+ }
+
+ /**
+ * Called when the expected number of messages are is reached
+ */
+ protected void onExpectedMessage(Exchange exchange) {
+ setTimeCompleted(currentTime());
+ setCompleted(true);
+ }
+
+ /**
+ * Called when an excess message (after the expected number of messages)
+ * are received
+ */
+ protected void onExcessMessage(Exchange exchange) {
+ // TODO
+ }
+
+ protected long currentTime() {
+ return System.currentTimeMillis();
+ }
+
+}
\ No newline at end of file
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/EntitySupport.java Tue May 15 00:14:51 2007
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import javax.persistence.*;
+
+/**
+ * A base class for persistent entities
+ *
+ * @version $Revision: $
+ */
+public class EntitySupport {
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String toString() {
+ return getClass().getName() + "[" + id + "]";
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/ProcessInstance.java Tue May 15 00:14:51 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.OneToMany;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Represents a single business process
+ *
+ * @version $Revision: $
+ */
+@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;
+
+
+ /**
+ * Returns the activity state for the given activity
+ *
+ * @param activity the activity to find the state for
+ * @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) {
+ if (activityState.isActivity(activity)) {
+ return activityState;
+ }
+ }
+ return null;
+ }
+
+ public Set<ActivityState> getActivityStates() {
+ return activityStates;
+ }
+
+ public void setActivityStates(Set<ActivityState> activityStates) {
+ this.activityStates = activityStates;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+}
Added: activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TemporalEntity.java Tue May 15 00:14:51 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import static org.apache.camel.util.Time.millis;
+import org.apache.camel.util.Time;
+
+/**
+ * @version $Revision: $
+ */
+public abstract class TemporalEntity extends EntitySupport{
+ private long timeStarted;
+ private long timeCompleted;
+ private boolean completed;
+
+ public boolean isCompleted() {
+ return completed;
+ }
+
+ public void setCompleted(boolean completed) {
+ this.completed = completed;
+ }
+
+ public long getTimeCompleted() {
+ return timeCompleted;
+ }
+
+ public void setTimeCompleted(long timeCompleted) {
+ this.timeCompleted = timeCompleted;
+ }
+
+ public long getTimeStarted() {
+ return timeStarted;
+ }
+
+ public void setTimeStarted(long timeStarted) {
+ this.timeStarted = timeStarted;
+ }
+
+ public Time getStartTime() {
+ long value = getTimeStarted();
+ if (value > 0) {
+ return millis(value);
+ }
+ return null;
+ }
+
+ public Time getCompleteTime() {
+ long value = getTimeCompleted();
+ if (value > 0) {
+ return millis(value);
+ }
+ return null;
+ }
+}
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEvent.java Tue May 15 00:14:51 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+import javax.persistence.Entity;
+import javax.persistence.ManyToOne;
+import javax.persistence.FetchType;
+import javax.persistence.CascadeType;
+import java.util.Date;
+
+/**
+ * Represents a persistent timer event
+ *
+ * @version $Revision: $
+ */
+@Entity
+public class TimerEvent extends EntitySupport {
+ private Date time;
+
+ @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
+ private TimerEventHandler handler;
+
+ public Date getTime() {
+ return time;
+ }
+
+ public void setTime(Date time) {
+ this.time = time;
+ }
+
+
+ public TimerEventHandler getHandler() {
+ return handler;
+ }
+
+ public void setHandler(TimerEventHandler handler) {
+ this.handler = handler;
+ }
+
+ public void fire() {
+ getHandler().onTimerEvent(this);
+ }
+}
Added: 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/model/TimerEventHandler.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java (added)
+++ activemq/camel/trunk/camel-bam/src/main/java/org/apache/camel/bam/model/TimerEventHandler.java Tue May 15 00:14:51 2007
@@ -0,0 +1,25 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam.model;
+
+/**
+ * @version $Revision: $
+ */
+public interface TimerEventHandler {
+
+ void onTimerEvent(TimerEvent event);
+}
\ No newline at end of file
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java (added)
+++ activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java Tue May 15 00:14:51 2007
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import static org.apache.camel.builder.xml.XPathBuilder.xpath;
+import static org.apache.camel.util.Time.*;
+
+/**
+ * @version $Revision: $
+ */
+public class BamRouteTest extends ContextTestSupport {
+ protected Object body = "<hello>world!</hello>";
+
+ public void testRoute() throws Exception {
+ template.sendBody("direct:start", body);
+ }
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new ProcessBuilder() {
+ public void configure() throws Exception {
+
+ ActivityBuilder a = activity("direct:a").name("a")
+ .correlate(header("foo"));
+
+ ActivityBuilder b = activity("direct:b").name("b")
+ .correlate(header("foo"));
+
+ ActivityBuilder c = activity("direct:c").name("c")
+ .correlate(xpath("/foo/bar"));
+
+
+ b.starts().after(a.completes())
+ .expectWithin(seconds(1))
+ .errorIfOver(seconds(5));
+
+ // TODO .errorIfBefore(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: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);
+
+ bam.expects("direct:c").expectedMesageCount(1)
+ .expectedAfter().minutes(10)
+ .errorAfter().minutes(30);
+
+ */
+ }
+ };
+ }
+}
Added: activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/TimerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/TimerTest.java?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/TimerTest.java (added)
+++ activemq/camel/trunk/camel-bam/src/test/java/org/apache/camel/bam/TimerTest.java Tue May 15 00:14:51 2007
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.bam;
+
+import org.apache.camel.ContextTestSupport;
+
+/**
+ * @version $Revision: $
+ */
+public class TimerTest extends ContextTestSupport {
+
+ public void testTimers() throws Exception {
+
+ }
+
+}
Added: activemq/camel/trunk/camel-bam/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-bam/src/test/resources/META-INF/persistence.xml?view=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/resources/META-INF/persistence.xml (added)
+++ activemq/camel/trunk/camel-bam/src/test/resources/META-INF/persistence.xml Tue May 15 00:14:51 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ version="1.0">
+
+ <persistence-unit name="bam" transaction-type="RESOURCE_LOCAL">
+ <class>org.apache.camel.bam.model.ActivityState</class>
+ <class>org.apache.camel.bam.model.ProcessInstance</class>
+ <class>org.apache.camel.bam.model.TimerEvent</class>
+
+ <properties>
+ <property name="openjpa.ConnectionURL" value="jdbc:derby:target/idempotentTest;create=true"/>
+ <property name="openjpa.ConnectionDriverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+ <property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
+ <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
+ </properties>
+ </persistence-unit>
+</persistence>
Added: 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=auto&rev=538073
==============================================================================
--- activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties (added)
+++ activemq/camel/trunk/camel-bam/src/test/resources/log4j.properties Tue May 15 00:14:51 2007
@@ -0,0 +1,30 @@
+## ------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ------------------------------------------------------------------------
+
+#
+# The logging properties used for eclipse testing, We want to see debug output on the console.
+#
+log4j.rootLogger=INFO, out
+
+#log4j.logger.org.apache.activemq=DEBUG
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n