Author: jstrachan
Date: Wed Dec 12 15:03:46 2007
New Revision: 603768
URL: http://svn.apache.org/viewvc?rev=603768&view=rev
Log:
minor patch to allow a flush on a send, and expose the entity beans on the
exchange
Modified:
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
Modified:
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java?rev=603768&r1=603767&r2=603768&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
(original)
+++
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaEndpoint.java
Wed Dec 12 15:03:46 2007
@@ -48,6 +48,7 @@
private Map entityManagerProperties;
private boolean consumeDelete = true;
private boolean consumeLockEntity = true;
+ private boolean flushOnSend = true;
public JpaEndpoint(String uri, JpaComponent component) {
super(uri, component);
@@ -161,6 +162,14 @@
public void setConsumeLockEntity(boolean consumeLockEntity) {
this.consumeLockEntity = consumeLockEntity;
+ }
+
+ public boolean isFlushOnSend() {
+ return flushOnSend;
+ }
+
+ public void setFlushOnSend(boolean flushOnSend) {
+ this.flushOnSend = flushOnSend;
}
// Implementation methods
Modified:
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
URL:
http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java?rev=603768&r1=603767&r2=603768&view=diff
==============================================================================
---
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
(original)
+++
activemq/camel/trunk/components/camel-jpa/src/main/java/org/apache/camel/component/jpa/JpaProducer.java
Wed Dec 12 15:03:46 2007
@@ -33,10 +33,12 @@
*/
public class JpaProducer extends DefaultProducer<Exchange> {
private final TransactionStrategy template;
+ private final JpaEndpoint endpoint;
private final Expression<Exchange> expression;
public JpaProducer(JpaEndpoint endpoint, Expression<Exchange> expression) {
super(endpoint);
+ this.endpoint = endpoint;
this.expression = expression;
this.template = endpoint.createTransactionStrategy();
}
@@ -51,9 +53,13 @@
Object value = iter.next();
entityManager.persist(value);
}
+ if (endpoint.isFlushOnSend()) {
+ entityManager.flush();
+ }
return null;
}
});
}
+ exchange.setProperty("CamelJpaValue", values);
}
}