Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.3-prepare cac067d9b -> 6d74b263d


http://git-wip-us.apache.org/repos/asf/tomee/blob/6d74b263/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java
----------------------------------------------------------------------
diff --git 
a/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java 
b/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java
index 0bdceff..b452c3e 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/common/NamingUtil.java
@@ -1,149 +1,149 @@
-/**
- *
- * 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.tomee.common;
-
-import org.apache.catalina.core.StandardContext;
-import org.apache.naming.EjbRef;
-
-import javax.naming.RefAddr;
-import javax.naming.Reference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
-public class NamingUtil {
-    public static final String NAME = "name";
-    public static final String DEPLOYMENT_ID = "deploymentid";
-    public static final String EXTERNAL = "external";
-    public static final String LOCAL = "local";
-    public static final String LOCALBEAN = "localbean";
-    public static final String REMOTE = EjbRef.REMOTE;
-    public static final String JNDI_NAME = "jndiname";
-    public static final String JNDI_PROVIDER_ID = "jndiproviderid";
-    public static final String UNIT = "unit";
-    public static final String EXTENDED = "extended";
-    public static final String PROPERTIES = "properties";
-    public static final String RESOURCE_ID = "resourceid";
-    public static final String COMPONENT_TYPE = "componenttype";
-    public static final String WS_ID = "wsid";
-    public static final String WS_CLASS = "wsclass";
-    public static final String WS_QNAME = "wsqname";
-    public static final String WS_PORT_QNAME = "wsportqname";
-    public static final String WSDL_URL = "wsdlurl";
-
-    private static final AtomicInteger id = new AtomicInteger(31);
-    private static final Map<String,Object> registry = new 
ConcurrentHashMap<String, Object>();
-
-    // these two attributes are used to be able to cleanup quickly the 
registry (otherwise we need to duplicate a lot of logic)
-    private static StandardContext currentContext;
-    private static final Map<StandardContext, Collection<String>> 
ID_BY_CONTEXT = new HashMap<StandardContext, Collection<String>>();
-
-    public static String getProperty(final Reference ref, final String name) {
-        final RefAddr addr = ref.get(name);
-        if (addr == null) {
-            return null;
-        }
-        final Object value = addr.getContent();
-        return (String) value;
-    }
-
-    public static boolean isPropertyTrue(final Reference ref, final String 
name) {
-        final RefAddr addr = ref.get(name);
-        if (addr == null) {
-            return false;
-        }
-        final Object value = addr.getContent();
-        return Boolean.parseBoolean(String.valueOf(value));
-    }
-
-    public static void setStaticValue(final Resource resource, final Object 
value) {
-        setStaticValue(resource, null, value);
-    }
-
-    public static void setStaticValue(final Resource resource, final String 
name, final Object value) {
-        final String token = String.valueOf(id.incrementAndGet());
-        registry.put(token, value);
-        resource.setProperty("static-token" + (name != null ? "-" + name : 
""), token);
-        if (currentContext != null) {
-            Collection<String> ids = ID_BY_CONTEXT.get(currentContext);
-            if (ids == null) {
-                ids = new ArrayList<String>();
-                ID_BY_CONTEXT.put(currentContext, ids);
-            }
-            ids.add(token);
-        }
-    }
-
-    @SuppressWarnings({"unchecked"})
-    public static<T> T getStaticValue(final Reference ref) {
-        return (T) getStaticValue(ref, null);
-    }
-
-    @SuppressWarnings({"unchecked"})
-    public static <T> T getStaticValue(final Reference ref, String name) {
-        name = name != null ? "-" + name : "";
-        final String token = getProperty(ref, "static-token" + name);
-        if (token == null) {
-            return null;
-        }
-        return (T) registry.get(token);
-    }
-
-    public static Class<?> loadClass(final String className) {
-        if (className == null) {
-            return null;
-        }
-        try {
-            final ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
-            if (classLoader != null) {
-                try {
-                    return classLoader.loadClass(className);
-                } catch(final ClassNotFoundException e) {
-                    // no-op
-                }
-            }
-            return Class.forName(className);
-        } catch (final ClassNotFoundException e) {
-            return null;
-        }
-    }
-
-    /**
-     * This interface exists because the class 
org.apache.catalina.deploy.ContextResource
-     * is not available in the common classloader in tomcat 55
-     */
-    public interface Resource {
-        void setProperty(String name, Object value);
-    }
-
-    public static void setCurrentContext(final StandardContext currentContext) 
{
-        NamingUtil.currentContext = currentContext;
-    }
-
-    public static void cleanUpContextResource(final StandardContext context) {
-        final Collection<String> keys = ID_BY_CONTEXT.remove(context);
-        if (keys != null) {
-            for (final String k : keys) {
-                registry.remove(k);
-            }
-        }
-    }
-}
+/**
+ *
+ * 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.tomee.common;
+
+import org.apache.catalina.core.StandardContext;
+import org.apache.naming.EjbRef;
+
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class NamingUtil {
+    public static final String NAME = "name";
+    public static final String DEPLOYMENT_ID = "deploymentid";
+    public static final String EXTERNAL = "external";
+    public static final String LOCAL = "local";
+    public static final String LOCALBEAN = "localbean";
+    public static final String REMOTE = EjbRef.REMOTE;
+    public static final String JNDI_NAME = "jndiname";
+    public static final String JNDI_PROVIDER_ID = "jndiproviderid";
+    public static final String UNIT = "unit";
+    public static final String EXTENDED = "extended";
+    public static final String PROPERTIES = "properties";
+    public static final String RESOURCE_ID = "resourceid";
+    public static final String COMPONENT_TYPE = "componenttype";
+    public static final String WS_ID = "wsid";
+    public static final String WS_CLASS = "wsclass";
+    public static final String WS_QNAME = "wsqname";
+    public static final String WS_PORT_QNAME = "wsportqname";
+    public static final String WSDL_URL = "wsdlurl";
+
+    private static final AtomicInteger id = new AtomicInteger(31);
+    private static final Map<String,Object> registry = new 
ConcurrentHashMap<String, Object>();
+
+    // these two attributes are used to be able to cleanup quickly the 
registry (otherwise we need to duplicate a lot of logic)
+    private static StandardContext currentContext;
+    private static final Map<StandardContext, Collection<String>> 
ID_BY_CONTEXT = new HashMap<StandardContext, Collection<String>>();
+
+    public static String getProperty(final Reference ref, final String name) {
+        final RefAddr addr = ref.get(name);
+        if (addr == null) {
+            return null;
+        }
+        final Object value = addr.getContent();
+        return (String) value;
+    }
+
+    public static boolean isPropertyTrue(final Reference ref, final String 
name) {
+        final RefAddr addr = ref.get(name);
+        if (addr == null) {
+            return false;
+        }
+        final Object value = addr.getContent();
+        return Boolean.parseBoolean(String.valueOf(value));
+    }
+
+    public static void setStaticValue(final Resource resource, final Object 
value) {
+        setStaticValue(resource, null, value);
+    }
+
+    public static void setStaticValue(final Resource resource, final String 
name, final Object value) {
+        final String token = String.valueOf(id.incrementAndGet());
+        registry.put(token, value);
+        resource.setProperty("static-token" + (name != null ? "-" + name : 
""), token);
+        if (currentContext != null) {
+            Collection<String> ids = ID_BY_CONTEXT.get(currentContext);
+            if (ids == null) {
+                ids = new ArrayList<String>();
+                ID_BY_CONTEXT.put(currentContext, ids);
+            }
+            ids.add(token);
+        }
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public static<T> T getStaticValue(final Reference ref) {
+        return (T) getStaticValue(ref, null);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public static <T> T getStaticValue(final Reference ref, String name) {
+        name = name != null ? "-" + name : "";
+        final String token = getProperty(ref, "static-token" + name);
+        if (token == null) {
+            return null;
+        }
+        return (T) registry.get(token);
+    }
+
+    public static Class<?> loadClass(final String className) {
+        if (className == null) {
+            return null;
+        }
+        try {
+            final ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
+            if (classLoader != null) {
+                try {
+                    return classLoader.loadClass(className);
+                } catch(final ClassNotFoundException e) {
+                    // no-op
+                }
+            }
+            return Class.forName(className);
+        } catch (final ClassNotFoundException e) {
+            return null;
+        }
+    }
+
+    /**
+     * This interface exists because the class 
org.apache.catalina.deploy.ContextResource
+     * is not available in the common classloader in tomcat 55
+     */
+    public interface Resource {
+        void setProperty(String name, Object value);
+    }
+
+    public static void setCurrentContext(final StandardContext currentContext) 
{
+        NamingUtil.currentContext = currentContext;
+    }
+
+    public static void cleanUpContextResource(final StandardContext context) {
+        final Collection<String> keys = ID_BY_CONTEXT.remove(context);
+        if (keys != null) {
+            for (final String k : keys) {
+                registry.remove(k);
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/6d74b263/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
----------------------------------------------------------------------
diff --git 
a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java 
b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
index 1de7a83..8546deb 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/common/WsFactory.java
@@ -1,134 +1,134 @@
-/**
- *
- * 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.tomee.common;
-
-import org.apache.naming.ResourceRef;
-import org.apache.openejb.Injection;
-import org.apache.openejb.core.ivm.naming.JaxWsServiceReference;
-import org.apache.openejb.core.webservices.HandlerChainData;
-import org.apache.openejb.core.webservices.PortRefData;
-
-import javax.naming.Context;
-import javax.naming.Name;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Properties;
-
-public class WsFactory extends AbstractObjectFactory {
-    public Object getObjectInstance(final Object object, final Name name, 
final Context context, final Hashtable environment) throws Exception {
-        // ignore non resource-refs
-        if (!(object instanceof ResourceRef)) {
-            return null;
-        }
-
-        final Reference ref = (Reference) object;
-
-        final Object value;
-        if (NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME) != null) {
-            // lookup the value in JNDI
-            value = super.getObjectInstance(object, name, context, 
environment);
-        } else {
-            // load service class which is used to construct the port
-            final String serviceClassName = NamingUtil.getProperty(ref, 
NamingUtil.WS_CLASS);
-            Class<? extends Service> serviceClass = Service.class;
-            if (serviceClassName != null) {
-                final Class<?> loadClass = 
NamingUtil.loadClass(serviceClassName);
-
-                if (loadClass == null) {
-                    throw new NamingException("Could not load service type 
class "+ serviceClassName);
-                }
-
-                serviceClass = loadClass.asSubclass(Service.class);
-            }
-
-            // load the reference class which is the ultimate type of the port
-            final Class<?> referenceClass = 
NamingUtil.loadClass(ref.getClassName());
-
-            // if ref class is a subclass of Service, use it for the service 
class
-            if (referenceClass != null && 
Service.class.isAssignableFrom(referenceClass)) {
-                serviceClass = referenceClass.asSubclass(Service.class);
-            }
-
-            // PORT ID
-            final String serviceId = NamingUtil.getProperty(ref, 
NamingUtil.WS_ID);
-
-            // Service QName
-            QName serviceQName = null;
-            String property = NamingUtil.getProperty(ref, NamingUtil.WS_QNAME);
-            if (property != null) {
-                serviceQName = QName.valueOf(property);
-            }
-
-            // WSDL URL
-            URL wsdlUrl = null;
-            property = NamingUtil.getProperty(ref, NamingUtil.WSDL_URL);
-            if (property != null) {
-                wsdlUrl = new URL(property);
-            }
-
-            // Port QName
-            QName portQName = null;
-            property = NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME);
-            if (property != null) {
-                portQName = QName.valueOf(property);
-            }
-
-            // port refs
-            List<PortRefData> portRefs = NamingUtil.getStaticValue(ref, 
"port-refs");
-            if (portRefs == null) {
-                portRefs = Collections.emptyList();
-            }
-
-            // HandlerChain
-            List<HandlerChainData> handlerChains = 
NamingUtil.getStaticValue(ref, "handler-chains");
-            if (handlerChains == null) {
-                handlerChains = Collections.emptyList();
-            }
-            Collection<Injection> injections = NamingUtil.getStaticValue(ref, 
"injections");
-            if (injections == null) {
-                injections = Collections.emptyList();
-            }
-
-            final Properties properties = new Properties();
-            properties.putAll(environment);
-            final JaxWsServiceReference serviceReference = new 
JaxWsServiceReference(serviceId,
-                    serviceQName,
-                    serviceClass, portQName,
-                    referenceClass,
-                    wsdlUrl,
-                    portRefs,
-                    handlerChains,
-                    injections,
-                    properties);
-            value = serviceReference.getObject();
-        }
-
-        return value;
-    }
-
-    protected String buildJndiName(final Reference reference) throws 
NamingException {
-        throw new UnsupportedOperationException();
-    }
-}
+/**
+ *
+ * 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.tomee.common;
+
+import org.apache.naming.ResourceRef;
+import org.apache.openejb.Injection;
+import org.apache.openejb.core.ivm.naming.JaxWsServiceReference;
+import org.apache.openejb.core.webservices.HandlerChainData;
+import org.apache.openejb.core.webservices.PortRefData;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Properties;
+
+public class WsFactory extends AbstractObjectFactory {
+    public Object getObjectInstance(final Object object, final Name name, 
final Context context, final Hashtable environment) throws Exception {
+        // ignore non resource-refs
+        if (!(object instanceof ResourceRef)) {
+            return null;
+        }
+
+        final Reference ref = (Reference) object;
+
+        final Object value;
+        if (NamingUtil.getProperty(ref, NamingUtil.JNDI_NAME) != null) {
+            // lookup the value in JNDI
+            value = super.getObjectInstance(object, name, context, 
environment);
+        } else {
+            // load service class which is used to construct the port
+            final String serviceClassName = NamingUtil.getProperty(ref, 
NamingUtil.WS_CLASS);
+            Class<? extends Service> serviceClass = Service.class;
+            if (serviceClassName != null) {
+                final Class<?> loadClass = 
NamingUtil.loadClass(serviceClassName);
+
+                if (loadClass == null) {
+                    throw new NamingException("Could not load service type 
class "+ serviceClassName);
+                }
+
+                serviceClass = loadClass.asSubclass(Service.class);
+            }
+
+            // load the reference class which is the ultimate type of the port
+            final Class<?> referenceClass = 
NamingUtil.loadClass(ref.getClassName());
+
+            // if ref class is a subclass of Service, use it for the service 
class
+            if (referenceClass != null && 
Service.class.isAssignableFrom(referenceClass)) {
+                serviceClass = referenceClass.asSubclass(Service.class);
+            }
+
+            // PORT ID
+            final String serviceId = NamingUtil.getProperty(ref, 
NamingUtil.WS_ID);
+
+            // Service QName
+            QName serviceQName = null;
+            String property = NamingUtil.getProperty(ref, NamingUtil.WS_QNAME);
+            if (property != null) {
+                serviceQName = QName.valueOf(property);
+            }
+
+            // WSDL URL
+            URL wsdlUrl = null;
+            property = NamingUtil.getProperty(ref, NamingUtil.WSDL_URL);
+            if (property != null) {
+                wsdlUrl = new URL(property);
+            }
+
+            // Port QName
+            QName portQName = null;
+            property = NamingUtil.getProperty(ref, NamingUtil.WS_PORT_QNAME);
+            if (property != null) {
+                portQName = QName.valueOf(property);
+            }
+
+            // port refs
+            List<PortRefData> portRefs = NamingUtil.getStaticValue(ref, 
"port-refs");
+            if (portRefs == null) {
+                portRefs = Collections.emptyList();
+            }
+
+            // HandlerChain
+            List<HandlerChainData> handlerChains = 
NamingUtil.getStaticValue(ref, "handler-chains");
+            if (handlerChains == null) {
+                handlerChains = Collections.emptyList();
+            }
+            Collection<Injection> injections = NamingUtil.getStaticValue(ref, 
"injections");
+            if (injections == null) {
+                injections = Collections.emptyList();
+            }
+
+            final Properties properties = new Properties();
+            properties.putAll(environment);
+            final JaxWsServiceReference serviceReference = new 
JaxWsServiceReference(serviceId,
+                    serviceQName,
+                    serviceClass, portQName,
+                    referenceClass,
+                    wsdlUrl,
+                    portRefs,
+                    handlerChains,
+                    injections,
+                    properties);
+            value = serviceReference.getObject();
+        }
+
+        return value;
+    }
+
+    protected String buildJndiName(final Reference reference) throws 
NamingException {
+        throw new UnsupportedOperationException();
+    }
+}

Reply via email to