tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r591858 [4/13] - in /openejb/trunk/openejb3: ./ assembly/openejb-tomcat/ assembly/openejb-tomcat/src/main/java/org/apache/openejb/tomcat/ container/openejb-core/ container/openejb-core/src/main/java/org/apache/openejb/ container/openejb-cor...
Date Sun, 04 Nov 2007 22:42:06 GMT
Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortData.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,122 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import org.apache.openejb.Injection;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.PortInfo;
+import java.util.List;
+import java.util.ArrayList;
+import java.net.URL;
+
+public class PortData implements PortInfo {
+    private QName serviceName;
+    private QName portName;
+    private String bindingId;
+
+    private URL wsdlUrl;
+    private final List<HandlerChainData> handlerChains = new ArrayList<HandlerChainData>();
+    private final List<Injection> injections = new ArrayList<Injection>();
+    private boolean mtomEnabled;
+    private QName wsdlPort;
+    private QName wsdlService;
+    private String location;
+    private String wsdlPublishLocation;
+
+
+    public QName getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(QName serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public QName getPortName() {
+        return portName;
+    }
+
+    public void setPortName(QName portName) {
+        this.portName = portName;
+    }
+
+    public String getBindingID() {
+        return bindingId;
+    }
+
+    public void setBindingID(String bindingId) {
+        this.bindingId = bindingId;
+    }
+
+    public URL getWsdlUrl() {
+        return wsdlUrl;
+    }
+
+    public void setWsdlUrl(URL wsdlUrl) {
+        this.wsdlUrl = wsdlUrl;
+    }
+
+    public List<HandlerChainData> getHandlerChains() {
+        return handlerChains;
+    }
+
+    public List<Injection> getInjections() {
+        return injections;
+    }
+
+    public boolean isMtomEnabled() {
+        return mtomEnabled;
+    }
+
+    public void setMtomEnabled(boolean mtomEnabled) {
+        this.mtomEnabled = mtomEnabled;
+    }
+
+    public QName getWsdlPort() {
+        return wsdlPort;
+    }
+
+    public void setWsdlPort(QName wsdlPort) {
+        this.wsdlPort = wsdlPort;
+    }
+
+    public QName getWsdlService() {
+        return wsdlService;
+    }
+
+    public void setWsdlService(QName wsdlService) {
+        this.wsdlService = wsdlService;
+    }
+
+    public String getLocation() {
+        return location;
+    }
+
+    public void setLocation(String location) {
+        this.location = location;
+    }
+
+    public String getWsdlPublishLocation() {
+        return wsdlPublishLocation;
+    }
+
+    public void setWsdlPublishLocation(String wsdlPublishLocation) {
+        this.wsdlPublishLocation = wsdlPublishLocation;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortRefData.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortRefData.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortRefData.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/PortRefData.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,56 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import java.util.Properties;
+import java.util.List;
+
+public class PortRefData {
+    private Class serviceEndpointInterface;
+    private boolean enableMtom;
+    private String portComponentLink;
+    private final Properties properties = new Properties();
+
+    public Class getServiceEndpointInterface() {
+        return serviceEndpointInterface;
+    }
+
+    public void setServiceEndpointInterface(Class serviceEndpointInterface) {
+        this.serviceEndpointInterface = serviceEndpointInterface;
+    }
+
+    public boolean isEnableMtom() {
+        return enableMtom;
+    }
+
+    public void setEnableMtom(boolean value) {
+        this.enableMtom = value;
+    }
+
+    public String getPortComponentLink() {
+        return portComponentLink;
+    }
+
+    public void setPortComponentLink(String value) {
+        this.portComponentLink = value;
+    }
+
+    public Properties getProperties() {
+        return properties;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ProviderWrapper.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,342 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.LogCategory;
+
+import javax.xml.ws.spi.Provider;
+import javax.xml.ws.spi.ServiceDelegate;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.handler.HandlerResolver;
+import javax.xml.namespace.QName;
+import javax.xml.bind.JAXBContext;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.List;
+import java.util.Properties;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.concurrent.Executor;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+
+public class ProviderWrapper extends Provider {
+    public static final Logger logger = Logger.getInstance(LogCategory.OPENEJB_WS, ProviderWrapper.class);
+
+    //
+    // Magic to get our proider wrapper installed with the PortRefData
+    //
+
+    private static ThreadLocal<ProviderWrapperData> threadPortRefs = new ThreadLocal<ProviderWrapperData>();
+
+    public static void beforeCreate(List<PortRefData> portRefData) {
+        // Axis JAXWS api is non compliant and checks system property before classloader
+        // so we replace system property so this wrapper is selected.  The original value
+        // is saved into an openejb property so we can load the class in the find method
+        String oldProperty = System.getProperty(JAXWSPROVIDER_PROPERTY);
+        if (oldProperty != null && !oldProperty.equals(ProviderWrapper.class.getName())) {
+            System.setProperty("openejb." + JAXWSPROVIDER_PROPERTY, oldProperty);
+            System.setProperty(JAXWSPROVIDER_PROPERTY, ProviderWrapper.class.getName());
+        }
+
+        ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        if (oldClassLoader != null) {
+            Thread.currentThread().setContextClassLoader(new ProviderClassLoader(oldClassLoader));
+        } else {
+            Thread.currentThread().setContextClassLoader(new ProviderClassLoader());
+        }
+        threadPortRefs.set(new ProviderWrapperData(portRefData, oldClassLoader));
+    }
+
+    public static void afterCreate() {
+        Thread.currentThread().setContextClassLoader(threadPortRefs.get().callerClassLoader);
+        threadPortRefs.set(null);
+    }
+
+    private static class ProviderWrapperData {
+        private final List<PortRefData> portRefData;
+        private final ClassLoader callerClassLoader;
+
+        public ProviderWrapperData(List<PortRefData> portRefData, ClassLoader callerClassLoader) {
+            this.portRefData = portRefData;
+            this.callerClassLoader = callerClassLoader;
+        }
+    }
+
+
+    //
+    // Provider wappre implementation
+    //
+
+    private final Provider delegate;
+    private final List<PortRefData> portRefs;
+
+    public ProviderWrapper() {
+        delegate = findProvider();
+        portRefs = threadPortRefs.get().portRefData;
+    }
+
+    public Provider getDelegate() {
+        return delegate;
+    }
+
+    public ServiceDelegate createServiceDelegate(URL wsdlDocumentLocation, QName serviceName, Class serviceClass) {
+        ServiceDelegate serviceDelegate = delegate.createServiceDelegate(wsdlDocumentLocation, serviceName, serviceClass);
+        serviceDelegate = new ServiceDelegateWrapper(serviceDelegate);
+        return serviceDelegate;
+    }
+
+    public Endpoint createEndpoint(String bindingId, Object implementor) {
+        return delegate.createEndpoint(bindingId, implementor);
+    }
+
+    public Endpoint createAndPublishEndpoint(String address, Object implementor) {
+        return delegate.createAndPublishEndpoint(address, implementor);
+    }
+
+    private class ServiceDelegateWrapper extends ServiceDelegate {
+        private final ServiceDelegate serviceDelegate;
+
+        public ServiceDelegateWrapper(ServiceDelegate serviceDelegate) {
+            this.serviceDelegate = serviceDelegate;
+        }
+
+        public <T> T getPort(QName portName, Class<T> serviceEndpointInterface) {
+            T t = serviceDelegate.getPort(portName, serviceEndpointInterface);
+            setProperties((BindingProvider) t);
+            return t;
+        }
+
+        public <T> T getPort(Class<T> serviceEndpointInterface) {
+            T t = serviceDelegate.getPort(serviceEndpointInterface);
+            setProperties((BindingProvider) t);
+            return t;
+        }
+
+        public void addPort(QName portName, String bindingId, String endpointAddress) {
+            serviceDelegate.addPort(portName, bindingId, endpointAddress);
+        }
+
+        public <T> Dispatch<T> createDispatch(QName portName, Class<T> type, Service.Mode mode) {
+            Dispatch<T> dispatch = serviceDelegate.createDispatch(portName, type, mode);
+            setProperties(dispatch);
+            return dispatch;
+        }
+
+        public Dispatch<Object> createDispatch(QName portName, JAXBContext context, Service.Mode mode) {
+            Dispatch<Object> dispatch = serviceDelegate.createDispatch(portName, context, mode);
+            setProperties(dispatch);
+            return dispatch;
+        }
+
+        public QName getServiceName() {
+            QName qName = serviceDelegate.getServiceName();
+            return qName;
+        }
+
+        public Iterator<QName> getPorts() {
+            Iterator<QName> ports = serviceDelegate.getPorts();
+            return ports;
+        }
+
+        public URL getWSDLDocumentLocation() {
+            URL documentLocation = serviceDelegate.getWSDLDocumentLocation();
+            return documentLocation;
+        }
+
+        public HandlerResolver getHandlerResolver() {
+            HandlerResolver handlerResolver = serviceDelegate.getHandlerResolver();
+            return handlerResolver;
+        }
+
+        public void setHandlerResolver(HandlerResolver handlerResolver) {
+            serviceDelegate.setHandlerResolver(handlerResolver);
+        }
+
+        public Executor getExecutor() {
+            Executor executor = serviceDelegate.getExecutor();
+            return executor;
+        }
+
+        public void setExecutor(Executor executor) {
+            serviceDelegate.setExecutor(executor);
+        }
+
+        private void setProperties(BindingProvider proxy) {
+            for (PortRefData portRef : portRefs) {
+                if (portRef.getServiceEndpointInterface().isInstance(proxy)) {
+                    // set mtom
+                    boolean enableMTOM = portRef.isEnableMtom();
+                    if (enableMTOM && proxy.getBinding() instanceof SOAPBinding) {
+                        ((SOAPBinding)proxy.getBinding()).setMTOMEnabled(enableMTOM);
+                    }
+
+                    // set properties
+                    for (Map.Entry<Object, Object> entry : portRef.getProperties().entrySet()) {
+                        String name = (String) entry.getKey();
+                        String value = (String) entry.getValue();
+                        proxy.getRequestContext().put(name, value);
+                    }
+
+                    return;
+                }
+            }
+        }
+    }
+
+    private static Provider findProvider() {
+        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+        if (classLoader == null) classLoader = ClassLoader.getSystemClassLoader();
+
+        // 0. System.getProperty("openejb.javax.xml.ws.spi.Provider")
+        // This is so those using old axis rules still work as expected
+        String providerClass = System.getProperty("openejb." + JAXWSPROVIDER_PROPERTY);
+        Provider provider = createProviderInstance(providerClass, classLoader);
+        if (provider != null) {
+            return provider;
+        }
+
+        // 1. META-INF/services/javax.xml.ws.spi.Provider
+        try {
+            for (URL url : Collections.list(classLoader.getResources("META-INF/services/" + JAXWSPROVIDER_PROPERTY))) {
+                BufferedReader in = null;
+                try {
+                    in = new BufferedReader(new InputStreamReader(url.openStream()));
+
+                    providerClass = in.readLine();
+                    provider = createProviderInstance(providerClass, classLoader);
+                    if (provider != null) {
+                        return provider;
+                    }
+                } catch (Exception ignored) {
+                } finally {
+                    if (in != null) {
+                        try {
+                            in.close();
+                        } catch (IOException e) {
+                        }
+                    }
+                }
+            }
+        } catch (Exception ingored) {
+        }
+
+        // 2. $java.home/lib/jaxws.properties
+        String javaHome = System.getProperty("java.home");
+        File jaxrpcPropertiesFile = new File(new File(javaHome, "lib"), "jaxrpc.properties");
+        if (jaxrpcPropertiesFile.exists()) {
+            InputStream in = null;
+            try {
+                in = new FileInputStream(jaxrpcPropertiesFile);
+                Properties properties = new Properties();
+                properties.load(in);
+
+                providerClass = properties.getProperty(JAXWSPROVIDER_PROPERTY);
+                provider = createProviderInstance(providerClass, classLoader);
+                if (provider != null) {
+                    return provider;
+                }
+            } catch(Exception ignored) {
+            } finally {
+                if (in != null) {
+                    try {
+                        in.close();
+                    } catch (IOException e) {
+                    }
+                }
+            }
+        }
+
+        // 3. System.getProperty("javax.xml.ws.spi.Provider")
+        providerClass = System.getProperty(JAXWSPROVIDER_PROPERTY);
+        provider = createProviderInstance(providerClass, classLoader);
+        if (provider != null) {
+            return provider;
+        }
+
+        throw new WebServiceException("No " + JAXWSPROVIDER_PROPERTY + " implementation found");
+    }
+
+    private static Provider createProviderInstance(String providerClass, ClassLoader classLoader) {
+        if (providerClass != null && providerClass.length() > 0 && !providerClass.equals(ProviderWrapper.class.getName())) {
+            try {
+                Class<? extends Provider> clazz = classLoader.loadClass(providerClass).asSubclass(Provider.class);
+                return clazz.newInstance();
+            } catch (Throwable e) {
+                logger.warning("Unable to construct provider implementation " + providerClass, e);
+            }
+        }
+        return null;
+    }
+
+    private static class ProviderClassLoader extends ClassLoader {
+        private static final String PROVIDER_RESOURCE = "META-INF/services/" + JAXWSPROVIDER_PROPERTY;
+        private static final URL PROVIDER_URL;
+        static {
+            try {
+                File tempFile = File.createTempFile("openejb-jaxws-provider", "tmp");
+                OutputStream out = new FileOutputStream(tempFile);
+                out.write(ProviderWrapper.class.getName().getBytes());
+                out.close();
+                PROVIDER_URL = tempFile.toURL();
+            } catch (IOException e) {
+                throw new RuntimeException("Cound not create openejb-jaxws-provider file");
+            }
+        }
+
+        public ProviderClassLoader() {
+        }
+
+        public ProviderClassLoader(ClassLoader parent) {
+            super(parent);
+        }
+
+        public Enumeration<URL> getResources(String name) throws IOException {
+            Enumeration<URL> resources = super.getResources(name);
+            if (PROVIDER_RESOURCE.equals(name)) {
+                ArrayList<URL> list = new ArrayList<URL>();
+                list.add(PROVIDER_URL);
+                list.addAll(Collections.list(resources));
+                resources = Collections.enumeration(list);
+            }
+            return resources;
+        }
+
+
+        public URL getResource(String name) {
+            if (PROVIDER_RESOURCE.equals(name)) {
+                return PROVIDER_URL;
+            }
+            return super.getResource(name);
+        }
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ServiceRefData.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ServiceRefData.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ServiceRefData.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/ServiceRefData.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,87 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.WeakHashMap;
+
+public class ServiceRefData {
+    private static final WeakHashMap<Object,ServiceRefData> registry = new WeakHashMap<Object,ServiceRefData>();
+
+    public static ServiceRefData getServiceRefData(Object key) {
+        return registry.get(key);
+    }
+
+    public static ServiceRefData putServiceRefData(Object key, ServiceRefData value) {
+        return registry.put(key, value);
+    }
+
+    private final Class<? extends Service> serviceClass;
+    private final Class<?> referenceClass;
+    private final URL wsdlURL;
+    private final QName serviceQName;
+    private final String wsdlRepoUri;
+    private final List<HandlerChainData> handlerChains = new ArrayList<HandlerChainData>();
+    private final List<PortRefData> portRefs = new ArrayList<PortRefData>();
+
+    public ServiceRefData(Class<? extends Service> serviceClass, Class<?> referenceClass, URL wsdlURL, QName serviceQName, String wsdlRepoUri, List<HandlerChainData> handlerChains, List<PortRefData> portRefs) {
+        this.wsdlRepoUri = wsdlRepoUri;
+        this.serviceClass = serviceClass;
+        this.referenceClass = referenceClass;
+        this.serviceQName = serviceQName;
+        this.wsdlURL = wsdlURL;
+        if (handlerChains != null) {
+            this.handlerChains.addAll(handlerChains);
+        }
+        if (portRefs != null) {
+            this.portRefs.addAll(portRefs);
+        }
+    }
+
+    public Class<? extends Service> getServiceClass() {
+        return serviceClass;
+    }
+
+    public Class<?> getReferenceClass() {
+        return referenceClass;
+    }
+
+    public URL getWsdlURL() {
+        return wsdlURL;
+    }
+
+    public QName getServiceQName() {
+        return serviceQName;
+    }
+
+    public String getWsdlRepoUri() {
+        return wsdlRepoUri;
+    }
+
+    public List<HandlerChainData> getHandlerChains() {
+        return handlerChains;
+    }
+
+    public List<PortRefData> getPortRefs() {
+        return portRefs;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/UriResolver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/UriResolver.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/UriResolver.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/UriResolver.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,341 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import org.apache.openejb.util.Base64;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+/**
+ * Resolves a File, classpath resource, or URL according to the follow rules:
+ * <ul>
+ * <li>Check to see if a file exists, relative to the base URI.</li>
+ * <li>If the file doesn't exist, check the classpath</li>
+ * <li>If the classpath doesn't exist, try to create URL from the URI.</li>
+ * </ul>
+ */
+// Imported from CXF
+public class UriResolver {
+    private File file;
+    private URI uri;
+    private URL url;
+    private InputStream is;
+    private Class calling;
+
+    public UriResolver() {
+    }
+
+    public UriResolver(String path) throws IOException {
+        this("", path);
+    }
+
+    public UriResolver(String baseUriStr, String uriStr) throws IOException {
+        this(baseUriStr, uriStr, null);
+    }
+
+    public UriResolver(String baseUriStr, String uriStr, Class calling) throws IOException {
+        this.calling = (calling != null) ? calling : getClass();
+        if (uriStr.startsWith("classpath:")) {
+            tryClasspath(uriStr);
+        } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) {
+            tryJar(baseUriStr, uriStr);
+        } else if (uriStr.startsWith("jar:")) {
+            tryJar(uriStr);
+        } else {
+            tryFileSystem(baseUriStr, uriStr);
+        }
+    }
+
+
+    public void resolve(String baseUriStr, String uriStr, Class callingCls) throws IOException {
+        this.calling = (callingCls != null) ? callingCls : getClass();
+        this.file = null;
+        this.uri = null;
+
+        this.is = null;
+
+        if (uriStr.startsWith("classpath:")) {
+            tryClasspath(uriStr);
+        } else if (baseUriStr != null && baseUriStr.startsWith("jar:")) {
+            tryJar(baseUriStr, uriStr);
+        } else if (uriStr.startsWith("jar:")) {
+            tryJar(uriStr);
+        } else {
+            tryFileSystem(baseUriStr, uriStr);
+        }
+    }
+
+
+
+    private void tryFileSystem(String baseUriStr, String uriStr) throws IOException, MalformedURLException {
+        try {
+            URI relative;
+            File uriFile = new File(uriStr);
+            uriFile = new File(uriFile.getAbsolutePath());
+
+            if (uriFile.exists()) {
+                relative = uriFile.toURI();
+            } else {
+                relative = new URI(uriStr.replaceAll(" ", "%20"));
+            }
+
+            if (relative.isAbsolute()) {
+                uri = relative;
+                url = relative.toURL();
+
+                try {
+                    HttpURLConnection huc = (HttpURLConnection)url.openConnection();
+
+                    String host = System.getProperty("http.proxyHost");
+                    if (host != null) {
+                        //comment out unused port to pass pmd check
+                        /*String ports = System.getProperty("http.proxyPort");
+                        int port = 80;
+                        if (ports != null) {
+                            port = Integer.parseInt(ports);
+                        }*/
+
+                        String username = System.getProperty("http.proxy.user");
+                        String password = System.getProperty("http.proxy.password");
+
+                        if (username != null && password != null) {
+                            String encoded = new String(Base64.encodeBase64((username + ":" + password).getBytes()));
+                            huc.setRequestProperty("Proxy-Authorization", "Basic " + encoded);
+                        }
+                    }
+                    is =  huc.getInputStream();
+                } catch (ClassCastException ex) {
+                    is = url.openStream();
+                }
+            } else if (baseUriStr != null) {
+                URI base;
+                File baseFile = new File(baseUriStr);
+
+                if (!baseFile.exists() && baseUriStr.startsWith("file:/")) {
+                    baseFile = new File(baseUriStr.substring(6));
+                }
+
+                if (baseFile.exists()) {
+                    base = baseFile.toURI();
+                } else {
+                    base = new URI(baseUriStr);
+                }
+
+                base = base.resolve(relative);
+                if (base.isAbsolute()) {
+                    try {
+                        baseFile = new File(base);
+                        if (baseFile.exists()) {
+                            is = base.toURL().openStream();
+                            uri = base;
+                        } else {
+                            tryClasspath(base.toString().startsWith("file:")
+                                         ? base.toString().substring(5) : base.toString());
+                        }
+                    } catch (Throwable th) {
+                        tryClasspath(base.toString().startsWith("file:")
+                                     ? base.toString().substring(5) : base.toString());
+                    }
+                }
+            }
+        } catch (URISyntaxException e) {
+            // do nothing
+        }
+
+        if (uri != null && "file".equals(uri.getScheme())) {
+            try {
+                file = new File(uri);
+            } catch (IllegalArgumentException iae) {
+                file = new File(uri.toURL().getPath());
+                if (!file.exists()) {
+                    file = null;
+                }
+            }
+        }
+
+        if (is == null && file != null && file.exists()) {
+            uri = file.toURI();
+            try {
+                is = new FileInputStream(file);
+            } catch (FileNotFoundException e) {
+                throw new RuntimeException("File was deleted! " + uriStr, e);
+            }
+            url = file.toURI().toURL();
+        } else if (is == null) {
+            tryClasspath(uriStr);
+        }
+    }
+
+    private void tryJar(String baseStr, String uriStr) throws IOException {
+        int i = baseStr.indexOf('!');
+        if (i == -1) {
+            tryFileSystem(baseStr, uriStr);
+        }
+
+        String jarBase = baseStr.substring(0, i + 1);
+        String jarEntry = baseStr.substring(i + 1);
+        try {
+            URI u = new URI(jarEntry).resolve(uriStr);
+
+            tryJar(jarBase + u.toString());
+
+            if (is != null) {
+                if (u.isAbsolute()) {
+                    url = u.toURL();
+                }
+                return;
+            }
+        } catch (URISyntaxException e) {
+            // do nothing
+        }
+
+        tryFileSystem("", uriStr);
+    }
+
+    private void tryJar(String uriStr) throws IOException {
+        int i = uriStr.indexOf('!');
+        if (i == -1) {
+            return;
+        }
+
+        url = new URL(uriStr);
+        try {
+            is = url.openStream();
+            try {
+                uri = url.toURI();
+            } catch (URISyntaxException ex) {
+                // ignore
+            }
+        } catch (IOException e) {
+            uriStr = uriStr.substring(i + 1);
+            tryClasspath(uriStr);
+        }
+    }
+
+    private void tryClasspath(String uriStr) throws IOException {
+        if (uriStr.startsWith("classpath:")) {
+            uriStr = uriStr.substring(10);
+        }
+        url = getResource(uriStr, calling);
+        if (url == null) {
+            tryRemote(uriStr);
+        } else {
+            try {
+                uri = url.toURI();
+            } catch (URISyntaxException e) {
+                // processing the jar:file:/ type value
+                String urlStr = url.toString();
+                if (urlStr.startsWith("jar:")) {
+                    int pos = urlStr.indexOf('!');
+                    if (pos != -1) {
+                        try {
+                            uri = new URI("classpath:" + urlStr.substring(pos + 1));
+                        } catch (URISyntaxException ue) {
+                            // ignore
+                        }
+                    }
+                }
+
+            }
+            is = url.openStream();
+        }
+    }
+
+    private void tryRemote(String uriStr) throws IOException {
+        try {
+            url = new URL(uriStr);
+            uri = new URI(url.toString());
+            is = url.openStream();
+        } catch (MalformedURLException e) {
+            // do nothing
+        } catch (URISyntaxException e) {
+            // do nothing
+        }
+    }
+
+    public URI getURI() {
+        return uri;
+    }
+
+    public URL getURL() {
+        return url;
+    }
+
+    public InputStream getInputStream() {
+        return is;
+    }
+
+    public boolean isFile() {
+        return file != null && file.exists();
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public boolean isResolved() {
+        return is != null;
+    }
+
+    /**
+     * Load a given resource. <p/> This method will try to load the resource
+     * using the following methods (in order):
+     * <ul>
+     * <li>From Thread.currentThread().getContextClassLoader()
+     * <li>From ClassLoaderUtil.class.getClassLoader()
+     * <li>callingClass.getClassLoader()
+     * </ul>
+     *
+     * @param resourceName The name of the resource to load
+     * @param callingClass The Class object of the calling object
+     */
+    public static URL getResource(String resourceName, Class callingClass) {
+        URL url = Thread.currentThread().getContextClassLoader().getResource(resourceName);
+
+        if (url == null) {
+            url = UriResolver.class.getClassLoader().getResource(resourceName);
+        }
+
+        if (url == null) {
+            ClassLoader cl = callingClass.getClassLoader();
+
+            if (cl != null) {
+                url = cl.getResource(resourceName);
+            }
+        }
+
+        if (url == null) {
+            url = callingClass.getResource(resourceName);
+        }
+
+        if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
+            return getResource('/' + resourceName, callingClass);
+        }
+
+        return url;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepo.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepo.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepo.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,26 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import javax.xml.namespace.QName;
+
+public interface WsdlRepo {
+    void addWsdl(String wsdlRepoUri, QName serviceQname, String serviceInterface, String address);
+    void removeWsdl(String wsdlRepoUri, QName serviceQname, String serviceInterface, String address);
+    String getWsdl(String wsdlRepoUri, QName serviceQname, String serviceInterface);
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepoImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepoImpl.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepoImpl.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlRepoImpl.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,137 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import javax.xml.namespace.QName;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+public class WsdlRepoImpl implements WsdlRepo {
+    private Map<String, Set<String>> addressesByWsdlUri = new TreeMap<String, Set<String>>();
+    private Map<QName, Set<String>> addressesByQNames = new HashMap<QName, Set<String>>();
+    private Map<String, Set<String>> addressesByInterface = new TreeMap<String, Set<String>>();
+
+    public synchronized void addWsdl(String wsdlRepoUri, QName qname, String intf, String address) {
+        addAddress(addressesByWsdlUri, wsdlRepoUri, address);
+        addAddress(addressesByQNames, qname, address);
+        addAddress(addressesByInterface, intf, address);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    private synchronized void addAddress(Map addressesMap, Object key, String address) {
+        if (key == null) return;
+        Set<String> strings = (Set<String>) addressesMap.get(key);
+        if (strings == null) {
+            strings = new TreeSet<String>();
+            addressesMap.put(key, strings);
+        }
+        strings.add(address);
+    }
+
+    public synchronized void removeWsdl(String wsdlRepoUri, QName qname, String intf, String address) {
+        removeAddress(addressesByWsdlUri, wsdlRepoUri, address);
+        removeAddress(addressesByQNames, qname, address);
+        removeAddress(addressesByInterface, intf, address);
+    }
+
+    @SuppressWarnings({"unchecked"})
+    private synchronized void removeAddress(Map addressesMap, Object key, String address) {
+        if (key == null) return;
+        Set<String> strings = (Set<String>) addressesMap.get(key);
+        if (strings != null) {
+            strings.remove(address);
+            if (strings.isEmpty()) {
+                addressesMap.remove(key);
+            }
+        }
+    }
+
+    public synchronized String getWsdl(String wsdlRepoUri, QName qname, String intf) {
+        // ServiceInterface
+        Set<String> intfAddresses = addressesByInterface.get(intf);
+        String address = getSingleAddress(intfAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // ServiceQName
+        Set<String> qnameAddresses = addressesByQNames.get(qname);
+        address = getSingleAddress(qnameAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // WsdlUri
+        Set<String> wsdlUriAddresses = addressesByWsdlUri.get(wsdlRepoUri);
+        address = getSingleAddress(wsdlUriAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // ServiceInterface + ServiceQName
+        address = getUniqueAddress(intfAddresses, qnameAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // WsdlUri + ServiceInterface
+        address = getUniqueAddress(wsdlUriAddresses, intfAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // WsdlUri + ServiceQName
+        address = getUniqueAddress(wsdlUriAddresses, qnameAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        // WsdlUri + ServiceInterface + ServiceQName
+        address = getUniqueAddress(wsdlUriAddresses, intfAddresses, qnameAddresses);
+        if (address != null) {
+            return address;
+        }
+
+        return null;
+    }
+
+    private String getSingleAddress(Set<String> addresses) {
+        if (addresses != null && addresses.size() == 1) {
+            return addresses.iterator().next();
+        }
+        return null;
+    }
+
+    private String getUniqueAddress(Set<String>... addressSets) {
+        if (addressSets.length < 2) return null;
+        if (addressSets[0] == null) return null;
+
+        Set<String> addresses = new HashSet<String>();
+        addresses.addAll(addressSets[0]);
+        for (Set<String> addressSet : addressSets) {
+            if (addressSet != null) {
+                addresses.retainAll(addressSet);
+            }
+        }
+        return getSingleAddress(addresses);
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlResolver.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlResolver.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlResolver.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/webservices/WsdlResolver.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,98 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import org.xml.sax.InputSource;
+
+import javax.wsdl.xml.WSDLLocator;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+import java.io.File;
+import java.io.IOException;
+
+public class WsdlResolver implements WSDLLocator {
+    private String baseUri;
+    private String importedUri;
+    private InputSource inputSource;
+
+    public WsdlResolver(String baseURI, InputSource is) {
+        this.baseUri = baseURI;
+        inputSource = is;
+    }
+
+    public InputSource getBaseInputSource() {
+        return inputSource;
+    }
+
+    public String getBaseURI() {
+        return baseUri;
+    }
+
+    public String getLatestImportURI() {
+        return importedUri;
+    }
+
+    public InputSource getImportInputSource(String parent, String importLocation) {
+        this.baseUri = parent;
+        URL parentUrl;
+        try {
+            parentUrl = new URL(parent);
+            URL importUrl = new URL(parentUrl, importLocation);
+            if (importUrl != null && !importUrl.getProtocol().startsWith("file")) {
+                URLConnection con = importUrl.openConnection();
+                con.setUseCaches(false);
+                inputSource = new InputSource(con.getInputStream());
+            } else {
+                File file = new File(importUrl.toURI());
+                if (file.exists()) {
+                    UriResolver resolver = new UriResolver(parent.toString(), importLocation);
+                    inputSource = new InputSource(resolver.getInputStream());
+                } else {
+                    UriResolver resolver = new UriResolver(importLocation);
+                    if (resolver.isResolved()) {
+                        inputSource = new InputSource(resolver.getInputStream());
+                    }
+                }
+            }
+            importedUri = importUrl.toURI().toString();
+
+        } catch (MalformedURLException e) {
+            //
+        } catch (URISyntaxException e) {
+            //
+        } catch (IOException e) {
+            //
+
+        }
+        return inputSource;
+
+    }
+
+    public void close() {
+        if (inputSource.getByteStream() != null) {
+            try {
+                inputSource.getByteStream().close();
+            } catch (IOException e) {
+                //
+            }
+        }
+
+    }
+}

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/spi/ContainerSystem.java Sun Nov  4 14:41:49 2007
@@ -18,6 +18,11 @@
 
 import org.apache.openejb.Container;
 import org.apache.openejb.DeploymentInfo;
+import org.apache.openejb.core.WebDeploymentInfo;
+
+import javax.naming.Context;
+import javax.xml.namespace.QName;
+import java.net.URL;
 
 public interface ContainerSystem {
 
@@ -29,5 +34,8 @@
 
     public Container [] containers();
 
-    public javax.naming.Context getJNDIContext();
+    public Context getJNDIContext();
+
+    WebDeploymentInfo getWebDeploymentInfo(String id);
+
 }

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/LogCategory.java Sun Nov  4 14:41:49 2007
@@ -42,11 +42,15 @@
 	public static final LogCategory OPENEJB_CONNECTOR = OPENEJB.createChild("connector");
 	public static final LogCategory OPENEJB_DEPLOY = OPENEJB.createChild("deploy");
 	public static final LogCategory OPENEJB_HSQL = OPENEJB.createChild("hsql");
+	public static final LogCategory OPENEJB_WS = OPENEJB.createChild("ws");
 	public static final LogCategory TRANSACTION = new LogCategory( "Transaction");
 	public static final LogCategory ACTIVEMQ = new LogCategory( "org.apache.activemq");
 	public static final LogCategory GERONIMO = new LogCategory( "org.apache.geronimo");
 	public static final LogCategory OPENJPA = new LogCategory( "openjpa");
 	public static final LogCategory CORBA_ADAPTER = new LogCategory( "CORBA-Adapter");
+	public static final LogCategory AXIS = new LogCategory( "axis");
+	public static final LogCategory AXIS2 = new LogCategory( "axis");
+	public static final LogCategory CXF = new LogCategory( "cxf");
 	public static final LogCategory TIMER = new LogCategory( "Timer");
 	public static final LogCategory HTTPSERVER = new LogCategory( "HttpServer");
 	public static final LogCategory SERVICEPOOL = new LogCategory( "ServicePool");

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/resources/logging.properties
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/logging.properties?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/resources/logging.properties (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/resources/logging.properties Sun Nov  4 14:41:49 2007
@@ -21,11 +21,15 @@
 log4j.category.OpenEJB.startup     = info
 log4j.category.OpenEJB.startup.config = info
 log4j.category.OpenEJB.hsql        = info
+log4j.category.OpenEJB.ws          = info
 log4j.category.CORBA-Adapter       = error,R
 log4j.category.Transaction         = warn,TX
 log4j.category.org.apache.activemq = error,R
 log4j.category.org.apache.geronimo = error,R
 log4j.category.openjpa             = error,R
+log4j.category.axis                 = info,R
+log4j.category.axis2                 = info,R
+log4j.category.cxf                 = info,R
 
 log4j.appender.R=org.apache.log4j.RollingFileAppender
 log4j.appender.R.layout=org.apache.log4j.PatternLayout

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/DependenceValidationTest.java Sun Nov  4 14:41:49 2007
@@ -26,15 +26,10 @@
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
-import java.util.Arrays;
-
 
-/**
- * @version $Rev$ $Date$
- */
 public class DependenceValidationTest extends TestCase {
 
     private Map<String, Map<String, Integer>> depsOfPackages;
@@ -80,7 +75,7 @@
 
     private void assertNotDependentOn(String referringPacakge, String referredPackage, String... exemptionsArray) {
         if (referringPacakge.equals(referredPackage)) return;
-        List exemptions = new ArrayList(Arrays.asList(exemptionsArray));
+        List<String> exemptions = new ArrayList<String>(Arrays.asList(exemptionsArray));
         exemptions.add(referredPackage);
 
         for (Map.Entry<String, Map<String, Integer>> entry : depsOfPackages.entrySet()) {

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/OpenEjbConfigurationValidationTest.java Sun Nov  4 14:41:49 2007
@@ -18,6 +18,7 @@
 
 import junit.framework.TestCase;
 
+import javax.xml.namespace.QName;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -35,7 +36,7 @@
  */
 public class OpenEjbConfigurationValidationTest extends TestCase {
 
-    private List<Class> seen = new ArrayList();
+    private List<Class> seen = new ArrayList<Class>();
 
     public void testValidate() throws Exception {
         seen.add(Object.class);
@@ -94,6 +95,10 @@
             }
 
             if (Properties.class.isAssignableFrom(type)) {
+                continue;
+            }
+
+            if (QName.class.isAssignableFrom(type)) {
                 continue;
             }
 

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/PersistenceUnitRefTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/PersistenceUnitRefTest.java?rev=591858&r1=591857&r2=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/PersistenceUnitRefTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/PersistenceUnitRefTest.java Sun Nov  4 14:41:49 2007
@@ -69,7 +69,7 @@
         emfLinkResolver.add("my/module.jar", "one", new MockEntityManagerFactory());
         emfLinkResolver.add("some/other.jar", "two", new MockEntityManagerFactory());
 
-        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo, null, emfLinkResolver, "my/module.jar");
+        JndiEncBuilder jndiEncBuilder = new JndiEncBuilder(jndiEncInfo, null, null, emfLinkResolver, "my/module.jar", getClass().getClassLoader());
         jndiEncBuilder.build();
     }
 

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/SunConversionTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/SunConversionTest.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/SunConversionTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/config/SunConversionTest.java Sun Nov  4 14:41:49 2007
@@ -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.openejb.config;
+
+import static org.apache.openejb.config.SunConversion.processWsdlPublishLocation;
+import junit.framework.TestCase;
+
+public class SunConversionTest extends TestCase {
+    public void testProcessWsdlPublishLocation() throws Exception {
+        assertEquals("dir/file", processWsdlPublishLocation("file:repo1/dir", "META-INF/wsdl/file.wsdl"));
+        assertEquals("dir/file", processWsdlPublishLocation("file:repo1/dir", "WEB-INF/wsdl/file.wsdl"));
+        assertEquals("dir/META-INF/file", processWsdlPublishLocation("file:repo1/dir", "META-INF/file.wsdl"));
+        assertEquals("dir/WEB-INF/file", processWsdlPublishLocation("file:repo1/dir", "WEB-INF/file.wsdl"));
+        assertEquals("dir/file", processWsdlPublishLocation("file:repo1/dir", "file.wsdl"));
+        assertEquals("dir/file.xml", processWsdlPublishLocation("file:repo1/dir", "META-INF/wsdl/file.xml"));
+        assertEquals("dir/file.xml", processWsdlPublishLocation("file:repo1/dir", "WEB-INF/wsdl/file.xml"));
+
+        String x = "file:repo1/dir";
+        assertEquals("dir", processWsdlPublishLocation(x));
+        assertEquals("dir/file", processWsdlPublishLocation("file:repo1/dir/file.wsdl"));
+        assertEquals("dir/file.xml", processWsdlPublishLocation("file:repo1/dir/file.xml"));
+        assertEquals(null, processWsdlPublishLocation("file:repo1/"));
+
+        assertEquals("dir/file", processWsdlPublishLocation("http://server.com:port/dir/file?WSDL"));
+        assertEquals("dir/file", processWsdlPublishLocation("http://server.com:port/dir/file?wsdl"));
+        assertEquals("dir/file", processWsdlPublishLocation("http://server.com:port/dir/file?cheese"));
+        assertEquals("dir/file", processWsdlPublishLocation("http://server.com:port/dir/file"));
+        assertEquals("file", processWsdlPublishLocation("http://server.com:port/file?WSDL"));
+        assertEquals("file", processWsdlPublishLocation("http://server.com:port/file?wsdl"));
+        assertEquals("file", processWsdlPublishLocation("http://server.com:port/file?cheese"));
+        assertEquals("file", processWsdlPublishLocation("http://server.com:port/file"));
+        assertEquals(null, processWsdlPublishLocation("http://server.com:port/?WSDL"));
+        assertEquals(null, processWsdlPublishLocation("http://server.com:port/?wsdl"));
+        assertEquals(null, processWsdlPublishLocation("http://server.com:port/?cheese"));
+        assertEquals(null, processWsdlPublishLocation("http://server.com:port/"));
+        assertEquals("dir/file/", processWsdlPublishLocation("http://server.com:port/dir/file/?WSDL"));
+        assertEquals("dir/file/", processWsdlPublishLocation("http://server.com:port/dir/file/?wsdl"));
+        assertEquals("dir/file/", processWsdlPublishLocation("http://server.com:port/dir/file/?cheese"));
+        assertEquals("dir/file/", processWsdlPublishLocation("http://server.com:port/dir/file/"));
+        assertEquals("dir/file", processWsdlPublishLocation("https://server.com:port/dir/file?WSDL"));
+        assertEquals("dir/file", processWsdlPublishLocation("https://server.com:port/dir/file?wsdl"));
+        assertEquals("dir/file", processWsdlPublishLocation("https://server.com:port/dir/file?cheese"));
+        assertEquals("dir/file", processWsdlPublishLocation("https://server.com:port/dir/file"));
+        assertEquals("file", processWsdlPublishLocation("https://server.com:port/file?WSDL"));
+        assertEquals("file", processWsdlPublishLocation("https://server.com:port/file?wsdl"));
+        assertEquals("file", processWsdlPublishLocation("https://server.com:port/file?cheese"));
+        assertEquals("file", processWsdlPublishLocation("https://server.com:port/file"));
+        assertEquals(null, processWsdlPublishLocation("https://server.com:port/?WSDL"));
+        assertEquals(null, processWsdlPublishLocation("https://server.com:port/?wsdl"));
+        assertEquals(null, processWsdlPublishLocation("https://server.com:port/?cheese"));
+        assertEquals(null, processWsdlPublishLocation("https://server.com:port/"));
+        assertEquals("dir/file/", processWsdlPublishLocation("https://server.com:port/dir/file/?WSDL"));
+        assertEquals("dir/file/", processWsdlPublishLocation("https://server.com:port/dir/file/?wsdl"));
+        assertEquals("dir/file/", processWsdlPublishLocation("https://server.com:port/dir/file/?cheese"));
+        assertEquals("dir/file/", processWsdlPublishLocation("https://server.com:port/dir/file/"));
+
+        assertEquals(null, processWsdlPublishLocation(null));
+    }
+}

Copied: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcInvocationTest.java (from r585401, openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcWebServiceInvocationTest.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcInvocationTest.java?p2=openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcInvocationTest.java&p1=openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcWebServiceInvocationTest.java&r1=585401&r2=591858&rev=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcWebServiceInvocationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxRpcInvocationTest.java Sun Nov  4 14:41:49 2007
@@ -59,9 +59,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class JaxRpcWebServiceInvocationTest extends TestCase {
-
-    public void testNothing(){}
+public class JaxRpcInvocationTest extends TestCase {
     public void testWebServiceInvocations() throws Exception {
         System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
 
@@ -100,12 +98,12 @@
         // web service provider.  Instead of writing "fake" marshalling
         // code that would pull the arguments from the soap message, we'll
         // just give it the argument values directly.
-        Object webServiceProviderInterceptor = new FakeWebServiceProviderInterceptor("Hello world");
+        Object wsProviderInterceptor = new FakeWsProviderInterceptor("Hello world");
 
         // Ok, now we have the two arguments expected on a JAX-RPC Web Service
         // invocation as per the OpenEJB-specific agreement between OpenEJB
         // and the Web Service Provider
-        Object[] args = new Object[]{messageContext, webServiceProviderInterceptor};
+        Object[] args = new Object[]{messageContext, wsProviderInterceptor};
 
         // Let's grab the container as the Web Service Provider would do and
         // perform an invocation
@@ -271,14 +269,14 @@
      * Unlike typical EJB Interceptor around invoke methods, the @AroundInvoke
      * annotation must be used and is not optional, and the method must be public.
      */
-    public static class FakeWebServiceProviderInterceptor {
+    public static class FakeWsProviderInterceptor {
 
         /**
          * These would normally come from the soap message
          */
         private final Object[] args;
 
-        public FakeWebServiceProviderInterceptor(Object... args) {
+        public FakeWsProviderInterceptor(Object... args) {
             this.args = args;
         }
 

Copied: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsInvocationTest.java (from r585401, openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsWebServiceInvocationTest.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsInvocationTest.java?p2=openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsInvocationTest.java&p1=openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsWebServiceInvocationTest.java&r1=585401&r2=591858&rev=591858&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsWebServiceInvocationTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/stateless/JaxWsInvocationTest.java Sun Nov  4 14:41:49 2007
@@ -64,9 +64,9 @@
  *
  * @version $Rev$ $Date$
  */
-public class JaxWsWebServiceInvocationTest extends TestCase {
+public class JaxWsInvocationTest extends TestCase {
 
-    public void testWebServiceInvocations() throws Exception {
+    public void testWsInvocations() throws Exception {
         System.setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY, InitContextFactory.class.getName());
 
         ConfigurationFactory config = new ConfigurationFactory();
@@ -104,12 +104,12 @@
         // web service provider.  Instead of writing "fake" marshalling
         // code that would pull the arguments from the soap message, we'll
         // just give it the argument values directly.
-        Object webServiceProviderInterceptor = new FakeWebServiceProviderInterceptor("Hello world");
+        Object wsProviderInterceptor = new FakeWsProviderInterceptor("Hello world");
 
         // Ok, now we have the two arguments expected on a JAX-RPC Web Service
         // invocation as per the OpenEJB-specific agreement between OpenEJB
         // and the Web Service Provider
-        Object[] args = new Object[]{messageContext, webServiceProviderInterceptor};
+        Object[] args = new Object[]{messageContext, wsProviderInterceptor};
 
         // Let's grab the container as the Web Service Provider would do and
         // perform an invocation
@@ -152,6 +152,7 @@
     }
 
     @Interceptors({PlainEjbInterceptor.class})
+    @WebService
     public static class EchoBean {
 
         @Resource
@@ -333,14 +334,14 @@
      * Unlike typical EJB Interceptor around invoke methods, the @AroundInvoke
      * annotation must be used and is not optional, and the method must be public.
      */
-    public static class FakeWebServiceProviderInterceptor {
+    public static class FakeWsProviderInterceptor {
 
         /**
          * These would normally come from the soap message
          */
         private final Object[] args;
 
-        public FakeWebServiceProviderInterceptor(Object... args) {
+        public FakeWsProviderInterceptor(Object... args) {
             this.args = args;
         }
 

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/HandlerResolverImplTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/HandlerResolverImplTest.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/HandlerResolverImplTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/HandlerResolverImplTest.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,195 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import junit.framework.TestCase;
+import org.apache.openejb.jee.HandlerChains;
+import org.apache.openejb.config.ReadDescriptors;
+import org.apache.openejb.config.ConfigurationFactory;
+import org.apache.openejb.assembler.classic.HandlerChainInfo;
+import org.apache.openejb.assembler.classic.WsBuilder;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.PortInfo;
+import javax.xml.namespace.QName;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.net.URL;
+
+public class HandlerResolverImplTest extends TestCase {
+
+    public void testBasic() throws Exception {
+        HandlerChains handlerChains = readHandlerChains("/handlers.xml");
+        assertEquals(3, handlerChains.getHandlerChain().size());
+
+        List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
+        List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
+        HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
+
+        List<Handler> handlers = null;
+
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
+        assertEquals(3, handlers.size());
+    }
+
+    public void testServiceMatching() throws Exception {
+        HandlerChains handlerChains = readHandlerChains("/handlers_service.xml");
+        assertEquals(3, handlerChains.getHandlerChain().size());
+
+        List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
+        List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
+        HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
+
+        List<Handler> handlers = null;
+
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
+        assertEquals(0, handlers.size());
+
+        QName serviceName1 = new QName("http://foo", "Bar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName1));
+        assertEquals(1, handlers.size());
+
+        QName serviceName2 = new QName("http://foo", "Foo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName2));
+        assertEquals(2, handlers.size());
+
+        QName serviceName3 = new QName("http://foo", "FooBar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName3));
+        assertEquals(1, handlers.size());
+
+        QName serviceName4 = new QName("http://foo", "BarFoo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, serviceName4));
+        assertEquals(0, handlers.size());
+    }
+
+    public void testBindingMatching() throws Exception {
+        HandlerChains handlerChains = readHandlerChains("/handlers_bindings.xml");
+        assertEquals(3, handlerChains.getHandlerChain().size());
+
+        List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
+        List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
+        HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
+
+        List<Handler> handlers = null;
+
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
+        assertEquals(0, handlers.size());
+
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP12_HTTP", null, null));
+        assertEquals(0, handlers.size());
+
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP", null, null));
+        assertEquals(2, handlers.size());
+
+        handlers = resolver.getHandlerChain(new TestPortInfo("##SOAP11_HTTP_MTOM", null, null));
+        assertEquals(1, handlers.size());
+    }
+
+    public void testPortMatching() throws Exception {
+        HandlerChains handlerChains = readHandlerChains("/handlers_port.xml");
+        assertEquals(3, handlerChains.getHandlerChain().size());
+
+        List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
+        List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
+        HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
+
+        List<Handler> handlers = null;
+
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
+        assertEquals(0, handlers.size());
+
+        QName portName1 = new QName("http://foo", "Bar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName1, null));
+        assertEquals(1, handlers.size());
+
+        QName portName2 = new QName("http://foo", "Foo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName2, null));
+        assertEquals(2, handlers.size());
+
+        QName portName3 = new QName("http://foo", "FooBar");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName3, null));
+        assertEquals(1, handlers.size());
+
+        QName portName4 = new QName("http://foo", "BarFoo");
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, portName4, null));
+        assertEquals(0, handlers.size());
+    }
+
+    public void testMixedMatching() throws Exception {
+        HandlerChains handlerChains = readHandlerChains("/handlers_mixed.xml");
+        assertEquals(3, handlerChains.getHandlerChain().size());
+
+        List<HandlerChainInfo> handlerChainInfos = ConfigurationFactory.toHandlerChainInfo(handlerChains);
+        List<HandlerChainData> handlerChainDatas = WsBuilder.toHandlerChainData(handlerChainInfos, getClass().getClassLoader());
+        HandlerResolverImpl resolver = new HandlerResolverImpl(handlerChainDatas, null, new InitialContext());
+
+        List<Handler> handlers = null;
+
+        handlers = resolver.getHandlerChain(new TestPortInfo(null, null, null));
+        assertEquals(0, handlers.size());
+
+        QName serviceName1 = new QName("http:/foo", "Bar");
+        QName portName1 = new QName("http://foo", "FooBar");
+        String binding1 = "##XML_HTTP";
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName1, serviceName1));
+        assertEquals(3, handlers.size());
+
+        String binding2 = "##SOAP11_HTTP";
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding2, portName1, serviceName1));
+        assertEquals(2, handlers.size());
+
+        QName serviceName2 = new QName("http://foo", "Baaz");
+        QName portName2 = new QName("http://foo", "Baaz");
+        handlers = resolver.getHandlerChain(new TestPortInfo(binding1, portName2, serviceName2));
+        assertEquals(1, handlers.size());
+    }
+
+    private HandlerChains readHandlerChains(String filePath) throws Exception {
+        URL url = getClass().getResource(filePath);
+        assertNotNull("Could not find handler chains file " + filePath, url);
+        HandlerChains handlerChains = ReadDescriptors.readHandlerChains(url);
+        return handlerChains;
+    }
+
+    private static class TestPortInfo implements PortInfo {
+
+        private String bindingID;
+        private QName portName;
+        private QName serviceName;
+
+        public TestPortInfo(String bindingID, QName portName, QName serviceName) {
+            this.bindingID = bindingID;
+            this.portName = portName;
+            this.serviceName = serviceName;
+        }
+
+        public String getBindingID() {
+            return this.bindingID;
+        }
+
+        public QName getPortName() {
+            return this.portName;
+        }
+
+        public QName getServiceName() {
+            return this.serviceName;
+        }
+
+    }
+
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/ProviderWrapperTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/ProviderWrapperTest.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/ProviderWrapperTest.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/ProviderWrapperTest.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,64 @@
+/**
+ *
+ * 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.openejb.core.webservices;
+
+import junit.framework.TestCase;
+
+import javax.xml.ws.spi.Provider;
+import javax.xml.ws.spi.ServiceDelegate;
+import javax.xml.ws.Endpoint;
+import javax.xml.namespace.QName;
+import java.net.URL;
+
+public class ProviderWrapperTest extends TestCase {
+    public void test() throws Exception {
+        System.setProperty(Provider.JAXWSPROVIDER_PROPERTY, MockProvider.class.getName());
+        Provider provider = Provider.provider();
+        assertNotNull("provider is null", provider);
+        assertFalse("provider should not be an instance of ProviderWrapper", provider instanceof ProviderWrapper);
+
+        ProviderWrapper.beforeCreate(null);
+        try {
+            provider = Provider.provider();
+            assertNotNull("provider is null", provider);
+            assertTrue("provider should be an instance of ProviderWrapper", provider instanceof ProviderWrapper);
+            ProviderWrapper providerWrapper = (ProviderWrapper)provider;
+
+            // check delegate
+            Provider delegate = providerWrapper.getDelegate();
+            assertNotNull("providerWrapper delegate is null", delegate);
+            assertFalse("providerWrapper delegate should not be an instance of ProviderWrapper", delegate instanceof ProviderWrapper);
+        } finally {
+            ProviderWrapper.afterCreate();
+        }
+    }
+
+    public static class MockProvider extends Provider {
+        public ServiceDelegate createServiceDelegate(URL url, QName qName, Class aClass) {
+            return null;
+        }
+
+        public Endpoint createEndpoint(String string, Object object) {
+            return null;
+        }
+
+        public Endpoint createAndPublishEndpoint(String string, Object object) {
+            return null;
+        }
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/TestHandler.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/TestHandler.java?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/TestHandler.java (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/core/webservices/TestHandler.java Sun Nov  4 14:41:49 2007
@@ -0,0 +1,33 @@
+/**
+ *  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.openejb.core.webservices;
+
+import javax.xml.ws.handler.Handler;
+import javax.xml.ws.handler.MessageContext;
+
+public class TestHandler implements Handler {
+    public void close(MessageContext messageContext) {
+    }
+
+    public boolean handleFault(MessageContext messageContext) {
+        return false;
+    }
+
+    public boolean handleMessage(MessageContext messageContext) {
+        return false;
+    }
+}

Added: openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers.xml?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers.xml (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers.xml Sun Nov  4 14:41:49 2007
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev: 482336 $ $Date: 2006-12-04 15:12:19 -0500 (Mon, 04 Dec 2006) $ -->
+
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+    <jws:handler-chain>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+    <jws:handler-chain>
+        <jws:service-name-pattern>*</jws:service-name-pattern>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+    <jws:handler-chain>
+        <jws:port-name-pattern>*</jws:port-name-pattern>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+</jws:handler-chains>

Added: openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers_bindings.xml
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers_bindings.xml?rev=591858&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers_bindings.xml (added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/resources/handlers_bindings.xml Sun Nov  4 14:41:49 2007
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+
+<!-- $Rev: 482336 $ $Date: 2006-12-04 15:12:19 -0500 (Mon, 04 Dec 2006) $ -->
+
+<jws:handler-chains xmlns:jws="http://java.sun.com/xml/ns/javaee">
+    <jws:handler-chain>
+        <jws:protocol-bindings>##XML_HTTP</jws:protocol-bindings>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+    <jws:handler-chain>
+        <jws:protocol-bindings>##SOAP11_HTTP</jws:protocol-bindings>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+    <jws:handler-chain>
+        <jws:protocol-bindings>##SOAP11_HTTP ##SOAP11_HTTP_MTOM</jws:protocol-bindings>
+        <jws:handler>
+            <jws:handler-name>GreeterHandler</jws:handler-name>
+            <jws:handler-class>org.apache.openejb.core.webservices.TestHandler</jws:handler-class>
+        </jws:handler>
+    </jws:handler-chain>
+</jws:handler-chains>



Mime
View raw message