You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/03/24 16:08:42 UTC
svn commit: r640438 [8/8] - in /activemq/camel/trunk:
camel-core/src/main/java/org/apache/camel/
camel-core/src/main/java/org/apache/camel/builder/
camel-core/src/main/java/org/apache/camel/builder/xml/
camel-core/src/main/java/org/apache/camel/compone...
Modified: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java (original)
+++ activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/BamProcessorSupport.java Mon Mar 24 08:08:24 2008
@@ -16,6 +16,11 @@
*/
package org.apache.camel.bam.processor;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+
+import javax.persistence.EntityExistsException;
+
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Processor;
@@ -29,10 +34,6 @@
import org.springframework.transaction.support.TransactionCallback;
import org.springframework.transaction.support.TransactionTemplate;
-import javax.persistence.EntityExistsException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
/**
* A base {@link Processor} for working on <a
* href="http://activemq.apache.org/camel/bam.html">BAM</a> which a derived
@@ -48,26 +49,19 @@
private TransactionTemplate transactionTemplate;
private int maximumRetries = 30;
- public int getMaximumRetries() {
- return maximumRetries;
- }
-
- public void setMaximumRetries(int maximumRetries) {
- this.maximumRetries = maximumRetries;
- }
-
- protected BamProcessorSupport(TransactionTemplate transactionTemplate, Expression<Exchange> correlationKeyExpression) {
+ protected BamProcessorSupport(TransactionTemplate transactionTemplate,
+ Expression<Exchange> correlationKeyExpression) {
this.transactionTemplate = transactionTemplate;
this.correlationKeyExpression = correlationKeyExpression;
Type type = getClass().getGenericSuperclass();
if (type instanceof ParameterizedType) {
- ParameterizedType parameterizedType = (ParameterizedType) type;
+ 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;
+ this.entityType = (Class<T>)argumentType;
}
}
}
@@ -76,7 +70,8 @@
}
}
- protected BamProcessorSupport(TransactionTemplate transactionTemplate, Expression<Exchange> correlationKeyExpression, Class<T> entitytype) {
+ protected BamProcessorSupport(TransactionTemplate transactionTemplate,
+ Expression<Exchange> correlationKeyExpression, Class<T> entitytype) {
this.transactionTemplate = transactionTemplate;
this.entityType = entitytype;
this.correlationKeyExpression = correlationKeyExpression;
@@ -101,23 +96,24 @@
processEntity(exchange, entity);
return entity;
- }
- catch (JpaSystemException e) {
+ } catch (JpaSystemException e) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Likely exception is due to duplicate row in concurrent setting: " + e, e);
+ LOG.debug("Likely exception is due to duplicate row in concurrent setting: " + e,
+ e);
}
- LOG.info("Attempt to insert duplicate row due to concurrency issue, so retrying: " + e);
+ LOG.info("Attempt to insert duplicate row due to concurrency issue, so retrying: "
+ + e);
return retryDueToDuplicate(status);
- }
- catch (DataIntegrityViolationException e) {
+ } catch (DataIntegrityViolationException e) {
Throwable throwable = e.getCause();
if (throwable instanceof EntityExistsException) {
- LOG.info("Attempt to insert duplicate row due to concurrency issue, so retrying: " + throwable);
+ LOG
+ .info("Attempt to insert duplicate row due to concurrency issue, so retrying: "
+ + throwable);
return retryDueToDuplicate(status);
}
return onError(status, throwable);
- }
- catch (Throwable e) {
+ } catch (Throwable e) {
return onError(status, e);
}
}
@@ -125,6 +121,14 @@
}
}
+ public int getMaximumRetries() {
+ return maximumRetries;
+ }
+
+ public void setMaximumRetries(int maximumRetries) {
+ this.maximumRetries = maximumRetries;
+ }
+
// Properties
// -----------------------------------------------------------------------
public Expression<Exchange> getCorrelationKeyExpression() {
@@ -154,7 +158,6 @@
}
return value;
}
-
protected Object retryDueToDuplicate(TransactionStatus status) {
status.setRollbackOnly();
Modified: activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java (original)
+++ activemq/camel/trunk/components/camel-bam/src/main/java/org/apache/camel/bam/processor/JpaBamProcessorSupport.java Mon Mar 24 08:08:24 2008
@@ -16,6 +16,9 @@
*/
package org.apache.camel.bam.processor;
+import java.lang.reflect.Method;
+import java.util.List;
+
import org.apache.camel.Exchange;
import org.apache.camel.Expression;
import org.apache.camel.Processor;
@@ -27,9 +30,6 @@
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.transaction.support.TransactionTemplate;
-import java.util.List;
-import java.lang.reflect.Method;
-
/**
* A base class for JPA based BAM which can use any entity to store the process
* instance information which allows derived classes to specialise the process
@@ -39,20 +39,23 @@
*/
public class JpaBamProcessorSupport<T> extends BamProcessorSupport<T> {
private static final transient Log LOG = LogFactory.getLog(JpaBamProcessorSupport.class);
-
+
private ActivityRules activityRules;
private JpaTemplate template;
private String findByKeyQuery;
private String keyPropertyName = "correlationKey";
private boolean correlationKeyIsPrimary = true;
- public JpaBamProcessorSupport(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, ActivityRules activityRules, Class<T> entitytype) {
+ public JpaBamProcessorSupport(TransactionTemplate transactionTemplate, JpaTemplate template,
+ Expression<Exchange> correlationKeyExpression, ActivityRules activityRules,
+ Class<T> entitytype) {
super(transactionTemplate, correlationKeyExpression, entitytype);
this.activityRules = activityRules;
this.template = template;
}
- public JpaBamProcessorSupport(TransactionTemplate transactionTemplate, JpaTemplate template, Expression<Exchange> correlationKeyExpression, ActivityRules activityRules) {
+ public JpaBamProcessorSupport(TransactionTemplate transactionTemplate, JpaTemplate template,
+ Expression<Exchange> correlationKeyExpression, ActivityRules activityRules) {
super(transactionTemplate, correlationKeyExpression);
this.activityRules = activityRules;
this.template = template;
@@ -108,11 +111,14 @@
if (entity == null) {
entity = createEntity(exchange, key);
setKeyProperty(entity, key);
- ProcessDefinition definition = ProcessDefinition.getRefreshedProcessDefinition(template, getActivityRules().getProcessRules().getProcessDefinition());
+ ProcessDefinition definition = ProcessDefinition
+ .getRefreshedProcessDefinition(template, getActivityRules().getProcessRules()
+ .getProcessDefinition());
setProcessDefinitionProperty(entity, definition);
template.persist(entity);
- // Now we must flush to avoid concurrent updates clashing trying to insert the
+ // Now we must flush to avoid concurrent updates clashing trying to
+ // insert the
// same row
LOG.debug("About to flush on entity: " + entity + " with key: " + key);
template.flush();
@@ -123,13 +129,11 @@
protected T findEntityByCorrelationKey(Object key) {
if (isCorrelationKeyIsPrimary()) {
return template.find(getEntityType(), key);
- }
- else {
+ } else {
List<T> list = template.find(getFindByKeyQuery(), key);
if (list.isEmpty()) {
return null;
- }
- else {
+ } else {
return list.get(0);
}
}
@@ -139,12 +143,13 @@
try {
Method getter = IntrospectionSupport.getPropertyGetter(getEntityType(), getKeyPropertyName());
return getter.getReturnType();
- }
- catch (NoSuchMethodException e) {
- LOG.warn("no such getter for: " + getKeyPropertyName() + " on " + getEntityType() + ". Reason: " + e, e);
+ } catch (NoSuchMethodException e) {
+ LOG.warn("no such getter for: " + getKeyPropertyName() + " on " + getEntityType() + ". Reason: "
+ + e, e);
return null;
}
}
+
/**
* Sets the key property on the new entity
*/
@@ -152,7 +157,8 @@
IntrospectionSupport.setProperty(entity, getKeyPropertyName(), key);
}
- protected void setProcessDefinitionProperty(T entity, ProcessDefinition processDefinition) throws Exception {
+ protected void setProcessDefinitionProperty(T entity, ProcessDefinition processDefinition)
+ throws Exception {
IntrospectionSupport.setProperty(entity, "processDefinition", processDefinition);
}
@@ -160,15 +166,14 @@
* 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());
+ 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 processor = (Processor)entity;
processor.process(exchange);
- }
- else {
+ } else {
// TODO add other extension points - eg. passing in Activity
throw new IllegalArgumentException("No processor defined for this route");
}
Modified: activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/BamRouteTest.java Mon Mar 24 08:08:24 2008
@@ -16,14 +16,17 @@
*/
package org.apache.camel.bam;
+
import org.apache.camel.builder.RouteBuilder;
-import static org.apache.camel.builder.xml.XPathBuilder.xpath;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.spring.SpringTestSupport;
-import static org.apache.camel.util.Time.seconds;
+
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.transaction.support.TransactionTemplate;
+
+import static org.apache.camel.builder.xml.XPathBuilder.xpath;
+import static org.apache.camel.util.Time.seconds;
/**
* @version $Revision$
Modified: activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleActivitiesConcurrentlyTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleActivitiesConcurrentlyTest.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleActivitiesConcurrentlyTest.java (original)
+++ activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleActivitiesConcurrentlyTest.java Mon Mar 24 08:08:24 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -17,9 +16,8 @@
*/
package org.apache.camel.bam;
-import static org.apache.camel.language.juel.JuelExpression.el;
-
import java.util.concurrent.CountDownLatch;
+import static org.apache.camel.language.juel.JuelExpression.el;
/**
* @version $Revision$
@@ -48,14 +46,14 @@
sendAMessages();
endLatch.await();
-
+
overdueEndpoint.assertIsSatisfied();
}
@Override
protected void setUp() throws Exception {
errorTimeout = 5;
-
+
super.setUp();
}
}
Modified: activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleProcessesTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleProcessesTest.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleProcessesTest.java (original)
+++ activemq/camel/trunk/components/camel-bam/src/test/java/org/apache/camel/bam/MultipleProcessesTest.java Mon Mar 24 08:08:24 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java (original)
+++ activemq/camel/trunk/components/camel-csv/src/main/java/org/apache/camel/dataformat/csv/CsvDataFormat.java Mon Mar 24 08:08:24 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
@@ -60,8 +59,7 @@
CSVWriter writer = new CSVWriter(conf);
writer.setWriter(out);
writer.writeRecord(map);
- }
- finally {
+ } finally {
out.close();
}
}
@@ -81,12 +79,10 @@
}
if (list.size() == 1) {
return list.get(0);
- }
- else {
+ } else {
return list;
}
- }
- finally {
+ } finally {
in.close();
}
}
Modified: activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java (original)
+++ activemq/camel/trunk/components/camel-csv/src/test/java/org/apache/camel/dataformat/csv/CsvRouteTest.java Mon Mar 24 08:08:24 2008
@@ -1,5 +1,4 @@
/**
- *
* 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.
@@ -7,7 +6,7 @@
* (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
+ * 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,
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfCustmerizedExceptionTest.java Mon Mar 24 08:08:24 2008
@@ -40,11 +40,11 @@
protected static final String ROUTER_ADDRESS = "http://localhost:9002/router";
protected static final String SERVICE_CLASS = "serviceClass=org.apache.camel.component.cxf.HelloService";
-
+ protected static String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS;
private static final String EXCEPTION_MESSAGE = "This is an exception test message";
private static final String DETAIL_TEXT = "This is a detail text node";
private static final SoapFault SOAP_FAULT;
- protected static String routerEndpointURI = "cxf://" + ROUTER_ADDRESS + "?" + SERVICE_CLASS;
+
private Bus bus;
Modified: activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsIssue170Test.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsIssue170Test.java?rev=640438&r1=640437&r2=640438&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsIssue170Test.java (original)
+++ activemq/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/issues/JmsIssue170Test.java Mon Mar 24 08:08:24 2008
@@ -31,7 +31,7 @@
public class JmsIssue170Test extends Issue170Test {
@Override
protected void setUp() throws Exception {
- Q1 = "activemq:Test.Q1";
+ qOne = "activemq:Test.Q1";
super.setUp();
}
@@ -48,14 +48,14 @@
protected RouteBuilder createRouteBuilder() {
return new RouteBuilder() {
public void configure() {
- from("direct:start").to(Q1);
+ from("direct:start").to(qOne);
// write to Q3 but not to Q2
- from(Q1).to("activemq:Test.Q2", "activemq:Test.Q3");
+ from(qOne).to("activemq:Test.Q2", "activemq:Test.Q3");
// subscribe from the JMS queues to send to the mocks for testing
- from("activemq:Test.Q2").to(Q2);
- from("activemq:Test.Q3").to(Q3);
+ from("activemq:Test.Q2").to(qTwo);
+ from("activemq:Test.Q3").to(qThree);
}
};
}