axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ami...@apache.org
Subject svn commit: r725032 - in /webservices/axis2/trunk/java/modules/kernel: ./ src/org/apache/axis2/ src/org/apache/axis2/deployment/ src/org/apache/axis2/engine/ src/org/apache/axis2/transaction/
Date Wed, 10 Dec 2008 08:59:42 GMT
Author: amilas
Date: Wed Dec 10 00:59:41 2008
New Revision: 725032

URL: http://svn.apache.org/viewvc?rev=725032&view=rev
Log:
applied the patch for AXIS2-4138

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/pom.xml
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
    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/engine/AxisConfiguration.java

Modified: webservices/axis2/trunk/java/modules/kernel/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/pom.xml?rev=725032&r1=725031&r2=725032&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/pom.xml (original)
+++ webservices/axis2/trunk/java/modules/kernel/pom.xml Wed Dec 10 00:59:41 2008
@@ -49,6 +49,10 @@
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-ws-metadata_2.0_spec</artifactId>
         </dependency>
+	  <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jta_1.1_spec</artifactId>
+        </dependency>
         <dependency>
             <groupId>javax.servlet</groupId>
             <artifactId>servlet-api</artifactId>

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?rev=725032&r1=725031&r2=725032&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Wed Dec
10 00:59:41 2008
@@ -298,6 +298,14 @@
     public static final String JMS_COORELATION_ID = "JMS_COORELATION_ID";
 
     public static final String MODULE_VERSION ="version";
+
+    /**
+     * Following constant are used for JTA transaction supporyt in Axis2
+     */
+    public static final String USER_TRANSACTION = "UserTransaction";
+    public static final String TRANSACTION_MANAGER = "TransactionManager";
+    public static final String SUSPENDED_TRANSACTION = "SuspendedTransaction";
+
     
     public static interface Configuration {
         public static final String ENABLE_REST = "enableREST";
@@ -420,5 +428,7 @@
 
         public static final String GENERATE_ABSOLUTE_LOCATION_URIS = "generateAbsoluteLocationURIs";
 
+
+
     }
 }

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=725032&r1=725031&r2=725032&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
Wed Dec 10 00:59:41 2008
@@ -26,6 +26,7 @@
 import org.apache.axiom.soap.RolePlayer;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.transaction.TransactionConfiguration;
 import org.apache.axis2.builder.ApplicationXMLBuilder;
 import org.apache.axis2.builder.Builder;
 import org.apache.axis2.builder.MIMEBuilder;
@@ -35,11 +36,7 @@
 import org.apache.axis2.dataretrieval.DRConstants;
 import org.apache.axis2.deployment.util.PhasesInfo;
 import org.apache.axis2.deployment.util.Utils;
-import org.apache.axis2.description.HandlerDescription;
-import org.apache.axis2.description.ModuleConfiguration;
-import org.apache.axis2.description.ParameterInclude;
-import org.apache.axis2.description.TransportInDescription;
-import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.description.*;
 import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisObserver;
 import org.apache.axis2.engine.MessageReceiver;
@@ -186,6 +183,24 @@
                 clusterBuilder.buildCluster(clusterElement);
             }
 
+            //Add jta transaction  configuration
+            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);
+
+                OMAttribute timeoutAttribute = transactionElement.getAttribute(new QName(TAG_TIMEOUT));
+                if(timeoutAttribute != null) {
+                    txcfg.setTransactionTimeout(Integer.parseInt(timeoutAttribute.getAttributeValue()));
+                }
+
+                axisConfig.setTransactionConfig(txcfg);
+            }
+
+                    
             /*
             * Add Axis2 default builders if they are not overidden by the config
             */

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=725032&r1=725031&r2=725032&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
Wed Dec 10 00:59:41 2008
@@ -71,6 +71,8 @@
     String TAG_MEP = "mep";
     String TAG_DEFAULT_MODULE_VERSION = "defaultModuleVersions";
     String TAG_CLUSTER = "cluster";
