You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by am...@apache.org on 2009/05/30 13:33:55 UTC

svn commit: r780246 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: deployment/AxisConfigBuilder.java deployment/DeploymentConstants.java transaction/Axis2UserTransaction.java transaction/TransactionConfiguration.java

Author: amilas
Date: Sat May 30 11:33:55 2009
New Revision: 780246

URL: http://svn.apache.org/viewvc?rev=780246&view=rev
Log:
modify the axis2 transction configuration building to pass a custom class to provide the
transaction managers. This class should extend the existing transaction configuration class.
Added a new method to provide a user transaction which is required by jms transport.

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/Axis2UserTransaction.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java?rev=780246&r1=780245&r2=780246&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/AxisConfigBuilder.java Sat May 30 11:33:55 2009
@@ -65,6 +65,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.lang.reflect.Constructor;
 
 public class AxisConfigBuilder extends DescriptionBuilder {
 
@@ -184,13 +185,28 @@
             }
 
             //Add jta transaction  configuration
-            OMElement transactionElement = config_element
-                    .getFirstChildWithName(new QName(TAG_TRANSACTION));
+            OMElement transactionElement = config_element.getFirstChildWithName(new QName(TAG_TRANSACTION));
             if (transactionElement != null) {
                 ParameterInclude transactionParameters = new ParameterIncludeImpl();
                 Iterator parameters = transactionElement.getChildrenWithName(new QName(TAG_PARAMETER));
                 processParameters(parameters, transactionParameters, null);
-                TransactionConfiguration txcfg = new TransactionConfiguration(transactionParameters);
+
+                TransactionConfiguration txcfg = null;
+                OMAttribute txConfigurationClassAttribute =
+                        transactionElement.getAttribute(new QName(TAG_TRANSACTION_CONFIGURATION_CLASS));
+
+                if (txConfigurationClassAttribute != null){
+                    String txConfigurationClassName = txConfigurationClassAttribute.getAttributeValue();
+                    try {
+                        Class txConfigurationClass = Class.forName(txConfigurationClassName);
+                        Constructor constructor = txConfigurationClass.getConstructor(new Class[]{ParameterInclude.class});
+                        txcfg = (TransactionConfiguration) constructor.newInstance(new Object[]{transactionParameters});
+                    } catch (Exception e) {
+                        throw new DeploymentException("Can not found or instantiate the class " + txConfigurationClassName, e);
+                    }
+                } else {
+                    txcfg = new TransactionConfiguration(transactionParameters);
+                }
 
                 OMAttribute timeoutAttribute = transactionElement.getAttribute(new QName(TAG_TIMEOUT));
                 if(timeoutAttribute != null) {

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java?rev=780246&r1=780245&r2=780246&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/DeploymentConstants.java Sat May 30 11:33:55 2009
@@ -72,6 +72,7 @@
     String TAG_DEFAULT_MODULE_VERSION = "defaultModuleVersions";
     String TAG_CLUSTER = "cluster";
     String TAG_TRANSACTION = "transaction";
+    String TAG_TRANSACTION_CONFIGURATION_CLASS = "transactionConfigurationClass";
     String TAG_TIMEOUT = "timeout";
     String TAG_MESSAGE_BUILDERS =
             "messageBuilders"; //used to add pluggable support for diffrent wire formats

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/Axis2UserTransaction.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/Axis2UserTransaction.java?rev=780246&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/Axis2UserTransaction.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/Axis2UserTransaction.java Sat May 30 11:33:55 2009
@@ -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.axis2.transaction;
+
+import javax.transaction.*;
+
+
+public class Axis2UserTransaction implements UserTransaction {
+
+    private TransactionManager transactionManager = null;
+
+    public Axis2UserTransaction(TransactionManager transactionManager) {
+        this.transactionManager = transactionManager;
+    }
+
+    public void begin() throws NotSupportedException, SystemException {
+        this.transactionManager.begin();
+    }
+
+    public void commit() throws HeuristicMixedException,
+            HeuristicRollbackException,
+            IllegalStateException,
+            RollbackException,
+            SecurityException, SystemException {
+        this.transactionManager.commit();
+    }
+
+    public int getStatus() throws SystemException {
+        return this.transactionManager.getStatus();
+    }
+
+    public void rollback() throws IllegalStateException, SecurityException, SystemException {
+        this.transactionManager.rollback();
+    }
+
+    public void setRollbackOnly() throws IllegalStateException, SystemException {
+       this.transactionManager.setRollbackOnly();
+    }
+
+    public void setTransactionTimeout(int i) throws SystemException {
+       this.transactionManager.setTransactionTimeout(i);
+    }
+}

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java?rev=780246&r1=780245&r2=780246&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java Sat May 30 11:33:55 2009
@@ -30,6 +30,7 @@
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
 import java.util.Hashtable;
 import java.util.Iterator;
 
@@ -45,22 +46,23 @@
     private Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
     private String transactionManagerJNDIName = null;
 
-
+    public TransactionConfiguration() {
+    }
 
     public TransactionConfiguration(ParameterInclude transactionParameters) throws DeploymentException {
        Iterator it = transactionParameters.getParameters().iterator();
         while (it.hasNext()) {
             Parameter parameter = (Parameter) it.next();
             jndiProperties.put(parameter.getName(), (String) parameter.getValue());
-        }         
-     
+        }
+
         transactionManagerJNDIName = (String) transactionParameters.getParameter(TX_MANAGER_JNDI_NAME).getValue();
 
         if(transactionManagerJNDIName == null){
              throw new DeploymentException("Required transaction parameter " + TX_MANAGER_JNDI_NAME + " missing");
         }
 
-        threadTransactionManager = new ThreadLocal();     
+        threadTransactionManager = new ThreadLocal();
     }
 
     public int getTransactionTimeout(){
@@ -87,6 +89,10 @@
         return transactionManager;
     }
 
+    public UserTransaction getUserTransaction() throws AxisFault {
+        return new Axis2UserTransaction(getTransactionManager());
+    }
+
     private synchronized TransactionManager lookupTransactionManager() throws AxisFault {
 
         try {