You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by li...@apache.org on 2010/06/24 23:35:18 UTC
svn commit: r957723 - in /incubator/aries/sandbox/linsun/mds: ./ mds-impl/
mds-impl/src/main/java/org/apache/aries/mds/impl/
mds-impl/src/main/java/org/apache/aries/mds/impl/exception/
mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/ mds-i...
Author: linsun
Date: Thu Jun 24 21:35:17 2010
New Revision: 957723
URL: http://svn.apache.org/viewvc?rev=957723&view=rev
Log:
[message driven service] add in container managed transaction handling for message driven service
Added:
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java (with props)
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java (with props)
Modified:
incubator/aries/sandbox/linsun/mds/mds-impl/pom.xml
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/Activator.java
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/EndpointHandler.java
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/JmsEndpointFactory.java
incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/MDSContainerImpl.java
incubator/aries/sandbox/linsun/mds/mds-itest/pom.xml
incubator/aries/sandbox/linsun/mds/mds-itest/src/test/java/org/apache/aries/mds/itests/MessageDrivenTest.java
incubator/aries/sandbox/linsun/mds/mds-sample/src/main/resources/OSGI-INF/blueprint/config.xml
incubator/aries/sandbox/linsun/mds/pom.xml
Modified: incubator/aries/sandbox/linsun/mds/mds-impl/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/pom.xml?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/pom.xml (original)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/pom.xml Thu Jun 24 21:35:17 2010
@@ -35,7 +35,9 @@
org.apache.aries.mds.impl.Activator
</aries.osgi.activator>
<aries.osgi.export.pkg>
- org.apache.aries.mds.impl
+ org.apache.aries.mds.impl,
+ org.apache.aries.mds.impl.exception,
+ org.apache.aries.mds.impl.transaction
</aries.osgi.export.pkg>
<aries.osgi.import>
!org.apache.aries.mds.impl.*,
Modified: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/Activator.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/Activator.java?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/Activator.java (original)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/Activator.java Thu Jun 24 21:35:17 2010
@@ -22,6 +22,8 @@ import java.util.ArrayList;
import java.util.List;
import javax.resource.spi.ResourceAdapter;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
import org.apache.aries.mds.MDSContainer;
import org.osgi.framework.BundleActivator;
@@ -41,14 +43,16 @@ public class Activator implements Bundle
private ServiceTracker st;
private static BundleContext context;
public static final long DEFAULT_TIMEOUT = 30000;
- private List<ServiceTracker> srs;
+ private List<ServiceTracker> sts = new ArrayList<ServiceTracker>();;
+ private static TransactionSynchronizationRegistry tsr;
+ private static TransactionManager tm;
+ private static List<ServiceReference> srs = new ArrayList<ServiceReference>();
public void start(BundleContext context) throws Exception {
System.out.println("aries-mds-impl starts");
this.context = context;
- srs = new ArrayList<ServiceTracker>();
-
+
st = createServiceTracker();
st.open();
}
@@ -67,11 +71,46 @@ public class Activator implements Bundle
st.close();
}
- for (ServiceTracker st : srs) {
+ for (ServiceTracker st : sts) {
if (st != null) {
st.close();
}
}
+ for (ServiceReference sr : srs) {
+ if (sr != null) {
+ context.ungetService(sr);
+ }
+ }
+ }
+
+ public static TransactionManager getTransactionManager() {
+ if (tm == null) {
+ ServiceReference sr = context.getServiceReference(TransactionManager.class.getName());
+ if (sr == null) {
+ throw new NullPointerException("TransactionManager service is not avail, will not be able to do transaction for the MDB");
+ } else {
+ tm = (TransactionManager)context.getService(sr);
+ srs.add(sr);
+ }
+
+ }
+
+ return tm;
+ }
+
+ public static TransactionSynchronizationRegistry getTransactionSynchronizationRegistry() {
+ if (tsr == null) {
+ ServiceReference sr = context.getServiceReference(TransactionSynchronizationRegistry.class.getName());
+ if (sr == null) {
+ throw new NullPointerException("TransactionSynchronizationRegistry service is not avail, will not be able to do transaction for the MDB");
+ } else {
+ tsr = (TransactionSynchronizationRegistry)context.getService(sr);
+ srs.add(sr);
+ }
+
+ }
+
+ return tsr;
}
private class MessageListenerServiceTrackerCustomizer implements
@@ -132,7 +171,7 @@ public class Activator implements Bundle
tracker.open();
// add tracker to the list of trackers we close at tear down
- srs.add(tracker);
+ sts.add(tracker);
Object svc = type.cast(tracker.waitForService(timeout));
if (svc == null) {
throw new RuntimeException("Gave up waiting for service " + flt);
Modified: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/EndpointHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/EndpointHandler.java?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/EndpointHandler.java (original)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/EndpointHandler.java Thu Jun 24 21:35:17 2010
@@ -24,17 +24,61 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import javax.resource.ResourceException;
+import javax.resource.spi.ApplicationServerInternalException;
+import javax.resource.spi.UnavailableException;
import javax.resource.spi.endpoint.MessageEndpoint;
import javax.transaction.xa.XAResource;
+import org.apache.aries.mds.MDSContainer;
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+import org.apache.aries.mds.impl.transaction.TransactionPolicy;
+
+
public class EndpointHandler implements InvocationHandler, MessageEndpoint {
- private XAResource xaResource;
- private Object instance;
+ private static enum State {
+ /**
+ * The handler has been initialized and is ready for invocation
+ */
+ NONE,
+
+ /**
+ * The beforeDelivery method has been called, and the next method called must be a message delivery method
+ * or release.
+ */
+ BEFORE_CALLED,
+
+ /**
+ * The message delivery method has been called successfully, and the next method called must be
+ * another message delivery method, afterDelivery, or release.
+ */
+ METHOD_CALLED,
+
+ /**
+ * The message delivery threw a system exception, and the next method called must be afterDelivery
+ * or release. This state notified the afterDelivery method that the instance must be replaced with a new
+ * instance.
+ */
+ SYSTEM_EXCEPTION,
+
+ /**
+ * This message endpoint handler has been released and can no longer be used.
+ */
+ RELEASED
+ }
- public EndpointHandler(Object instance, XAResource xaResource) {
+ private final MDSContainerImpl container;
+ private final XAResource xaResource;
+ private final Object instance;
+ private final TransactionPolicy txPolicy;
+ private State state = State.NONE;
+
+ public EndpointHandler(MDSContainerImpl container, Object instance, XAResource xaResource, TransactionPolicy txPolicy) {
+ this.container = container;
this.instance = instance;
this.xaResource = xaResource;
+ this.txPolicy = txPolicy;
}
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
@@ -70,22 +114,120 @@ public class EndpointHandler implements
}
private Object deliverMessage(Method method, Object[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- return method.invoke(this.instance, args);
+
+ boolean callBeforeAfter = false;
+
+ // verify current state
+ switch (state) {
+ case NONE:
+ try {
+ beforeDelivery(method);
+ } catch (Exception e) {
+ // TODO throw (EJBException) new EJBException().initCause(e.getCause());
+ }
+ callBeforeAfter = true;
+ state = State.METHOD_CALLED;
+ break;
+ case BEFORE_CALLED:
+ state = State.METHOD_CALLED;
+ break;
+ case RELEASED:
+ throw new IllegalStateException("Message endpoint factory has been released");
+ case METHOD_CALLED:
+ case SYSTEM_EXCEPTION:
+ throw new IllegalStateException("The last message delivery must be completed with an afterDeliver before another message can be delivered");
+ }
+
+ Throwable throwable = null;
+ Object value = null;
+ try {
+ value = method.invoke(this.instance, args);
+ } finally {
+ // if the adapter is not using before/after, we must call afterDelivery to clean up
+ if (callBeforeAfter) {
+ try {
+ afterDelivery();
+ } catch (ApplicationServerInternalException e) {
+ throwable = throwable == null ? e.getCause() : throwable;
+ } catch (UnavailableException e) {
+ throwable = throwable == null ? e : throwable;
+ } catch (ResourceException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ return value;
}
public void afterDelivery() throws ResourceException {
- // TODO Auto-generated method stub
+ // verify current state
+ switch (state) {
+ case RELEASED:
+ throw new IllegalStateException("Message endpoint factory has been released");
+ case BEFORE_CALLED:
+ throw new IllegalStateException("Exactally one message must be delivered between beforeDelivery and afterDelivery");
+ case NONE:
+ throw new IllegalStateException("afterDelivery may only be called if message delivery began with a beforeDelivery call");
+ }
+
+
+ // call afterDelivery on the container
+ try {
+ container.afterDelivery(txPolicy);
+ } catch (SystemException se) {
+ Throwable throwable = (se.getRootCause() != null) ? se.getRootCause() : se;
+ throw new ApplicationServerInternalException(throwable);
+ }
+ boolean exceptionThrown = false;
+ try {
+ // TODO invoke after delivery actions
+ } catch (Exception se) {
+ exceptionThrown = true;
+
+ Throwable throwable = (se.getCause() != null) ? se.getCause() : se;
+ throwable.printStackTrace();
+ throw new ApplicationServerInternalException(throwable);
+ } finally {
+ /*if (state == State.SYSTEM_EXCEPTION) {
+ recreateInstance(exceptionThrown);
+ }*/
+ // we are now in the default NONE state
+ state = State.NONE;
+ }
}
- public void beforeDelivery(Method arg0) throws NoSuchMethodException,
+ public void beforeDelivery(Method method) throws NoSuchMethodException,
ResourceException {
- // TODO Auto-generated method stub
+ // verify current state
+ switch (state) {
+ case RELEASED:
+ throw new IllegalStateException("Message endpoint factory has been released");
+ case BEFORE_CALLED:
+ throw new IllegalStateException("beforeDelivery can not be called again until message is delivered and afterDelivery is called");
+ case METHOD_CALLED:
+ case SYSTEM_EXCEPTION:
+ throw new IllegalStateException("The last message delivery must be completed with an afterDeliver before beforeDeliver can be called again");
+ }
+ try {
+ container.beforeDelivery(method, xaResource, txPolicy);
+ } catch (SystemException se) {
+ Throwable throwable = (se.getRootCause() != null) ? se.getRootCause() : se;
+ throw new ApplicationServerInternalException(throwable);
+ }
+ // before completed successfully we are now ready to invoke bean
+ state = State.BEFORE_CALLED;
}
public void release() {
- // TODO Auto-generated method stub
+ if (state == State.RELEASED) return;
+ state = State.RELEASED;
+
+ // release actions
+
+ // free instance?
}
Modified: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/JmsEndpointFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/JmsEndpointFactory.java?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/JmsEndpointFactory.java (original)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/JmsEndpointFactory.java Thu Jun 24 21:35:17 2010
@@ -28,20 +28,50 @@ import javax.resource.spi.endpoint.Messa
import javax.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
+import org.apache.aries.mds.MDSContainer;
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+import org.apache.aries.mds.impl.transaction.TransactionPolicy;
+import org.apache.aries.mds.impl.transaction.TransactionPolicyFactory;
+import org.apache.aries.mds.impl.transaction.TransactionType;
-public class JmsEndpointFactory implements MessageEndpointFactory {
+public class JmsEndpointFactory implements MessageEndpointFactory {
+ private final MDSContainerImpl container;
private final XAResource xaResource;
private final Object instance;
private final Class[] interfaces;
private final ActivationSpec activationSpec;
+ private TransactionType tranType;
+ private TransactionPolicy tp;
- public JmsEndpointFactory(Object instance, XAResource xaResource, ActivationSpec activationSpec) {
+ public JmsEndpointFactory(MDSContainerImpl container, Object instance, XAResource xaResource, ActivationSpec activationSpec, String tranAttr, TransactionPolicyFactory tpf) {
+ this.container = container;
this.instance = instance;
this.xaResource = xaResource;
interfaces = new Class[]{MessageListener.class, MessageEndpoint.class};
this.activationSpec = activationSpec;
+
+ if (tranAttr != null) {
+ this.tranType = TransactionType.get(tranAttr);
+ }
+
+ // default transaction attribute is not supported, container managed
+ if (this.tranType == null) {
+ this.tranType = TransactionType.NotSupported;
+ }
+
+ try {
+ this.tp = tpf.createTransactionPolicy(this.tranType);
+ } catch (SystemException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ApplicationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
}
public ActivationSpec getActivationSpec() {
@@ -49,7 +79,8 @@ public class JmsEndpointFactory implemen
}
public MessageEndpoint createEndpoint(XAResource xaResource) throws UnavailableException {
- EndpointHandler endpointHandler = new EndpointHandler(instance, xaResource);
+
+ EndpointHandler endpointHandler = new EndpointHandler(container, instance, xaResource, this.tp);
//ClassLoader cl = instance.getClass().getClassLoader();
ClassLoader cl = JmsEndpointFactory.class.getClassLoader();
MessageEndpoint messageEndpoint = (MessageEndpoint) Proxy.newProxyInstance(cl, interfaces, endpointHandler);
@@ -57,7 +88,7 @@ public class JmsEndpointFactory implemen
}
public boolean isDeliveryTransacted(Method method) throws NoSuchMethodException {
- return false;
+ return TransactionType.Required == this.tranType;
}
}
Modified: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/MDSContainerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/MDSContainerImpl.java?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/MDSContainerImpl.java (original)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/MDSContainerImpl.java Thu Jun 24 21:35:17 2010
@@ -18,14 +18,23 @@
*/
package org.apache.aries.mds.impl;
+import java.lang.reflect.Method;
+
import javax.jms.MessageListener;
import javax.resource.ResourceException;
import javax.resource.spi.ActivationSpec;
import javax.resource.spi.InvalidPropertyException;
import javax.resource.spi.ResourceAdapter;
import javax.resource.spi.endpoint.MessageEndpointFactory;
+import javax.transaction.xa.XAResource;
import org.apache.aries.mds.MDSContainer;
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+import org.apache.aries.mds.impl.transaction.JtaTransactionPolicyFactory;
+import org.apache.aries.mds.impl.transaction.TransactionPolicy;
+import org.apache.aries.mds.impl.transaction.TransactionPolicyFactory;
+import org.apache.aries.mds.impl.transaction.TransactionType;
import org.apache.xbean.recipe.ObjectRecipe;
import org.apache.xbean.recipe.Option;
import org.osgi.framework.BundleContext;
@@ -37,11 +46,13 @@ public class MDSContainerImpl implements
private final BundleContext bc;
private ActivationSpec activationSpec;
private MessageEndpointFactory endpointFactory;
+ private TransactionPolicyFactory tpf;
public MDSContainerImpl(ResourceAdapter ra, ServiceReference sr, BundleContext bc) {
this.ra = ra;
this.sr = sr;
this.bc = bc;
+ this.tpf = new JtaTransactionPolicyFactory(Activator.getTransactionManager(), Activator.getTransactionSynchronizationRegistry());
}
public void init() {
@@ -75,7 +86,10 @@ public class MDSContainerImpl implements
MessageListener ml = (MessageListener)bc.getService(sr);
// create the message endpoint
- endpointFactory = new JmsEndpointFactory(ml, null, activationSpec);
+ // obtain transaction attribute from service property
+ String tranAttr = sr.getProperty("transactionAttribute") == null ? null : (String)sr.getProperty("transactionAttribute");
+
+ endpointFactory = new JmsEndpointFactory(this, ml, null, activationSpec, tranAttr, tpf);
// activate the endpoint
try {
@@ -89,6 +103,7 @@ public class MDSContainerImpl implements
public void deActivateMessageEndpoint() {
ra.endpointDeactivation(endpointFactory, activationSpec);
+ // TODO: do we need to free up the proxyed instance of the MDService object?
}
@@ -113,7 +128,10 @@ public class MDSContainerImpl implements
String[] propKeys = reference.getPropertyKeys();
for (String propKey : propKeys) {
- objectRecipe.setMethodProperty(propKey, sr.getProperty(propKey));
+ // set method property on activation config prop keys
+ if (propKey.startsWith("ac:")) {
+ objectRecipe.setMethodProperty(propKey.substring(3), sr.getProperty(propKey));
+ }
}
// create the activationSpec
@@ -132,4 +150,33 @@ public class MDSContainerImpl implements
return activationSpec;
}
+
+
+ public void beforeDelivery(Method method, XAResource xaResource, TransactionPolicy txPolicy) throws SystemException {
+ try {
+ // if we have an xaResource and a transaction was not imported from the adapter, enlist the xaResource
+ if (xaResource != null && txPolicy.isNewTransaction()) {
+ txPolicy.enlistResource(xaResource);
+ }
+ } catch (Exception e) {
+ throw new SystemException("Unable to enlist xa resource in the transaction", e);
+ }
+ }
+
+
+ public void afterDelivery(TransactionPolicy txPolicy) throws SystemException {
+ try {
+ txPolicy.commit();
+ } catch (Exception e) {
+ // TODO handle different exception differently
+ try {
+ txPolicy.setRollbackOnly();
+ txPolicy.commit();
+ } catch (ApplicationException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ }
+ }
+
}
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,55 @@
+/**
+ * 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.aries.mds.impl.exception;
+
+//resue code from apache openejb project with modification
+/**
+ * This exception is thrown when a normal EnterpriseBean exception is thrown.
+ * It acts as a carrier or wrapper for the actual application exception.
+ *
+ * The ApplicationException's nested exception will be either an EJB spec
+ * defined ApplicationException ( or a custom exception defined by the bean
+ * developer) or a RemoteException.
+ *
+ * The ApplicationException must be caught and its nested
+ * exception rethrown by the bean proxy to the client.
+ *
+ * The ApplicationException is non-system exception; it does NOT
+ * indicate a problem with the container itself.
+ */
+public class ApplicationException extends MDSException {
+
+ public ApplicationException() {
+ super();
+ }
+
+ public ApplicationException(String message) {
+ super(message);
+ }
+
+ public ApplicationException(Exception e) {
+ super(e);
+ }
+
+ public ApplicationException(Throwable t) {
+ super(t);
+ }
+
+ public ApplicationException(String message, Exception e) {
+ super(message, e);
+ }
+}
\ No newline at end of file
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/ApplicationException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,51 @@
+/**
+ * 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.aries.mds.impl.exception;
+
+
+public class MDSException extends Exception {
+
+ public MDSException() {
+ super();
+ }
+
+ public MDSException(String message) {
+ super(message);
+ }
+
+ public MDSException(Throwable rootCause) {
+ super(rootCause);
+ }
+
+ public MDSException(String message, Throwable rootCause) {
+ super(message, rootCause);
+ }
+
+ public String getMessage() {
+ Throwable rootCause = getCause();
+ if (rootCause != null) {
+ return super.getMessage() + ": " + rootCause.getMessage();
+ } else {
+ return super.getMessage();
+ }
+ }
+
+ public Throwable getRootCause() {
+ return super.getCause();
+ }
+
+}
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/MDSException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,46 @@
+/**
+ * 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.aries.mds.impl.exception;
+
+//resue code from apache openejb project with modification
+/**
+ * This exception is thrown when the container has encountered an unresolvable
+ * system exception that make this Container unable to process requests.
+ * A breakdown in communication with one of the primary services or a
+ * RuntimeException thrown within the container (not by a bean) is are good
+ * examples.
+ *
+ */
+public class SystemException extends MDSException {
+
+ public SystemException() {
+ super();
+ }
+
+ public SystemException(String message) {
+ super(message);
+ }
+
+ public SystemException(Throwable rootCause) {
+ super(rootCause);
+ }
+
+ public SystemException(String message, Throwable rootCause) {
+ super(message, rootCause);
+ }
+
+}
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/exception/SystemException.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,348 @@
+/**
+ * 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.aries.mds.impl.transaction;
+
+import java.rmi.RemoteException;
+import java.util.Map;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.ArrayList;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionRolledbackException;
+import javax.transaction.TransactionSynchronizationRegistry;
+import javax.transaction.Synchronization;
+import javax.transaction.xa.XAResource;
+
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class JtaTransactionPolicy implements TransactionPolicy {
+ private static final Logger LOGGER = LoggerFactory.getLogger(JtaTransactionPolicy.class);
+
+ protected final TransactionType transactionType;
+
+ protected final TransactionManager transactionManager;
+ private final TransactionSynchronizationRegistry synchronizationRegistry;
+ private Map<Object,Object> resources;
+ private final List<TransactionSynchronization> synchronizations = new LinkedList<TransactionSynchronization>();
+ private boolean rollbackOnly;
+
+ public JtaTransactionPolicy(TransactionType transactionType, TransactionManager transactionManager, TransactionSynchronizationRegistry tsr) {
+ this.transactionType = transactionType;
+ this.transactionManager = transactionManager;
+ synchronizationRegistry = tsr;
+ }
+
+ public TransactionType getTransactionType() {
+ return transactionType;
+ }
+
+ public abstract Transaction getCurrentTransaction();
+
+ public boolean isTransactionActive() {
+ Transaction trasaction = getCurrentTransaction();
+ if (trasaction == null) {
+ return false;
+ }
+
+ try {
+ int status = trasaction.getStatus();
+ return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK;
+ } catch (javax.transaction.SystemException e) {
+ return false;
+ }
+ }
+
+ public boolean isRollbackOnly() {
+ Transaction trasaction = getCurrentTransaction();
+ if (trasaction != null) {
+ try {
+ int status = trasaction.getStatus();
+ return status == Status.STATUS_MARKED_ROLLBACK;
+ } catch (javax.transaction.SystemException e) {
+ return false;
+ }
+ } else {
+ return rollbackOnly;
+ }
+ }
+
+ public void setRollbackOnly() {
+ Transaction trasaction = getCurrentTransaction();
+ if (trasaction != null) {
+ setRollbackOnly(trasaction);
+ } else {
+ rollbackOnly = true;
+ }
+ }
+
+ public Object getResource(Object key) {
+ if (isTransactionActive()) {
+ return synchronizationRegistry.getResource(key);
+ }
+
+ if (resources == null) {
+ return null;
+ }
+ return resources.get(key);
+ }
+
+ public void putResource(Object key, Object value) {
+ if (isTransactionActive()) {
+ synchronizationRegistry.putResource(key, value);
+ }
+
+ if (resources == null) {
+ resources = new LinkedHashMap<Object,Object>();
+ }
+ resources.put(key, value);
+ }
+
+ public Object removeResource(Object key) {
+ if (isTransactionActive()) {
+ Object value = synchronizationRegistry.getResource(key);
+ synchronizationRegistry.putResource(key, null);
+ return value;
+ }
+
+ if (resources == null) {
+ return null;
+ }
+ return resources.remove(key);
+ }
+
+ public void registerSynchronization(final TransactionSynchronization synchronization) {
+ if (isTransactionActive()) {
+ synchronizationRegistry.registerInterposedSynchronization(new Synchronization() {
+ public void beforeCompletion() {
+ synchronization.beforeCompletion();
+ }
+
+ public void afterCompletion(int s) {
+ TransactionSynchronization.Status status;
+ if (s == Status.STATUS_COMMITTED) {
+ status = TransactionSynchronization.Status.COMMITTED;
+ } else if (s == Status.STATUS_ROLLEDBACK) {
+ status = TransactionSynchronization.Status.ROLLEDBACK;
+ } else {
+ status = TransactionSynchronization.Status.UNKNOWN;
+ }
+
+ synchronization.afterCompletion(status);
+ }
+ });
+ } else {
+ synchronizations.add(synchronization);
+ }
+ }
+
+ protected void fireNonTransactionalCompletion() {
+ for (TransactionSynchronization synchronization : new ArrayList<TransactionSynchronization>(synchronizations)) {
+ try {
+ synchronization.beforeCompletion();
+ } catch (Throwable e) {
+ LOGGER.error("Exception thrown from beforeCompletion() of TransactionSynchronization " + synchronization);
+ }
+ }
+ TransactionSynchronization.Status status = isRollbackOnly() ? TransactionSynchronization.Status.ROLLEDBACK : TransactionSynchronization.Status.COMMITTED;
+ for (TransactionSynchronization synchronization : new ArrayList<TransactionSynchronization>(synchronizations)) {
+ try {
+ synchronization.afterCompletion(status);
+ } catch (Exception e) {
+ LOGGER.error("Exception thrown from afterCompletion(" + status + ") of TransactionSynchronization " + synchronization);
+ }
+ }
+ }
+
+ public void enlistResource(XAResource xaResource) throws SystemException {
+ Transaction transaction = getCurrentTransaction();
+ if (transaction != null) {
+ try {
+ if (transaction.enlistResource(xaResource)) {
+ return;
+ }
+ } catch (Exception e) {
+ throw new SystemException("Unable to enlist xa resource in the transaction", e);
+ }
+ }
+ throw new SystemException("Unable to enlist xa resource in the transaction");
+ }
+
+ public String toString() {
+ return transactionType.toString();
+ }
+
+ protected Transaction getTransaction() throws SystemException {
+ try {
+ return transactionManager.getTransaction();
+ } catch (javax.transaction.SystemException e) {
+ LOGGER.error("The Transaction Manager has encountered an unexpected error condition while attempting to obtain current transaction: {0}", e.getMessage());
+ throw new SystemException(e);
+ }
+ }
+
+
+ protected void setRollbackOnly(Transaction tx) {
+ try {
+ if (tx != null && tx.getStatus() == Status.STATUS_ACTIVE) {
+ tx.setRollbackOnly();
+ LOGGER.debug("TX {0}: setRollbackOnly() on transaction {1}", transactionType, tx);
+ }
+ } catch (Exception e) {
+ LOGGER.error("Exception during setRollbackOnly()", e);
+ throw new IllegalStateException("No transaction active", e);
+ }
+ }
+
+ protected Transaction beginTransaction() throws SystemException {
+ Transaction transaction;
+ try {
+ transactionManager.begin();
+ transaction = transactionManager.getTransaction();
+ } catch (Exception e) {
+ LOGGER.error("The Transaction Manager has encountered an unexpected error condition while attempting to begin a new transaction: {0}", e.getMessage());
+ throw new SystemException(e);
+ }
+
+ if (transaction == null) {
+ throw new SystemException("Failed to begin a new transaction");
+ }
+
+ LOGGER.debug("TX {0}: Started transaction {1}", transactionType, transaction);
+ return transaction;
+ }
+
+ protected Transaction suspendTransaction() throws SystemException {
+ try {
+ Transaction tx = transactionManager.suspend();
+ LOGGER.info("TX {0}: Suspended transaction {1}", transactionType, tx);
+ return tx;
+ } catch (javax.transaction.SystemException se) {
+ LOGGER.error("Exception during suspend()", se);
+ throw new SystemException(se);
+ }
+ }
+
+ protected void resumeTransaction(Transaction tx) throws SystemException {
+ try {
+ if (tx == null) {
+ LOGGER.debug("TX {0}: No transaction to resume", transactionType);
+ } else {
+ LOGGER.debug("TX {0}: Resuming transaction {1}" ,transactionType, tx);
+ transactionManager.resume(tx);
+ }
+ } catch (InvalidTransactionException ite) {
+
+ LOGGER.error("Could not resume the client's transaction, the transaction is no longer valid: {0}", ite.getMessage());
+ throw new SystemException(ite);
+ } catch (IllegalStateException e) {
+
+ LOGGER.error("Could not resume the client's transaction: {0}", e.getMessage());
+ throw new SystemException(e);
+ } catch (javax.transaction.SystemException e) {
+
+ LOGGER.error("Could not resume the client's transaction: The transaction reported a system exception: {0}", e.getMessage());
+ throw new SystemException(e);
+ }
+ }
+
+ protected void completeTransaction(Transaction tx) throws SystemException, ApplicationException {
+ boolean shouldRollback;
+ try {
+ shouldRollback = tx.getStatus() != Status.STATUS_ACTIVE;
+ } catch (javax.transaction.SystemException e) {
+ LOGGER.error("The Transaction Manager has encountered an unexpected error condition while attempting to obtain transaction status: {0}", e.getMessage());
+ throw new SystemException(e);
+ }
+
+ if (shouldRollback) {
+ rollbackTransaction(tx);
+ return;
+ }
+
+ try {
+ LOGGER.debug("TX {0}: Committing transaction {1}", transactionType, tx);
+ if (tx.equals(transactionManager.getTransaction())) {
+
+ transactionManager.commit();
+ } else {
+ tx.commit();
+ }
+ } catch (RollbackException e) {
+
+ LOGGER.debug("The transaction has been rolled back rather than commited: {0}", e.getMessage());
+ Throwable txe = new TransactionRolledbackException("Transaction was rolled back, presumably because setRollbackOnly was called during a synchronization").initCause(e);
+ throw new ApplicationException(txe);
+
+ } catch (HeuristicMixedException e) {
+
+ LOGGER.debug("A heuristic decision was made, some relevant updates have been committed while others have been rolled back: {0}", e.getMessage());
+ throw new ApplicationException(new RemoteException("A heuristic decision was made, some relevant updates have been committed while others have been rolled back", e));
+
+ } catch (HeuristicRollbackException e) {
+
+ LOGGER.debug("A heuristic decision was made while commiting the transaction, some relevant updates have been rolled back: {0}", e.getMessage());
+ throw new ApplicationException(new RemoteException("A heuristic decision was made while commiting the transaction, some relevant updates have been rolled back", e));
+
+ } catch (SecurityException e) {
+
+ LOGGER.error("The current thread is not allowed to commit the transaction: {0}", e.getMessage());
+ throw new SystemException(e);
+
+ } catch (IllegalStateException e) {
+
+ LOGGER.error("The current thread is not associated with a transaction: {0}", e.getMessage());
+ throw new SystemException(e);
+
+ } catch (javax.transaction.SystemException e) {
+ LOGGER.error("The Transaction Manager has encountered an unexpected error condition while attempting to commit the transaction: {0}", e.getMessage());
+
+ throw new SystemException(e);
+ }
+ }
+
+ protected void rollbackTransaction(Transaction tx) throws SystemException {
+ try {
+ LOGGER.debug("TX {0}: Rolling back transaction {1}", transactionType, tx);
+ if (tx.equals(transactionManager.getTransaction())) {
+
+ transactionManager.rollback();
+ } else {
+ tx.rollback();
+ }
+ } catch (IllegalStateException e) {
+
+ LOGGER.error("The TransactionManager reported an exception while attempting to rollback the transaction: " + e.getMessage());
+ throw new SystemException(e);
+
+ } catch (javax.transaction.SystemException e) {
+
+ LOGGER.error("The TransactionManager reported an exception while attempting to rollback the transaction: " + e.getMessage());
+ throw new SystemException(e);
+ }
+ }
+}
+
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicy.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,60 @@
+/**
+ *
+ * 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.aries.mds.impl.transaction;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+
+//resue code from apache openejb project with modification
+public class JtaTransactionPolicyFactory implements TransactionPolicyFactory {
+ private final TransactionManager transactionManager;
+ private final TransactionSynchronizationRegistry tsr;
+
+ public JtaTransactionPolicyFactory(TransactionManager transactionManager, TransactionSynchronizationRegistry tsr) {
+ if (transactionManager == null) throw new NullPointerException("transactionManager is null");
+ this.transactionManager = transactionManager;
+ this.tsr = tsr;
+ }
+
+ public TransactionPolicy createTransactionPolicy(TransactionType type) throws SystemException, ApplicationException {
+ switch (type) {
+ // only required and notsupported are supported for MDB for container managed transaction
+ // not sure what to do for bean managed transaction as a bean can get hold of usertransaction service easily
+ // via osgi service registry
+ case Required:
+ return new TxRequired(transactionManager, tsr);
+ /*case RequiresNew:
+ return new TxRequiresNew(transactionManager);
+ case Supports:
+ return new TxSupports(transactionManager);*/
+ case NotSupported:
+ return new TxNotSupported(transactionManager, tsr);
+ /*case Mandatory:
+ return new TxMandatory(transactionManager);
+ case Never:
+ return new TxNever(transactionManager);
+ case BeanManaged:
+ return new TxBeanManaged(transactionManager);*/
+ default:
+ throw new SystemException(new IllegalArgumentException("Unknown transaction type " + type));
+ }
+ }
+}
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/JtaTransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,166 @@
+/**
+ *
+ * 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.aries.mds.impl.transaction;
+
+import javax.transaction.xa.XAResource;
+
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+
+//resue code from apache openejb project with modification
+/**
+ * TransactionPolicy represents a JEE container managed or bean manage
+ * transaction.
+ * <p/>
+ * This class can be used to query the transaction status, set the transaction
+ * rollback only flag, associate resources with the transaction and to register
+ * a listener for transaction completion events.
+ */
+public interface TransactionPolicy {
+ /**
+ * Gets the TransactionType for this policy.
+ *
+ * @return the TransactionType for this policy
+ */
+ TransactionType getTransactionType();
+
+ /**
+ * Is this a new transaction and not an inhreited transaction or no transaction? Some
+ * TransactionTypes, such as Required or Supported, use the caller's
+ * transaction instead of starting a new transaction. If there is no active
+ * transaction (e.g., TransactionType is NotSupported), this method will
+ *
+ * @return true if this not an inherited transaction
+ */
+ boolean isNewTransaction();
+
+
+ /**
+ * Is this policy running in an inherited transaction? Some
+ * TransactionTypes, such as Required or Supported, use the caller's
+ * transaction instead of starting a new transaction. If there is no active
+ * transaction (e.g., TransactionType is NotSupported), this method will
+ * return false.
+ *
+ * @return true if this is an inherited transaction
+ */
+ boolean isClientTransaction();
+
+ /**
+ * Is there a actual transaction active?
+ *
+ * @return true if there is an actual transaction active
+ */
+ boolean isTransactionActive();
+
+ /**
+ * If true, this TransactionPolicy will ultimately end with rollback.
+ *
+ * @return true if this TransactionPolicy will ultimately end with rollback
+ */
+ boolean isRollbackOnly();
+
+ /**
+ * Sets this TransactionPolicy to rollback when completed
+ */
+ void setRollbackOnly();
+
+ /**
+ * Commits or rolls back this TransactionPolicy. If there the actual
+ * transaction is completed or there is no actual transaction, the
+ * registered TransactionSynchronization are called. Otherwise, the
+ * registered TransactionSynchronization are called when the actual
+ * transaction is completed.
+ *
+ * @throws ApplicationException if recoverable exception is encountered
+ * @throws SystemException if an unrecoverable exception is encountered
+ */
+ void commit() throws ApplicationException, SystemException;
+
+ /**
+ * Gets a resource associated with the specified key. If there is an actual
+ * transaction active, the resource associated with the transaction is
+ * returned; otherwise the resource is scoped to this TransactionPolicy.
+ *
+ * @param key the resource key
+ * @return the resource or null if no resource was associated with the key
+ */
+ Object getResource(Object key);
+
+ /**
+ * Associates the specified resource with the specified key. If there is an
+ * actual transaction active, the resource associated with the transaction
+ * is set; otherwise the resource is scoped to this TransactionPolicy.
+ *
+ * @param key the resource key
+ * @param value the resource
+ */
+ void putResource(Object key, Object value);
+
+ /**
+ * Removes and returns the resource associated with the specified key. If
+ * there is an actual transaction active, the resource associated with the
+ * transaction is returned; otherwise the resource is scoped to this
+ * TransactionPolicy.
+ *
+ * @param key the resource key
+ * @return the resource previously associated with the key
+ */
+ Object removeResource(Object key);
+
+ /**
+ * Registers a listener for transaction synchronization events. If there is
+ * an actual transaction active, the events are fired when the acutal
+ * transaction is commited; otherwise the events are fired when this
+ * TransactionPolicy completes.
+ *
+ * @param synchronization the transaction synchronization listener
+ */
+ void registerSynchronization(TransactionSynchronization synchronization);
+
+ /**
+ * Enlists a XAResource in the actual active transaction. This only works
+ * if the TransactionPolicy is associated with an actual transaction and the
+ * TransactionPolicy supports XAResouce enlistment.
+ *
+ * @param xaResource the XAResource to enlist
+ * @throws SystemException if the xaResource could not be enlisted in the
+ * transaction
+ */
+ void enlistResource(XAResource xaResource) throws SystemException;
+
+ /**
+ * TransactionSynchronization receives notifications as the Transaction
+ * completes.
+ */
+ interface TransactionSynchronization {
+ public enum Status {
+ COMMITTED, ROLLEDBACK, UNKNOWN
+ }
+
+ /**
+ * Called immediately before the transaction is completed.
+ */
+ void beforeCompletion();
+
+ /**
+ * Called after the transaction is completed.
+ */
+ void afterCompletion(Status status);
+ }
+}
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicy.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,38 @@
+/**
+ * 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.aries.mds.impl.transaction;
+
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+
+//resue code from apache openejb project with modification
+/**
+ * TransactionPolicyFactory creates TransactionPolicy implementations.
+ */
+public interface TransactionPolicyFactory {
+ /**
+ * Creates and begins a TransactionPolicy for the specified TransactionType.
+ * If this method returns successfully, the specified transaction type is
+ * active and must be committed.
+ *
+ * @param type the desired type of transaction
+ * @return the active TransactionPolicy
+ * @throws ApplicationException if recoverable exception is encountered
+ * @throws SystemException if an unrecoverable exception is encountered
+ */
+ TransactionPolicy createTransactionPolicy(TransactionType type) throws SystemException, ApplicationException;
+}
\ No newline at end of file
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionPolicyFactory.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,52 @@
+/*
+ * 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.aries.mds.impl.transaction;
+
+//resue code from apache openejb project with modification
+public enum TransactionType {
+ Mandatory,
+ Never,
+ NotSupported,
+ Required,
+ RequiresNew,
+ Supports,
+ BeanManaged;
+
+ public static TransactionType get(String type) {
+ if (type.equalsIgnoreCase("Required")) {
+ return Required;
+ } else if (type.equalsIgnoreCase("RequiresNew")) {
+ return RequiresNew;
+ } else if (type.equalsIgnoreCase("Mandatory")) {
+ return Mandatory;
+ } else if (type.equalsIgnoreCase("Never")) {
+ return Never;
+ } else if (type.equalsIgnoreCase("NotSupported")) {
+ return NotSupported;
+ } else if (type.equalsIgnoreCase("Supports")) {
+ return Supports;
+ } else if (type.equalsIgnoreCase("BeanManaged")) {
+ return BeanManaged;
+ } else {
+ throw new IllegalStateException("Uknown TransactionAttribute Type"
+ + type);
+ }
+ }
+
+}
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TransactionType.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,74 @@
+/**
+ * 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.aries.mds.impl.transaction;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+import org.apache.aries.mds.impl.exception.SystemException;
+
+//resue code from apache openejb project with modification
+/**
+ * 17.6.2.1 NotSupported
+ * <p/>
+ * The Container invokes an enterprise Bean method whose transaction attribute
+ * is set to NotSupported with an unspecified transaction context.
+ * <p/>
+ * If a client calls with a transaction context, the container suspends the
+ * association of the transaction context with the current thread before
+ * invoking the enterprise bean's business method. The container resumes the
+ * suspended association when the business method has completed. The suspended
+ * transaction context of the client is not passed to the resource managers or
+ * other enterprise Bean objects that are invoked from the business method.
+ * <p/>
+ * If the business method invokes other enterprise beans, the Container passes
+ * no transaction context with the invocation.
+ * <p/>
+ * Refer to Subsection 17.6.5 for more details of how the Container can
+ * implement this case.
+ */
+public class TxNotSupported extends JtaTransactionPolicy {
+ private final Transaction clientTx;
+
+ public TxNotSupported(TransactionManager transactionManager, TransactionSynchronizationRegistry tsr) throws SystemException {
+ super(TransactionType.NotSupported, transactionManager, tsr);
+
+ clientTx = suspendTransaction();
+ }
+
+ public boolean isNewTransaction() {
+ return false;
+ }
+
+ public boolean isClientTransaction() {
+ return false;
+ }
+
+ public Transaction getCurrentTransaction() {
+ return null;
+ }
+
+ public void commit() throws SystemException {
+ fireNonTransactionalCompletion();
+
+ if (clientTx != null) {
+ resumeTransaction(clientTx);
+ }
+ }
+}
+
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxNotSupported.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java?rev=957723&view=auto
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java (added)
+++ incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java Thu Jun 24 21:35:17 2010
@@ -0,0 +1,82 @@
+/**
+ * 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.aries.mds.impl.transaction;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import javax.transaction.TransactionSynchronizationRegistry;
+
+import org.apache.aries.mds.impl.exception.ApplicationException;
+import org.apache.aries.mds.impl.exception.SystemException;
+
+//resue code from apache openejb project with modification
+/**
+ * 17.6.2.2 Required
+ * <p/>
+ * The Container must invoke an enterprise Bean method whose transaction
+ * attribute is set to Required with a valid transaction context.
+ * <p/>
+ * If a client invokes the enterprise Bean's method while the client is
+ * associated with a transaction context, the container invokes the enterprise
+ * Bean's method in the client's transaction context.
+ * <p/>
+ * If the client invokes the enterprise Bean's method while the client is not
+ * associated with a transaction context, the container automatically starts a
+ * new transaction before delegating a method call to the enterprise Bean
+ * business method. The Container automatically enlists all the resource
+ * managers accessed by the business method with the transaction. If the
+ * business method invokes other enterprise beans, the Container passes the
+ * transaction context with the invocation. The Container attempts to commit the
+ * transaction when the business method has completed. The container performs
+ * the commit protocol before the method result is sent to the client.
+ */
+public class TxRequired extends JtaTransactionPolicy {
+ private final Transaction clientTx;
+ private final Transaction currentTx;
+
+ public TxRequired(TransactionManager transactionManager, TransactionSynchronizationRegistry tsr) throws SystemException {
+ super(TransactionType.Required, transactionManager, tsr);
+
+ clientTx = getTransaction();
+ if (clientTx == null) {
+ currentTx = beginTransaction();
+ } else {
+ currentTx = clientTx;
+ }
+ }
+
+ public boolean isNewTransaction() {
+ return clientTx == null;
+ }
+
+ public boolean isClientTransaction() {
+ return !isNewTransaction();
+ }
+
+ public Transaction getCurrentTransaction() {
+ return currentTx;
+ }
+
+ public void commit() throws ApplicationException, SystemException {
+ // only commit if we started the transaction
+ if (clientTx == null) {
+ completeTransaction(currentTx);
+ } else {
+ fireNonTransactionalCompletion();
+ }
+ }
+}
\ No newline at end of file
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: incubator/aries/sandbox/linsun/mds/mds-impl/src/main/java/org/apache/aries/mds/impl/transaction/TxRequired.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/aries/sandbox/linsun/mds/mds-itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-itest/pom.xml?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-itest/pom.xml (original)
+++ incubator/aries/sandbox/linsun/mds/mds-itest/pom.xml Thu Jun 24 21:35:17 2010
@@ -81,7 +81,12 @@
<groupId>org.apache.aries.mds</groupId>
<artifactId>org.apache.aries.mds.sample</artifactId>
<scope>test</scope>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.transaction</groupId>
+ <artifactId>org.apache.aries.transaction.manager</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
Modified: incubator/aries/sandbox/linsun/mds/mds-itest/src/test/java/org/apache/aries/mds/itests/MessageDrivenTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-itest/src/test/java/org/apache/aries/mds/itests/MessageDrivenTest.java?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-itest/src/test/java/org/apache/aries/mds/itests/MessageDrivenTest.java (original)
+++ incubator/aries/sandbox/linsun/mds/mds-itest/src/test/java/org/apache/aries/mds/itests/MessageDrivenTest.java Thu Jun 24 21:35:17 2010
@@ -24,9 +24,11 @@ import static org.junit.Assert.assertNot
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackages;
import static org.ops4j.pax.exam.CoreOptions.equinox;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
import java.io.Serializable;
import java.text.SimpleDateFormat;
@@ -150,6 +152,9 @@ public class MessageDrivenTest extends A
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {
Option[] options = options(
+ bootDelegationPackages("javax.transaction", "javax.transaction.*"),
+ vmOption("-Dorg.osgi.framework.system.packages=javax.accessibility,javax.activation,javax.activity,javax.annotation,javax.annotation.processing,javax.crypto,javax.crypto.interfaces,javax.crypto.spec,javax.imageio,javax.imageio.event,javax.imageio.metadata,javax.imageio.plugins.bmp,javax.imageio.plugins.jpeg,javax.imageio.spi,javax.imageio.stream,javax.jws,javax.jws.soap,javax.lang.model,javax.lang.model.element,javax.lang.model.type,javax.lang.model.util,javax.management,javax.management.loading,javax.management.modelmbean,javax.management.monitor,javax.management.openmbean,javax.management.relation,javax.management.remote,javax.management.remote.rmi,javax.management.timer,javax.naming,javax.naming.directory,javax.naming.event,javax.naming.ldap,javax.naming.spi,javax.net,javax.net.ssl,javax.print,javax.print.attribute,javax.print.attribute.standard,javax.print.event,javax.rmi,javax.rmi.CORBA,javax.rmi.ssl,javax.script,javax.security.auth,javax.security.auth.callb
ack,javax.security.auth.kerberos,javax.security.auth.login,javax.security.auth.spi,javax.security.auth.x500,javax.security.cert,javax.security.sasl,javax.sound.midi,javax.sound.midi.spi,javax.sound.sampled,javax.sound.sampled.spi,javax.sql,javax.sql.rowset,javax.sql.rowset.serial,javax.sql.rowset.spi,javax.swing,javax.swing.border,javax.swing.colorchooser,javax.swing.event,javax.swing.filechooser,javax.swing.plaf,javax.swing.plaf.basic,javax.swing.plaf.metal,javax.swing.plaf.multi,javax.swing.plaf.synth,javax.swing.table,javax.swing.text,javax.swing.text.html,javax.swing.text.html.parser,javax.swing.text.rtf,javax.swing.tree,javax.swing.undo,javax.tools,javax.xml,javax.xml.bind,javax.xml.bind.annotation,javax.xml.bind.annotation.adapters,javax.xml.bind.attachment,javax.xml.bind.helpers,javax.xml.bind.util,javax.xml.crypto,javax.xml.crypto.dom,javax.xml.crypto.dsig,javax.xml.crypto.dsig.dom,javax.xml.crypto.dsig.keyinfo,javax.xml.crypto.dsig.spec,javax.xml.datatype,javax.xml.
namespace,javax.xml.parsers,javax.xml.soap,javax.xml.stream,javax.xml.stream.events,javax.xml.stream.util,javax.xml.transform,javax.xml.transform.dom,javax.xml.transform.sax,javax.xml.transform.stax,javax.xml.transform.stream,javax.xml.validation,javax.xml.ws,javax.xml.ws.handler,javax.xml.ws.handler.soap,javax.xml.ws.http,javax.xml.ws.soap,javax.xml.ws.spi,javax.xml.xpath,org.ietf.jgss,org.omg.CORBA,org.omg.CORBA.DynAnyPackage,org.omg.CORBA.ORBPackage,org.omg.CORBA.TypeCodePackage,org.omg.CORBA.portable,org.omg.CORBA_2_3,org.omg.CORBA_2_3.portable,org.omg.CosNaming,org.omg.CosNaming.NamingContextExtPackage,org.omg.CosNaming.NamingContextPackage,org.omg.Dynamic,org.omg.DynamicAny,org.omg.DynamicAny.DynAnyFactoryPackage,org.omg.DynamicAny.DynAnyPackage,org.omg.IOP,org.omg.IOP.CodecFactoryPackage,org.omg.IOP.CodecPackage,org.omg.Messaging,org.omg.PortableInterceptor,org.omg.PortableInterceptor.ORBInitInfoPackage,org.omg.PortableServer,org.omg.PortableServer.CurrentPackage,org.
omg.PortableServer.POAManagerPackage,org.omg.PortableServer.POAPackage,org.omg.PortableServer.ServantLocatorPackage,org.omg.PortableServer.portable,org.omg.SendingContext,org.omg.stub.java.rmi,org.w3c.dom,org.w3c.dom.bootstrap,org.w3c.dom.css,org.w3c.dom.events,org.w3c.dom.html,org.w3c.dom.ls,org.w3c.dom.ranges,org.w3c.dom.stylesheets,org.w3c.dom.traversal,org.w3c.dom.views,org.xml.sax,org.xml.sax.ext,org.xml.sax.helpers,javax.transaction;partial=true;mandatory:=partial,javax.transaction.xa;partial=true;mandatory:=partial"),
+
// Log
mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
@@ -166,6 +171,7 @@ public class MessageDrivenTest extends A
mavenBundle("org.apache.aries", "org.apache.aries.util"),
mavenBundle("asm", "asm-all"),
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
+ mavenBundle("org.apache.aries.transaction", "org.apache.aries.transaction.manager"),
mavenBundle("org.apache.geronimo.specs", "geronimo-annotation_1.0_spec"),
mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
mavenBundle("org.apache.geronimo.specs", "geronimo-j2ee-management_1.1_spec"),
Modified: incubator/aries/sandbox/linsun/mds/mds-sample/src/main/resources/OSGI-INF/blueprint/config.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/mds-sample/src/main/resources/OSGI-INF/blueprint/config.xml?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/mds-sample/src/main/resources/OSGI-INF/blueprint/config.xml (original)
+++ incubator/aries/sandbox/linsun/mds/mds-sample/src/main/resources/OSGI-INF/blueprint/config.xml Thu Jun 24 21:35:17 2010
@@ -25,9 +25,10 @@
<service ref="myMessageDrivenBean" interface="javax.jms.MessageListener">
<service-properties>
- <!-- add in activation config properties -->
- <entry key="destination" value="Hello.Queue" />
- <entry key="destinationType" value="javax.jms.Queue" />
+ <!-- add in activation config properties, starts with prefix ac -->
+ <entry key="ac:destination" value="Hello.Queue" />
+ <entry key="ac:destinationType" value="javax.jms.Queue" />
+ <entry key="transactionAttribute" value="Required" />
<!-- <entry key="service.pid" value="org.apache.aries.mds.sample.myMessageDrivenBean" /> -->
</service-properties>
</service>
Modified: incubator/aries/sandbox/linsun/mds/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/linsun/mds/pom.xml?rev=957723&r1=957722&r2=957723&view=diff
==============================================================================
--- incubator/aries/sandbox/linsun/mds/pom.xml (original)
+++ incubator/aries/sandbox/linsun/mds/pom.xml Thu Jun 24 21:35:17 2010
@@ -99,6 +99,11 @@
<artifactId>org.apache.aries.util</artifactId>
<version>${version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.transaction</groupId>
+ <artifactId>org.apache.aries.transaction.manager</artifactId>
+ <version>${version}</version>
+ </dependency>
<!--
Use an OSGi enabled cglib version, so that BND can find the version
information and we can use it in integration tests