+    String TAG_TRANSACTION = "transaction";
+    String TAG_TIMEOUT = "timeout";
     String TAG_MESSAGE_BUILDERS =
             "messageBuilders"; //used to add pluggable support for diffrent wire formats
     String TAG_MESSAGE_BUILDER = "messageBuilder";

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java?rev=725032&r1=725031&r2=725032&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisConfiguration.java
Wed Dec 10 00:59:41 2008
@@ -34,6 +34,7 @@
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.transaction.TransactionConfiguration;
 import org.apache.axis2.builder.Builder;
 import org.apache.axis2.builder.unknowncontent.UnknownContentBuilder;
 import org.apache.axis2.clustering.ClusterManager;
@@ -148,6 +149,8 @@
 
     private AxisConfigurator configurator;
 
+    private TransactionConfiguration transactionConfiguration;
+
     /**
      * Constructor AxisConfiguration.
      */
@@ -1023,6 +1026,14 @@
         this.clusterManager = clusterManager;
     }
 
+     public TransactionConfiguration getTransactionConfiguration() {
+        return transactionConfiguration;
+    }
+
+    public void setTransactionConfig(TransactionConfiguration transactionConfiguration) {
+        this.transactionConfiguration = transactionConfiguration;
+    }
+
     public Object getKey() {
         return toString();
     }

Added: 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=725032&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
(added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transaction/TransactionConfiguration.java
Wed Dec 10 00:59:41 2008
@@ -0,0 +1,120 @@
+/*
+ * 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 org.apache.axis2.AxisFault;
+import org.apache.axis2.deployment.AxisConfigBuilder;
+import org.apache.axis2.deployment.DeploymentException;
+import org.apache.axis2.description.ParameterInclude;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.description.ParameterIncludeImpl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMElement;
+
+import javax.transaction.TransactionManager;
+import javax.transaction.UserTransaction;
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.xml.namespace.QName;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+public class TransactionConfiguration {
+
+    private static final Log log = LogFactory.getLog(TransactionConfiguration.class);
+
+    public static final int DEFAULT_TX_TIME_OUT = 300000 ; //30s
+    public static final String TX_MANAGER_JNDI_NAME = "TransactionManagerJNDIName";
+
+    private int transactionTimeout = DEFAULT_TX_TIME_OUT;
+    private ThreadLocal threadTransactionManager = null;
+    private Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
+    private String transactionManagerJNDIName = null;
+
+
+
+    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();     
+    }
+
+    public int getTransactionTimeout(){
+        return transactionTimeout;
+    }
+
+    public void setTransactionTimeout(int transactionTimeout){
+        this.transactionTimeout = transactionTimeout;
+    }
+
+    public synchronized TransactionManager getTransactionManager() throws AxisFault {
+        TransactionManager transactionManager = (TransactionManager) threadTransactionManager.get();
+        if (transactionManager == null) {
+            transactionManager = lookupTransactionManager();
+            threadTransactionManager.set(transactionManager);
+            if (log.isDebugEnabled()) log.debug("JNDI lookup TransactionManager");
+        } else {
+            if (log.isDebugEnabled()) log.debug("Re-use previously JNDI lookup TransactionManager");
+        }
+        try{
+            transactionManager.setTransactionTimeout(transactionTimeout);
+        } catch(Exception ignore) {}
+
+        return transactionManager;
+    }
+
+    private synchronized TransactionManager lookupTransactionManager() throws AxisFault {
+
+        try {
+
+            Context context = new InitialContext(jndiProperties);
+            Object transactionManager = context.lookup( transactionManagerJNDIName );
+            if (transactionManager != null && transactionManager instanceof TransactionManager)
{
+                return (TransactionManager) transactionManager;
+            } else {
+                log.error("TransactionManager : " + transactionManagerJNDIName + " not found
when looking up" +
+                        " using JNDI properties : " + context.getEnvironment());
+                throw new AxisFault("TransactionManager : " + transactionManagerJNDIName
+ " not found when looking up" +
+                        " using JNDI properties : " + context.getEnvironment());
+            }
+
+        } catch (NamingException e) {
+
+            log.error(new StringBuilder().append("Error looking up TransactionManager ")
+                    .append(" using JNDI properties : ").append(jndiProperties));
+            throw new AxisFault("TransactionManager not found when looking up" +
+                    " using JNDI properties : " + jndiProperties);
+        }
+    }
+
+
+}



Mime
View raw message