You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/03/05 15:02:41 UTC
svn commit: r514670 - in
/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi:
container/SpringJBIContainer.java messaging/DeliveryChannelImpl.java
Author: gnodet
Date: Mon Mar 5 06:02:40 2007
New Revision: 514670
URL: http://svn.apache.org/viewvc?view=rev&rev=514670
Log:
SM-865: Remove jta and j2ee-connector from the mandatory dependencies when running an embedded ServiceMix instance
Modified:
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
Modified: incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java?view=diff&rev=514670&r1=514669&r2=514670
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java (original)
+++ incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/container/SpringJBIContainer.java Mon Mar 5 06:02:40 2007
@@ -17,12 +17,9 @@
package org.apache.servicemix.jbi.container;
import javax.jbi.JBIException;
-import javax.resource.spi.work.WorkManager;
-import org.apache.geronimo.transaction.manager.GeronimoTransactionManager;
import org.apache.servicemix.components.util.ComponentAdaptor;
import org.apache.servicemix.jbi.framework.ComponentMBeanImpl;
-import org.jencks.factory.WorkManagerFactoryBean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
@@ -166,19 +163,6 @@
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
- }
-
- protected WorkManager createWorkManager() throws JBIException {
- WorkManagerFactoryBean factory = new WorkManagerFactoryBean();
- if (getTransactionManager() instanceof GeronimoTransactionManager) {
- factory.setTransactionManager((GeronimoTransactionManager) getTransactionManager());
- }
- try {
- return (WorkManager) factory.getObject();
- }
- catch (Exception e) {
- throw new JBIException("Failed to start WorkManager: " + e, e);
- }
}
public void destroy() throws Exception {
Modified: incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java?view=diff&rev=514670&r1=514669&r2=514670
==============================================================================
--- incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java (original)
+++ incubator/servicemix/branches/servicemix-3.1/core/servicemix-core/src/main/java/org/apache/servicemix/jbi/messaging/DeliveryChannelImpl.java Mon Mar 5 06:02:40 2007
@@ -72,6 +72,7 @@
private int intervalCount = 0;
private AtomicBoolean closed = new AtomicBoolean(false);
private Map waiters = new ConcurrentHashMap();
+ private TransactionManager transactionManager = null;
/**
* When using clustering and sendSync, the exchange received will not be the same
@@ -87,6 +88,7 @@
this.component = component;
this.container = component.getContainer();
this.queue = new ArrayBlockingQueue(component.getInboundQueueCapacity());
+ this.transactionManager = (TransactionManager) this.container.getTransactionManager();
}
/**
@@ -707,40 +709,38 @@
}
protected void suspendTx(MessageExchangeImpl me) {
- try {
- Transaction oldTx = me.getTransactionContext();
- if (oldTx != null) {
- TransactionManager tm = (TransactionManager) container.getTransactionManager();
- if (tm != null) {
+ if (transactionManager != null) {
+ try {
+ Transaction oldTx = me.getTransactionContext();
+ if (oldTx != null) {
if (log.isDebugEnabled()) {
log.debug("Suspending transaction for " + me.getExchangeId() + " in " + this);
}
- Transaction tx = tm.suspend();
+ Transaction tx = transactionManager.suspend();
if (tx != oldTx) {
throw new IllegalStateException("the transaction context set in the messageExchange is not bound to the current thread");
}
}
+ } catch (Exception e) {
+ log.info("Exchange " + me.getExchangeId() + " aborted due to transaction exception", e);
+ me.getPacket().setAborted(true);
}
- } catch (Exception e) {
- log.info("Exchange " + me.getExchangeId() + " aborted due to transaction exception", e);
- me.getPacket().setAborted(true);
}
}
protected void resumeTx(MessageExchangeImpl me) throws MessagingException {
- try {
- Transaction oldTx = me.getTransactionContext();
- if (oldTx != null) {
- TransactionManager tm = (TransactionManager) container.getTransactionManager();
- if (tm != null) {
+ if (transactionManager != null) {
+ try {
+ Transaction oldTx = me.getTransactionContext();
+ if (oldTx != null) {
if (log.isDebugEnabled()) {
log.debug("Resuming transaction for " + me.getExchangeId() + " in " + this);
}
- tm.resume(oldTx);
+ transactionManager.resume(oldTx);
}
+ } catch (Exception e) {
+ throw new MessagingException(e);
}
- } catch (Exception e) {
- throw new MessagingException(e);
}
}
@@ -751,24 +751,21 @@
* @throws MessagingException
*/
protected void autoEnlistInTx(MessageExchangeImpl me) throws MessagingException {
- try {
- if (container.isAutoEnlistInTransaction()) {
- TransactionManager tm = (TransactionManager) container.getTransactionManager();
- if (tm != null) {
- Transaction tx = tm.getTransaction();
- if (tx != null) {
- Object oldTx = me.getTransactionContext();
- if (oldTx == null) {
- me.setTransactionContext(tx);
- } else if (oldTx != tx) {
- throw new IllegalStateException(
- "the transaction context set in the messageExchange is not bound to the current thread");
- }
+ if (transactionManager != null && container.isAutoEnlistInTransaction()) {
+ try {
+ Transaction tx = transactionManager.getTransaction();
+ if (tx != null) {
+ Object oldTx = me.getTransactionContext();
+ if (oldTx == null) {
+ me.setTransactionContext(tx);
+ } else if (oldTx != tx) {
+ throw new IllegalStateException(
+ "the transaction context set in the messageExchange is not bound to the current thread");
}
}
+ } catch (Exception e) {
+ throw new MessagingException(e);
}
- } catch (Exception e) {
- throw new MessagingException(e);
}
}