axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r522418 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: client/ServiceClient.java util/Counter.java
Date Mon, 26 Mar 2007 05:06:02 GMT
Author: dims
Date: Sun Mar 25 22:06:02 2007
New Revision: 522418

URL: http://svn.apache.org/viewvc?view=rev&rev=522418
Log:
avoid backport util at least for jdk1.5

Added:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Counter.java
Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java?view=diff&rev=522418&r1=522417&r2=522418
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/client/ServiceClient.java
Sun Mar 25 22:06:02 2007
@@ -24,6 +24,7 @@
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
+import org.apache.axis2.util.Counter;
 import org.apache.axis2.addressing.EndpointReference;
 import org.apache.axis2.client.async.Callback;
 import org.apache.axis2.context.ConfigurationContext;
@@ -44,7 +45,6 @@
 import org.apache.axis2.engine.ListenerManager;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.wsdl.WSDLConstants;
-import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong;
 
 
 import javax.wsdl.Definition;
@@ -66,7 +66,7 @@
     public static final String ANON_SERVICE = "anonService";
 
     /** Counter used to generate the anonymous service name. */
-    private static AtomicLong anonServiceCounter = new AtomicLong(0);
+    private static Counter anonServiceCounter = new Counter();
 
 
     /**

Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Counter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Counter.java?view=auto&rev=522418
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Counter.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Counter.java Sun
Mar 25 22:06:02 2007
@@ -0,0 +1,65 @@
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed 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.util;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+// Counter uses java.util.concurrent.atomic.AtomicLong if present,
+// else falls back to the backport version
+public class Counter {
+    private static Class clazz;
+    private static Method method;
+    private Object counter;
+
+    static {
+        try {
+            clazz = Class.forName("java.util.concurrent.atomic.AtomicLong");
+        } catch (ClassNotFoundException e) {
+            try {
+                clazz = Class.forName("edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicLong");
+            } catch (ClassNotFoundException e1) {
+                throw new RuntimeException(e1);
+            }
+        }
+        try {
+            method = clazz.getMethod("incrementAndGet", new Class[]{});
+        } catch (NoSuchMethodException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public Counter() {
+        try {
+            counter = clazz.newInstance();
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public final synchronized long incrementAndGet() {
+        try {
+            return ((Long) method.invoke(counter, new Object[]{})).longValue();
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message