cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r595027 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/resources/META-INF/cxf/ rt/core/src/test/java/org/apache/cxf/endpoint/ rt/frontend/jaxws/src/main/...
Date Wed, 14 Nov 2007 19:57:57 GMT
Author: dkulp
Date: Wed Nov 14 11:57:47 2007
New Revision: 595027

URL: http://svn.apache.org/viewvc?rev=595027&view=rev
Log:
[CXF-1199] ServiceResolver stuff from Jeff

Added:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
  (with props)
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
  (with props)
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
  (with props)
    incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
  (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
  (with props)
    incubator/cxf/trunk/systests/src/test/resources/wsdl/hello_world_resolver.jar   (with
props)
Modified:
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java

Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
(added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,29 @@
+/**
+ * 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.cxf.endpoint;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+public interface ServiceContactResolver {
+    URI getContractLocation(QName qname);
+
+}

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
(added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,32 @@
+/**
+ * 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.cxf.endpoint;
+
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+public interface ServiceContractResolverRegistry {
+    URI getContractLocation(QName qname);
+    void register(ServiceContactResolver resolver);
+    void unregister(ServiceContactResolver resolver);
+    boolean isRegistered(ServiceContactResolver resolver);
+
+}

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistry.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
(added)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,79 @@
+/**
+ * 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.cxf.endpoint;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+
+public class ServiceContractResolverRegistryImpl implements ServiceContractResolverRegistry
{
+
+    private Bus bus;
+    private List<ServiceContactResolver> resolvers;
+
+    /**
+     * Initialize registry, and expose as Bus extension.
+     */
+    @PostConstruct
+    public void init() {
+        resolvers = new ArrayList<ServiceContactResolver>();
+        if (bus != null) {
+            bus.setExtension(this, ServiceContractResolverRegistry.class);
+        }
+    }
+
+    public URI getContractLocation(QName qname) {
+        for (ServiceContactResolver resolver : resolvers) {
+            URI contact = resolver.getContractLocation(qname);
+            if (null != contact) {
+                return contact;
+            }
+        }
+        return null;
+    }
+
+    public boolean isRegistered(ServiceContactResolver resolver) {
+        return resolvers.contains(resolver);
+    }
+
+    public synchronized void register(ServiceContactResolver resolver) {
+        resolvers.add(resolver);
+        
+    }
+
+    public synchronized void unregister(ServiceContactResolver resolver) {
+        resolvers.remove(resolver);
+        
+    }
+
+    public void setBus(Bus bus) {
+        this.bus = bus;
+    }
+    
+    protected List<ServiceContactResolver> getResolvers() {
+        return resolvers;
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?rev=595027&r1=595026&r2=595027&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Wed Nov 14 11:57:47
2007
@@ -115,4 +115,8 @@
     <bean id="org.apache.cxf.catalog.OASISCatalogManager" class="org.apache.cxf.catalog.OASISCatalogManager">
         <property name="bus" ref="cxf"/>
     </bean>
+
+    <bean id="org.apache.cxf.endpoint.ServiceContractResolverRegistry" class="org.apache.cxf.endpoint.ServiceContractResolverRegistryImpl">
+        <property name="bus" ref="cxf"/>
+    </bean>
 </beans>

Added: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
(added)
+++ incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,161 @@
+/**
+ * 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.cxf.endpoint;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ServiceContractResolverRegistryImplTest extends Assert {
+    private ServiceContractResolverRegistryImpl registry;
+    private ServiceContactResolver resolver1;
+    private ServiceContactResolver resolver2;
+    private URI uri1;
+    private URI uri2;
+    private IMocksControl control;
+    private QName serviceName;
+
+    @Before
+    public void setUp() throws URISyntaxException {
+        registry = new ServiceContractResolverRegistryImpl();
+        control = EasyMock.createNiceControl();
+        resolver1 = control.createMock(ServiceContactResolver.class);
+        resolver2 = control.createMock(ServiceContactResolver.class);
+        uri1 = new URI("http://mock");
+        uri2 = new URI("file:///foo/bar");
+
+        serviceName = new QName("namespace", "local");
+    }
+    @After
+    public void tearDown() {
+        resolver1 = null;
+        resolver2 = null;
+        serviceName = null;
+    }
+    
+    @Test
+    public void testInit() {
+        assertNull("unexpected resolvers list", registry.getResolvers());
+        Bus bus = control.createMock(Bus.class);
+        registry.setBus(bus);
+        bus.setExtension(registry, ServiceContractResolverRegistry.class);
+        control.replay();
+        
+        registry.init();
+        
+        assertNotNull("expected resolvers list", registry.getResolvers());
+        control.verify();
+    }
+
+    @Test
+    public void testRegister() {
+        registry.init();
+        assertEquals("unexpected resolver count",
+                     0,
+                     registry.getResolvers().size());
+        
+        registry.register(resolver1);
+        
+        assertEquals("unexpected resolver count",
+                     1,
+                     registry.getResolvers().size());
+        assertTrue("expected resolver to be registered",
+                   registry.getResolvers().contains(resolver1));
+        
+        registry.unregister(resolver1);
+        
+        assertEquals("unexpected resolver count",
+                     0,
+                     registry.getResolvers().size());
+        assertFalse("expected resolver to be registered",
+                    registry.getResolvers().contains(resolver1));
+        
+        registry.register(resolver2);
+        registry.register(resolver1);
+        
+        assertEquals("unexpected resolver count",
+                     2,
+                     registry.getResolvers().size());
+        assertTrue("expected resolver to be registered",
+                   registry.getResolvers().contains(resolver1));
+        assertTrue("expected resolver to be registered",
+                   registry.getResolvers().contains(resolver2));
+        
+        registry.unregister(resolver2);
+        
+        assertEquals("unexpected resolver count",
+                     1,
+                     registry.getResolvers().size());
+        assertTrue("expected resolver to be registered",
+                   registry.getResolvers().contains(resolver1));
+        assertFalse("expected resolver to be registered",
+                    registry.getResolvers().contains(resolver2));
+    }
+    
+    @Test
+    public void testGetContactLocation() {
+        registry.init();
+        registry.register(resolver1);
+        registry.register(resolver2);
+        resolver1.getContractLocation(serviceName);
+        EasyMock.expectLastCall().andReturn(uri1);
+        control.replay();
+     
+        URI resolved = registry.getContractLocation(serviceName);
+        
+        control.verify();
+        assertSame("unexpected physical EPR", uri1, resolved);
+        
+        control.reset();
+        resolver1.getContractLocation(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.getContractLocation(serviceName);
+        EasyMock.expectLastCall().andReturn(uri2);
+        control.replay();
+        
+        resolved = registry.getContractLocation(serviceName);
+        
+        control.verify();
+        assertSame("unexpected physical EPR", uri2, resolved);
+        assertNotSame("unexpected physical EPR", uri1, resolved);
+
+        control.reset();
+        resolver1.getContractLocation(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        resolver2.getContractLocation(serviceName);
+        EasyMock.expectLastCall().andReturn(null);
+        control.replay();
+
+        resolved = registry.getContractLocation(serviceName);
+
+        control.verify();
+        assertNull("unexpected physical EPR", resolved);
+    }
+
+}

Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/core/src/test/java/org/apache/cxf/endpoint/ServiceContractResolverRegistryImplTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=595027&r1=595026&r2=595027&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Wed Nov 14 11:57:47 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.jaxws;
 
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.Arrays;
 import java.util.Collection;
@@ -32,6 +33,7 @@
 import java.util.concurrent.Executor;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.jws.WebService;
 import javax.xml.bind.JAXBContext;
 import javax.xml.namespace.QName;
@@ -56,6 +58,7 @@
 import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
+import org.apache.cxf.endpoint.ServiceContractResolverRegistry;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.binding.soap.JaxWsSoapBindingConfiguration;
@@ -99,11 +102,29 @@
 
     public ServiceImpl(Bus b, URL url, QName name, Class<?> cls) {
         bus = b;
-        wsdlURL = url == null ? null : url.toString();
         this.serviceName = name;
         clazz = cls;
         
         handlerResolver = new HandlerResolverImpl(bus, name, clazz);
+        
+        if (null == url && null != bus) {
+            ServiceContractResolverRegistry registry = 
+                bus.getExtension(ServiceContractResolverRegistry.class);
+            if (null != registry) {
+                URI uri = registry.getContractLocation(name);
+                if (null != uri) {
+                    try {
+                        url = uri.toURL();
+                    } catch (MalformedURLException e) {
+                        LOG.log(Level.FINE, "resolve qname failed", name);
+                        throw new WebServiceException(e);
+                    }
+                }
+            }
+        }
+
+        wsdlURL = url == null ? null : url.toString();
+        
         if (url != null) {
             try {
                 initializePorts();

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=595027&r1=595026&r2=595027&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Wed Nov 14 11:57:47 2007
@@ -27,6 +27,8 @@
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
+import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -54,6 +56,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
 import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.endpoint.ServiceContractResolverRegistry;
 import org.apache.cxf.feature.AbstractFeature;
 import org.apache.cxf.frontend.FaultInfoException;
 import org.apache.cxf.frontend.MethodDispatcher;
@@ -1642,13 +1645,30 @@
             for (AbstractServiceConfiguration c : serviceConfigurations) {
                 wsdlURL = c.getWsdlURL();
                 if (wsdlURL != null) {
-                    //create a unique string so if its an interned string (like
-                    //from an annotation), caches will clear
-                    wsdlURL = new String(wsdlURL);
                     break;
                 }
             }
+            if (null == wsdlURL && getBus() != null) {
+                ServiceContractResolverRegistry registry = 
+                    getBus().getExtension(ServiceContractResolverRegistry.class);
+                if (null != registry) {
+                    URI uri = registry.getContractLocation(this.getServiceQName());
+                    if (null != uri) {
+                        try {
+                            wsdlURL = uri.toURL().toString();
+                        } catch (MalformedURLException e) {
+                            LOG.log(Level.FINE, "resolve qname failed", this.getServiceQName());
+                        }
+                    }
+                }
+            }
+            if (wsdlURL != null) {
+                //create a unique string so if its an interned string (like
+                //from an annotation), caches will clear
+                wsdlURL = new String(wsdlURL);
+            }
         }
+        
         return wsdlURL;
     }
 

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,69 @@
+/**
+ * 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.cxf.systest.resolver;
+
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.endpoint.ServiceContractResolverRegistry;
+import org.apache.cxf.endpoint.ServiceContractResolverRegistryImpl;
+import org.apache.cxf.systest.jca.OutBoundConnectionTest.Server;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_soap_http.Greeter;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JarResolverTest extends AbstractBusClientServerTestBase {
+    private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
"SOAPService");
+
+    private final QName portName = new QName("http://apache.org/hello_world_soap_http", "SoapPort");
+    
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", launchServer(Server.class));
+        
+    }
+    @Test
+    public void testResolver() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        assertNotNull(wsdl);
+
+        createBus();
+        assertNotNull(bus);
+        ServiceContractResolverRegistryImpl registry = 
+            new ServiceContractResolverRegistryImpl();
+        registry.setBus(bus);
+        registry.init();
+        assertNotNull(bus.getExtension(ServiceContractResolverRegistry.class));
+
+        JarServiceContactResolver resolver = new JarServiceContactResolver();
+        registry.register(resolver);
+
+        Service service = Service.create(serviceName);
+        //service.addPort(portName, SOAPBinding.SOAP11HTTP_BINDING,
+        //                "http://localhost:9000/SoapContext/SoapPort"); 
+        Greeter greeter = service.getPort(portName,  Greeter.class);
+
+        String resp = greeter.sayHi();
+        assertNotNull(resp);
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarResolverTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,73 @@
+/**
+ * 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.cxf.systest.resolver;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.endpoint.ServiceContactResolver;
+
+public class JarServiceContactResolver implements ServiceContactResolver {
+
+    private URI uri;
+    
+    public URI getContractLocation(QName qname) {
+        URI ns = null;
+        try {
+            ns = new URI(qname.getNamespaceURI()).normalize();
+        } catch (URISyntaxException e2) {
+            return null;
+        }
+
+        String[] hostStrings = ns.getHost().split("\\.");
+        String[] pathStrings = ns.getPath().split("\\/");
+        String local = qname.getLocalPart();
+        StringBuffer path = new StringBuffer();
+        for (int i = hostStrings.length - 1; i >= 0; i--) {
+            path.append(hostStrings[i]).append("/");
+        }
+        for (int i = 1; i < pathStrings.length; i++) {
+            path.append(pathStrings[i]).append("/");
+        }
+        path.append(local).append(".wsdl");
+        try {
+            URL jarURL = this.getClass().getResource("/wsdl/hello_world_resolver.jar");
+            JarFile jar = new JarFile(new File(jarURL.toURI()));
+            JarEntry jarEntry = jar.getJarEntry(path.toString());
+            uri = new URI("jar:" + jarURL + "!/" + jarEntry.toString());
+            return uri;
+        } catch (IOException e1) {
+            e1.printStackTrace();
+            return null;
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/JarServiceContactResolver.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java?rev=595027&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
Wed Nov 14 11:57:47 2007
@@ -0,0 +1,46 @@
+/**
+ * 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.cxf.systest.resolver;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.hello_world_soap_http.GreeterImpl;
+
+public class Server extends AbstractBusTestServerBase {
+    protected void run() {
+        Object implementor = new GreeterImpl();
+        String address = "http://localhost:9000/SoapContext/SoapPort";
+        Endpoint.publish(address, implementor);
+        
+    }
+    
+    public static void main(String[] args) {
+        try {
+            Server s = new Server();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/resolver/Server.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/systests/src/test/resources/wsdl/hello_world_resolver.jar
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/wsdl/hello_world_resolver.jar?rev=595027&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/cxf/trunk/systests/src/test/resources/wsdl/hello_world_resolver.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message