You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ba...@apache.org on 2008/01/11 04:56:17 UTC
svn commit: r611042 [2/4] - in /webservices/axis2/trunk/java/modules:
jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/spi/
jaxws/test-resources/wsdl/ jaxws/test/org/apache/axis2/jaxws/description/
jaxws/test/org/apache/axis2/jaxws/sp...
Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java?rev=611042&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/spi/ClientMetadataTest.java Thu Jan 10 19:56:14 2008
@@ -0,0 +1,962 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.spi;
+
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.jaxws.ClientConfigurationFactory;
+import org.apache.axis2.jaxws.description.DescriptionTestUtils2;
+import org.apache.axis2.jaxws.description.ServiceDescription;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
+import org.apache.axis2.jaxws.description.builder.WebServiceClientAnnot;
+import org.apache.axis2.jaxws.description.impl.DescriptionFactoryImpl;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.axis2.metadata.registry.MetadataFactoryRegistry;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceClient;
+import javax.xml.ws.WebServiceException;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * Test creation of a generic Service and generated Service with and without additional
+ * metadata specified during the creation of the service. Additional metadata could be supplied
+ * by a runtime in order to support JSR-109 deployment descriptors or injection of WebServiceRef
+ * annotations.
+ */
+public class ClientMetadataTest extends TestCase {
+ static final String namespaceURI = "http://description.jaxws.axis2.apache.org";
+ static final String svcLocalPart = "svcLocalPart";
+
+ static final String originalWsdl = "ClientMetadata.wsdl";
+ static final String overridenWsdl = "ClientMetadataOverriden.wsdl";
+ static final String otherWsdl = "ClientMetadataOther.wsdl";
+
+ static final String originalWsdl_portLocalPart = "portLocalPart";
+ static final String overridenWsdl_portLocalPart = "portLocalPartOverriden";
+ static final String otherWsdl_portLocalPart = "portLocalPartOther";
+
+ /**
+ * Test Service.create(QName) with no composite specified
+ */
+ public void test1ArgServiceWithoutComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ Service service = Service.create(serviceQName);
+ assertNotNull(service);
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertNotNull(dbcInServiceDesc);
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+
+ // No WSDL should have been used, so no Ports should be found
+ assertTrue("Wrong WSDL used", validatePort(service, null));
+ }
+
+ /**
+ * Service.create(URL, QName) with no composite specified
+ */
+ public void test2ArgServiceWithoutComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = getWsdlURL(otherWsdl);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ assertNotNull(service);
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertNotNull(dbcInServiceDesc);
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+
+ // WSDL was specified on the create, so make sure the right one was used by checking the ports
+ assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
+ }
+
+ /**
+ * Service.create(QName) with a composite specified but no override in the composite
+ */
+ public void test1ArgServiceWithComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ assertNull(ServiceDelegate.getServiceMetadata());
+ // Use the proprietary SPI to create a service with additional metadata specified
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = Service.create(serviceQName);
+ assertNotNull(service);
+
+ // Verify that the composite has been reset so that it would not affect the next Service
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+
+ // No WSDL should have been used, so no Ports should be found
+ assertTrue("Wrong WSDL used", validatePort(service, null));
+
+ }
+
+ /**
+ * Service.create(URL, QName) with a composite specified but no override in the composite
+ */
+ public void test2ArgServiceWithComposite() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ URL wsdlUrl = getWsdlURL(otherWsdl);
+ // Use the proprietary SPI to create a service with additional metadata specified
+ ServiceDelegate.setServiceMetadata(composite);
+ Service service = Service.create(wsdlUrl, serviceQName);
+ assertNotNull(service);
+ // Verify that the composite has been reset so that it would not affect the next Service
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // Since this is a generic Service with no overrides, there will be no WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+
+ // WSDL was specified on the create, so make sure the right one was used by checking the ports
+ assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor() with no composite specified
+ */
+ public void testNoArgGeneratedService() {
+ Service service = new ClientMetadataGeneratedService();
+ assertNotNull(service);
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ // WSDL not specified, so generated Service should use the annotation value
+ assertTrue("Wrong WSDL Used", validatePort(service, originalWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor(URL, QName) with no composite specified
+ */
+ public void test2ArgGeneratedService() {
+
+ Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+ assertNotNull(service);
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ // WSDL was specified on the generated Service constructor,
+ // so make sure the right one was used by checking the ports
+ assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor() with composite specified but no override in composite
+ */
+ public void testNoArgGeneratedServiceWithComposite() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService();
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it wasn't overriden in the composite
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ // No WSDL override specified in the composite, so generated Service should use the annotation value
+ assertTrue("Wrong WSDL Used", validatePort(service, originalWsdl_portLocalPart));
+
+ }
+
+ /**
+ * Generated service constructor(URL, QName) with composite specified but no override in composite
+ */
+ public void test2ArgGeneratedServiceWithComposite() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it wasn't overriden in the composite
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ // WSDL was specified on the generated Service constructor, and none in the composite
+ // so should get the WSDL specified on the constructor
+ assertTrue("Wrong WSDL used", validatePort(service, otherWsdl_portLocalPart));
+ }
+
+ /**
+ * Service.create(QName) with a composite that specifies a wsdlLocation override
+ */
+ public void test1ArgServiceOverrideWsdlLocation() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno =
+ WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ // Use the proprietary SPI to create a service with additional metadata specified
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = Service.create(serviceQName);
+
+ assertNotNull(service);
+ // Verify that the composite has been reset so that it would not affect the next Service
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // This is a generic Service with overrides, there will be WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+ wsClient = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotNull(wsClient);
+ assertEquals(getWsdlLocation(overridenWsdl), wsClient.wsdlLocation());
+ assertNull(wsClient.targetNamespace());
+ assertNull(wsClient.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+ }
+
+ /**
+ * Service.create(QName) with a composite that overrides the TargetNamespace. Most of the
+ * other tests override the WSDL Location since that is what a JSR-109 DD can specify. This
+ * test makes sure other values can be overridden as well
+ */
+ public void test1ArgServiceOverrideTNS() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno =
+ WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, "overrideTNS", null);
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ // Use the proprietary SPI to create a service with additional metadata specified
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = Service.create(serviceQName);
+
+ assertNotNull(service);
+ // Verify that the composite has been reset so that it would not affect the next Service
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // The target namespace for the key should be overriden; it should not be overriden for
+ // no key.
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+
+ WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotNull(wsClientKeyed);
+ assertNull(wsClientKeyed.wsdlLocation());
+ assertEquals("overrideTNS", wsClientKeyed.targetNamespace());
+ assertNull(wsClientKeyed.name());
+
+ }
+
+ /**
+ * Service.create(URL, QName) with a composite that specifies a wsdlLocation override
+ */
+ public void test2ArgServiceOverrideWsdlLocation() {
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = getWsdlURL(otherWsdl);
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ // Use the proprietary SPI to create a service with additional metadata specified
+ ServiceDelegate.setServiceMetadata(composite);
+ Service service = Service.create(wsdlUrl, serviceQName);
+
+ assertNotNull(service);
+ // Verify that the composite has been reset so that it would not affect the next Service
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(Service.class, dbcInServiceDesc.getCorrespondingClass());
+ // Since this is a generic Service with overrides, there will be a WebServiceClient annotation
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNull(wsClient);
+ wsClient = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotNull(wsClient);
+ assertEquals(getWsdlLocation(overridenWsdl), wsClient.wsdlLocation());
+ assertNull(wsClient.targetNamespace());
+ assertNull(wsClient.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+
+ }
+
+ /**
+ * Generated service constructor() with a composite that specifies a wsdlLocation override
+ */
+ public void testNoArgGeneratedServiceOverrideWsdlLocation() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService();
+
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it was overriden in the composite
+ // for this key, however the keyless composite should not have any overrides.
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotSame(wsClient, wsClientKeyed);
+ assertEquals(getWsdlLocation(overridenWsdl), wsClientKeyed.wsdlLocation());
+ assertEquals("originalTNS", wsClientKeyed.targetNamespace());
+ assertEquals("", wsClientKeyed.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor(URL, QName) with a composite that specifies a wsdlLocation override
+ */
+ public void test2ArgGeneratedServiceOverrideWsdlLocation() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation(overridenWsdl));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it was overriden in the composite
+ // for this key, however the keyless composite should not have any overrides.
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotSame(wsClient, wsClientKeyed);
+
+ assertEquals(getWsdlLocation(overridenWsdl), wsClientKeyed.wsdlLocation());
+ assertEquals("originalTNS", wsClientKeyed.targetNamespace());
+ assertEquals("", wsClientKeyed.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor(URL, QName) with a composite that specifies a
+ * target Namespace override. Most of the other tests are based on wsdlLocation since
+ * that is what JSR-109 DDs override. This test verifies that other members can also
+ * be override.
+ */
+ public void test2ArgGeneratedServiceOverrideTNS() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, "overrideTNS", getWsdlLocation(overridenWsdl));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it was overriden in the composite
+ // for this key, however the keyless composite should not have any overrides.
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotSame(wsClient, wsClientKeyed);
+
+ assertEquals(getWsdlLocation(overridenWsdl), wsClientKeyed.wsdlLocation());
+ assertEquals("overrideTNS", wsClientKeyed.targetNamespace());
+ assertEquals("", wsClientKeyed.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+ }
+
+ /**
+ * Generated service constructor(URL, QName) with a composite that specifies a wsdlLocation override
+ * where the override is a fully specifed URL to a file.
+ */
+ public void test2ArgGeneratedServiceOverrideWsdlLocationWithProtocol() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ // If the wsdlLocation in the composite specifies a protocol (like file: or http:) then
+ // it should be used as-is. Otherwise (as shown by the other tests), it is treated as
+ // a path on the local filesystem.
+ String fullWsdlLocation = "file:/" + getWsdlLocation(overridenWsdl);
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, fullWsdlLocation);
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ Service service = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+
+ assertNotNull(service);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ ServiceDelegate serviceDelegate = DescriptionTestUtils2.getServiceDelegate(service);
+ assertNotNull(serviceDelegate);
+ ServiceDescription serviceDesc = serviceDelegate.getServiceDescription();
+ assertNotNull(serviceDesc);
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc);
+ assertSame(composite, dbcInServiceDesc.getSparseComposite(serviceDelegate));
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+ // There is WebServiceClient on the generated Service and it was overriden in the composite
+ // for the key. The annotation with no key should be unchanged.
+ WebServiceClient wsClient = dbcInServiceDesc.getWebServiceClientAnnot();
+ assertNotNull(wsClient);
+ assertEquals(originalWsdl, wsClient.wsdlLocation());
+ assertEquals("originalTNS", wsClient.targetNamespace());
+ assertEquals("", wsClient.name());
+
+ WebServiceClient wsClientKeyed = dbcInServiceDesc.getWebServiceClientAnnot(serviceDelegate);
+ assertNotSame(wsClient, wsClientKeyed);
+ assertEquals(fullWsdlLocation, wsClientKeyed.wsdlLocation());
+ assertEquals("originalTNS", wsClientKeyed.targetNamespace());
+ assertEquals("", wsClientKeyed.name());
+
+ // WSDL override specified in the composite
+ assertTrue("Wrong WSDL used", validatePort(service, overridenWsdl_portLocalPart));
+ }
+
+ /**
+ * Test override WSDL file that is full specified
+ */
+ public void testInvalidWsdlLocationOverrideWithProtocol() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ String fullWsdlLocation = "http:/" + getWsdlLocation("InvalidFileName.wsdl");
+
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, fullWsdlLocation);
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ try {
+ Service service = new ClientMetadataGeneratedService();
+ fail("Should have caught exception for invalid WSDL file name in override");
+ } catch (WebServiceException ex) {
+ // Expected path
+ }
+ }
+
+ /**
+ * The overide WSDL file doesn't exist; should catch an error
+ */
+ public void testInvalidWsdlLocationOverride() {
+ DescriptionBuilderComposite composite = new DescriptionBuilderComposite();
+ WebServiceClientAnnot wsClientAnno = WebServiceClientAnnot.createWebServiceClientAnnotImpl(null, null, getWsdlLocation("InvalidFileName.wsdl"));
+ composite.setWebServiceClientAnnot(wsClientAnno);
+ ServiceDelegate.setServiceMetadata(composite);
+
+ try {
+ Service service = new ClientMetadataGeneratedService();
+ fail("Should have caught exception for invalid WSDL file name in override");
+ } catch (WebServiceException ex) {
+ // Expected path
+ }
+ }
+
+ /**
+ * Create multiple instances of the same service. Validate that the service delegates are
+ * unique and the ServiceDescription is shared. Note we have to install a special factory
+ * so that the ServiceDescriptions are cached; the default factory will not cause them to be
+ * cached.
+ */
+ public void testMultipleServices() {
+ try {
+ installCachingFactory();
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQN = new QName(namespaceURI, otherWsdl_portLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
+
+ // Create the first service
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
+ validatePort(service1, otherWsdl_portLocalPart);
+
+ // Create the second service
+ Service service2 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
+ validatePort(service2, otherWsdl_portLocalPart);
+
+ assertNotSame(serviceDelegate1, serviceDelegate2);
+ // Since we installed a caching factory, the service descriptions WILL be cached.
+ // Without that factory, they would not have been cached. The reason is that the
+ // AxisConfiguration instance is part of the key. The default factory in this
+ // environment always returns a new instance. The test factory does not.
+ assertSame(serviceDesc1, serviceDesc2);
+ } finally {
+ restoreOriginalFactory();
+ }
+
+ // Sanity check that the factory WAS restored. Do the same thing as above, but this time
+ // the service descs should NOT be the same since they weren't cached.
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ QName portQN = new QName(namespaceURI, otherWsdl_portLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
+
+ // Create the first service
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
+ validatePort(service1, otherWsdl_portLocalPart);
+
+ // Create the second service
+ Service service2 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
+ validatePort(service2, otherWsdl_portLocalPart);
+
+ assertNotSame(serviceDelegate1, serviceDelegate2);
+ assertNotSame("Client Configuration factory NOT restored; subsequent tests may be affected!", serviceDesc1, serviceDesc2);
+ }
+
+ /**
+ * Create two services such that the ServiceDescriptions should be cached and shared.
+ * Create the first without a composite, the second with a composite, then validate the second
+ * service's composite. Note that we have to use a special factory so that the service
+ * descriptions are cached.
+ */
+ public void testMultipleServicesMixedComposite() {
+ try {
+ installCachingFactory();
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
+
+ // Create the first service
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
+ validatePort(service1, otherWsdl_portLocalPart);
+
+ // Create the second service specifiying a sparse composite
+ DescriptionBuilderComposite sparseComposite = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(sparseComposite);
+ Service service2 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
+ validatePort(service2, otherWsdl_portLocalPart);
+
+ assertNotSame(serviceDelegate1, serviceDelegate2);
+ // Since we installed a caching factory, the service descriptions WILL be cached.
+ // Without that factory, they would not have been cached. The reason is that the
+ // AxisConfiguration instance is part of the key. The default factory in this
+ // environment always returns a new instance. The test factory does not.
+ assertSame(serviceDesc1, serviceDesc2);
+
+ // There should not be a sparse composite for the first service delegate and there
+ // should be one for the second service delegate
+ assertNull(DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate1));
+ assertSame(sparseComposite, DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate2));
+ } finally {
+ restoreOriginalFactory();
+ }
+
+ }
+
+ /**
+ * Create two services such that the ServiceDescriptions should be cached and shared.
+ * Create the first with a composite, the second with a composite, then validate both
+ * composites. Note that we have to use a special factory so that the service
+ * descriptions are cached.
+ */
+ public void testMultipleServicesMultipleComposites() {
+ try {
+ installCachingFactory();
+ QName serviceQName = new QName(namespaceURI, svcLocalPart);
+ URL wsdlUrl = ClientMetadataTest.getWsdlURL(otherWsdl);
+
+ // Create the first service
+ DescriptionBuilderComposite sparseComposite1 = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(sparseComposite1);
+ Service service1 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
+ validatePort(service1, otherWsdl_portLocalPart);
+
+ // Create the second service specifiying a sparse composite
+ DescriptionBuilderComposite sparseComposite2 = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(sparseComposite2);
+ Service service2 = Service.create(wsdlUrl, serviceQName);
+ ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNull(ServiceDelegate.getServiceMetadata());
+ ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
+ validatePort(service2, otherWsdl_portLocalPart);
+
+ assertNotSame(serviceDelegate1, serviceDelegate2);
+ // Since we installed a caching factory, the service descriptions WILL be cached.
+ // Without that factory, they would not have been cached. The reason is that the
+ // AxisConfiguration instance is part of the key. The default factory in this
+ // environment always returns a new instance. The test factory does not.
+ assertSame(serviceDesc1, serviceDesc2);
+
+ // There should not be a sparse composite for the first service delegate and there
+ // should be one for the second service delegate
+ assertSame(sparseComposite1, DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate1));
+ assertSame(sparseComposite2, DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate2));
+ } finally {
+ restoreOriginalFactory();
+ }
+ }
+
+ /**
+ * Create two generated services such that the ServiceDescriptions should be cached and shared.
+ * Create the first with a composite, the second with a composite, then validate both
+ * composites. Note that we have to use a special factory so that the service
+ * descriptions are cached.
+ */
+ public void testMultipleGeneratedServiceWithMultipleComposite() {
+ try {
+ installCachingFactory();
+
+ // Create the first service with a sparse composite
+ DescriptionBuilderComposite sparseComposite1 = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(sparseComposite1);
+ Service service1 = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+ assertNotNull(service1);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ // Create the second service with a sparse composite
+ DescriptionBuilderComposite sparseComposite2 = new DescriptionBuilderComposite();
+ ServiceDelegate.setServiceMetadata(sparseComposite2);
+ Service service2 = new ClientMetadataGeneratedService(getWsdlURL(otherWsdl),
+ new QName(namespaceURI, svcLocalPart));
+ assertNotNull(service2);
+ assertNull(ServiceDelegate.getServiceMetadata());
+
+ // Verifiy the service delegates are different and the service descriptions are the same
+ // since we installed a caching factory above.
+ ServiceDelegate serviceDelegate1 = DescriptionTestUtils2.getServiceDelegate(service1);
+ assertNotNull(serviceDelegate1);
+ ServiceDescription serviceDesc1 = serviceDelegate1.getServiceDescription();
+ assertNotNull(serviceDesc1);
+
+ ServiceDelegate serviceDelegate2 = DescriptionTestUtils2.getServiceDelegate(service2);
+ assertNotNull(serviceDelegate2);
+ ServiceDescription serviceDesc2 = serviceDelegate2.getServiceDescription();
+ assertNotNull(serviceDesc2);
+
+ assertNotSame(serviceDelegate1, serviceDelegate2);
+ assertSame(serviceDesc1, serviceDesc2);
+
+ // There should be a sparse composite for the first service delegate and
+ // one for the second service delegate
+ assertSame(sparseComposite1,
+ DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate1));
+ assertSame(sparseComposite2, DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc2).getSparseComposite(serviceDelegate2));
+
+
+ DescriptionBuilderComposite dbcInServiceDesc = DescriptionTestUtils2.getServiceDescriptionComposite(serviceDesc1);
+ assertEquals(ClientMetadataGeneratedService.class, dbcInServiceDesc.getCorrespondingClass());
+
+ // WSDL was specified on the generated Service constructor, and none in the composite
+ // so should get the WSDL specified on the constructor
+ assertTrue("Wrong WSDL used", validatePort(service1, otherWsdl_portLocalPart));
+ assertTrue("Wrong WSDL used", validatePort(service2, otherWsdl_portLocalPart));
+
+
+
+
+ } finally {
+ restoreOriginalFactory();
+ }
+
+ }
+
+ // =============================================================================================
+ // Utility methods
+ // =============================================================================================
+
+ /**
+ * Prepends the base directory and the path where the test WSDL lives to a filename.
+ * @param wsdlFileName
+ * @return
+ */
+ static String getWsdlLocation(String wsdlFileName) {
+ String wsdlLocation = null;
+ String baseDir = System.getProperty("basedir",".");
+ wsdlLocation = baseDir + "/test-resources/wsdl/" + wsdlFileName;
+ return wsdlLocation;
+ }
+
+ /**
+ * Given a simple file name (with no base dictory or path), returns a URL to the WSDL file
+ * with the base directory and path prepended.
+ *
+ * @param wsdlFileName
+ * @return
+ */
+ static URL getWsdlURL(String wsdlFileName) {
+ URL url = null;
+ String wsdlLocation = getWsdlLocation(wsdlFileName);
+ try {
+ File file = new File(wsdlLocation);
+ url = file.toURL();
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ fail("Exception converting WSDL file to URL: " + e.toString());
+ }
+ return url;
+ }
+
+ /**
+ * Validate that the Service contains the expected port. If the portLocalPart is null then
+ * no ports are expected to exist under the service.
+ * @param service The service to check for the specified port
+ * @param portLocalPart If null means no ports are expected; otherwise the localname of the
+ * single port expected under the service
+ * @return
+ */
+ static boolean validatePort(Service service, String portLocalPart) {
+ boolean isValid = false;
+
+ if (service == null) {
+ return false;
+ }
+
+ // Each service in the WSDLs for this test have a single port
+ boolean portNameValid = false;
+ int expectedNumberOfPorts = 1;
+ int numberOfPorts = 0;
+
+ Iterator<QName> portIterator = service.getPorts();
+ while (portIterator.hasNext()) {
+ numberOfPorts++;
+ QName checkPort = portIterator.next();
+ // If we haven't found a match for the port yet, see if this one matches
+ if (!portNameValid) {
+ portNameValid = portLocalPart.equals(checkPort.getLocalPart());
+ }
+ }
+ if (portLocalPart == null && numberOfPorts == 0) {
+ // No ports expected (i.e. no WSDL should have been used)
+ isValid = true;
+ }
+ else if ((expectedNumberOfPorts == numberOfPorts) && portNameValid) {
+ isValid = true;
+ }
+ else {
+ isValid = false;
+ }
+ return isValid;
+ }
+
+ /**
+ * Methods to install a client configuration factory that will return the same AxisConfiguration
+ * each time. This is used so that the ServiceDescriptions will be cached in the DescriptionFactory.
+ *
+ * IMPORTANT!!!
+ * If you install a caching factory, you MUST restore the original factory before your test
+ * exits, otherwise it will remain installed when subsequent tests run and cause REALLY STRANGE
+ * failures. Use restoreOriginalFactory() INSIDE A finally() block to restore the factory.
+ */
+ static private ClientConfigurationFactory originalFactory = null;
+ static void installCachingFactory() {
+ // install caching factory
+ if (originalFactory != null) {
+ throw new UnsupportedOperationException("Attempt to install the caching factory when the original factory has already been overwritten");
+ }
+ originalFactory =
+ (ClientConfigurationFactory)MetadataFactoryRegistry.getFactory(ClientConfigurationFactory.class);
+ MetadataTestCachingClientContextFactory newFactory = new MetadataTestCachingClientContextFactory();
+ MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class, newFactory);
+ resetClientConfigFactory();
+ }
+ static void restoreOriginalFactory() {
+ if (originalFactory == null) {
+ throw new UnsupportedOperationException("Attempt to restore original factory to a null value");
+ }
+ MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class, originalFactory);
+ resetClientConfigFactory();
+ originalFactory = null;
+ }
+ static void resetClientConfigFactory() {
+ Field field;
+ try {
+ field = DescriptionFactoryImpl.class.getDeclaredField("clientConfigFactory");
+ field.setAccessible(true);
+ field.set(null, null);
+ } catch (Exception e) {
+ throw new UnsupportedOperationException("Unable to reset client config factory; caught " + e);
+ }
+ }
+
+}
+
+@WebServiceClient(targetNamespace="originalTNS", wsdlLocation=ClientMetadataTest.originalWsdl)
+class ClientMetadataGeneratedService extends javax.xml.ws.Service {
+ public ClientMetadataGeneratedService() {
+ super(ClientMetadataTest.getWsdlURL(ClientMetadataTest.originalWsdl),
+ new QName(ClientMetadataTest.namespaceURI, ClientMetadataTest.svcLocalPart));
+ }
+ public ClientMetadataGeneratedService(URL wsdlLocation, QName serviceName) {
+ super(wsdlLocation, serviceName);
+ }
+}
+
+
+class MetadataTestCachingClientContextFactory extends ClientConfigurationFactory {
+ ConfigurationContext context;
+
+ public ConfigurationContext getClientConfigurationContext() {
+ if (context == null) {
+ context = super.getClientConfigurationContext();
+ }
+ System.out.println("Test version of MetadataTestCachingClientContextFactory: " + context);
+ return context;
+ }
+
+ public void reset() {
+ context = null;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/DescriptionFactory.java Thu Jan 10 19:56:14 2008
@@ -68,6 +68,29 @@
Class serviceClass) {
return DescriptionFactoryImpl.createServiceDescription(wsdlURL, serviceQName, serviceClass);
}
+
+
+ /**
+ * Create the initial ServiceDescripton hierachy on the CLIENT side. This allows a sparse DBC
+ * to be specified in addition to the service class. The sparce DBC can be used to override
+ * the class annotation member values.
+ *
+ * @see #createServiceDescription(URL, QName, Class)
+ *
+ * @param wsdlURL
+ * @param serviceQName
+ * @param serviceClass
+ * @param sparseComposite
+ * @param sparseCompositeKey
+ * @return
+ */
+ public static ServiceDescription createServiceDescription(URL wsdlURL,
+ QName serviceQName, Class serviceClass, DescriptionBuilderComposite sparseComposite,
+ Object sparseCompositeKey) {
+ return DescriptionFactoryImpl.createServiceDescription(wsdlURL, serviceQName,
+ serviceClass, sparseComposite,
+ sparseCompositeKey);
+ }
/**
* Retrieve or create the EndpointDescription hierachy associated with an existing CLIENT side
@@ -94,8 +117,32 @@
Class sei, QName portQName,
DescriptionFactory.UpdateType updateType) {
return DescriptionFactoryImpl
- .updateEndpoint(serviceDescription, sei, portQName, updateType);
- }
+ .updateEndpoint(serviceDescription, sei, portQName, updateType);
+ }
+
+ /**
+ * Retrieve or create an EndpointDescription hierachy associated with an existing CLIENT side
+ * ServiceDescription for a particular port. Additonal metdata may be specified in a sparse
+ * composite. That metadata may come from a JSR-109 client deployment descriptor, for example,
+ * or from resource injection of an WebServiceRef or other Resource annotation.
+ *
+ * @see #updateEndpoint(ServiceDescription, Class, QName, org.apache.axis2.jaxws.description.DescriptionFactory.UpdateType)
+ *
+ * @param serviceDescription
+ * @param sei
+ * @param portQName
+ * @param updateType
+ * @param composite
+ * @return
+ */
+ public static EndpointDescription updateEndpoint(ServiceDescription serviceDescription,
+ Class sei, QName portQName,
+ DescriptionFactory.UpdateType updateType,
+ DescriptionBuilderComposite composite,
+ Object sparseCompositeKey) {
+ return DescriptionFactoryImpl
+ .updateEndpoint(serviceDescription, sei, portQName, updateType, composite, sparseCompositeKey);
+}
/**
* Create a full ServiceDescription hierachy on the SERVER side for EACH service implementation
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/EndpointDescription.java Thu Jan 10 19:56:14 2008
@@ -22,6 +22,7 @@
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.description.AxisService;
+import org.apache.axis2.jaxws.description.builder.DescriptionBuilderComposite;
import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
import javax.xml.namespace.QName;
@@ -135,4 +136,11 @@
public abstract QName getServiceQName();
public abstract Service.Mode getServiceMode();
+
+ /**
+ * Return the DescriptionBuilderComposite, if any, used to build this service description.
+ * @return
+ */
+ public DescriptionBuilderComposite getDescriptionBuilderComposite();
+
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/ServiceDescription.java Thu Jan 10 19:56:14 2008
@@ -99,5 +99,19 @@
public void setServiceRuntimeDesc(ServiceRuntimeDescription ord);
public boolean isServerSide();
-
+
+ /**
+ * Answer if MTOM is enabled for the service represented by this Service Description. This
+ * is currently only supported on the service-requester side; it is not supported on the
+ * service-provider side. If the key is non-null, it is used to look up an sparse metadata
+ * that may have been specified when the Service Description was created.
+ *
+ * @param key If non-null, used to look up any sparse metadata that may have been specified
+ * when the service was created.
+ * @return TRUE if mtom was enabled either in the sparse metadata or in the composite; FALSE
+ * othewise.
+ */
+ public boolean isMTOMEnabled(Object key);
+
+ public QName getPreferredPort(Object key);
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/BindingTypeAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/BindingTypeAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/BindingTypeAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/BindingTypeAnnot.java Thu Jan 10 19:56:14 2008
@@ -41,6 +41,15 @@
public static BindingTypeAnnot createBindingTypeAnnotImpl(String value) {
return new BindingTypeAnnot(value);
}
+
+ public static BindingTypeAnnot createFromAnnotation(Annotation annotation) {
+ BindingTypeAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.xml.ws.BindingType) {
+ javax.xml.ws.BindingType bt = (javax.xml.ws.BindingType) annotation;
+ returnAnnot = new BindingTypeAnnot(bt.value());
+ }
+ return returnAnnot;
+ }
/** @return Returns the value. */
public String value() {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderComposite.java Thu Jan 10 19:56:14 2008
@@ -22,21 +22,34 @@
*/
package org.apache.axis2.jaxws.description.builder;
+import org.apache.axis2.java.security.AccessController;
+import org.apache.axis2.jaxws.ExceptionFactory;
import org.apache.axis2.jaxws.description.xml.handler.HandlerChainsType;
import org.apache.axis2.jaxws.util.WSDL4JWrapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.jws.HandlerChain;
import javax.wsdl.Definition;
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingType;
+import javax.xml.ws.ServiceMode;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.WebServiceProvider;
import java.io.InputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
import java.net.URL;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.WeakHashMap;
public class DescriptionBuilderComposite implements TMAnnotationComposite, TMFAnnotationComposite {
@@ -59,12 +72,6 @@
genericAnnotationProcessors = new HashMap<String, CustomAnnotationProcessor>();
}
- //Class type within the module
- public static enum ModuleClassType {
- SERVICEIMPL, SEI, SERVICE, SUPER, PROVIDER, FAULT}
-
- private ModuleClassType moduleClassType = null;
-
//Note: a WSDL is not necessary
private Definition wsdlDefinition = null;
private URL wsdlURL = null;
@@ -88,6 +95,8 @@
private String extendsClass; //Set to the name of the super class
private List<String> interfacesList; //Set this for all implemented interfaces
private boolean isInterface = false;
+ private QName preferredPort; // Port to use if no port QName given. May be null
+ private boolean isMTOMEnabled = false;
private List<MethodDescriptionComposite> methodDescriptions;
private List<FieldDescriptionComposite> fieldDescriptions;
@@ -109,12 +118,104 @@
// JAXB object used to represent handler chain configuration info
private HandlerChainsType handlerChainsType = null;
+
+ // Does this composite represent a service requester or service provider.
+ // We default to service provider since composites were orginally not used by requesters.
+ private boolean isServiceProvider = true;
+
+ // For a service requester, this will be the client-side class associated with this composite;
+ // It could be the Service class or the SEI class. On the service provider this will be null
+ // unless the deprecated service construction logic in DescriptionFactory was used.
+ // TODO: (JLB) Remove the comment about the deprecated service construction logi
+ private Class theCorrespondingClass;
+
+ // Service-requesters (aka clients) can specify a sprase composite that may contain annotation
+ // information corresponding to information in a deployment descriptor or an injected
+ // resource.
+ private WeakHashMap<Object, DescriptionBuilderComposite> sparseCompositeMap = new WeakHashMap<Object, DescriptionBuilderComposite>();
+
+ public void setSparseComposite(Object key, DescriptionBuilderComposite sparseComposite) {
+ if (key != null && sparseComposite != null) {
+ this.sparseCompositeMap.put(key, sparseComposite);
+ }
+ }
+ public DescriptionBuilderComposite getSparseComposite(Object key) {
+ return sparseCompositeMap.get(key);
+ }
+ /**
+ * For a service requester, set the QName of the preferred port for this service. This
+ * indicates which port (i.e. which EndpointDescription) should be returned if a port QName
+ * isn't specified. This may be null, indicating the first valid port in the WSDL should be
+ * returned.
+ *
+ * @param preferredPort
+ */
+ public void setPreferredPort(QName preferredPort) {
+ this.preferredPort = preferredPort;
+ }
+
+ /**
+ * For a service requester, the QName of the prefered port for this service. This indicates
+ * which port should be returned if a port QName wasn't specified. This may be null,
+ * indicating the first valid port in the WSDL should be returned.
+ * @return
+ */
+ public QName getPreferredPort() {
+ return preferredPort;
+ }
+ public QName getPreferredPort(Object key) {
+ QName returnPreferredPort = null;
+ // See if there's a sparse composite override for this composite
+ if (key != null) {
+ DescriptionBuilderComposite sparse = getSparseComposite(key);
+ if (sparse != null
+ && !DescriptionBuilderUtils.isEmpty(sparse.getPreferredPort())) {
+ returnPreferredPort = sparse.getPreferredPort();
+ } else {
+ returnPreferredPort = getPreferredPort();
+ }
+ } else {
+ returnPreferredPort = getPreferredPort();
+ }
+
+ return returnPreferredPort;
+
+ }
+
+ public void setIsMTOMEnabled(boolean isMTOMEnabled) {
+ this.isMTOMEnabled = isMTOMEnabled;
+ }
+
+ public boolean isMTOMEnabled() {
+ return isMTOMEnabled;
+ }
+
+ public boolean isMTOMEnabled(Object key) {
+ boolean returnIsMTOMEnabled = false;
+ if (key != null) {
+ DescriptionBuilderComposite sparseDBC = getSparseComposite(key);
+ if (sparseDBC != null && sparseDBC.isMTOMEnabled()) {
+ returnIsMTOMEnabled = sparseDBC.isMTOMEnabled();
+ } else {
+ returnIsMTOMEnabled = isMTOMEnabled();
+ }
+
+ } else {
+ returnIsMTOMEnabled = isMTOMEnabled();
+ }
+
+ return returnIsMTOMEnabled;
+ }
+
// Methods
public WebServiceAnnot getWebServiceAnnot() {
- return this.webServiceAnnot;
+ return webServiceAnnot =
+ (WebServiceAnnot) getCompositeAnnotation(webServiceAnnot,
+ WebServiceAnnot.class,
+ javax.jws.WebService.class);
}
-
+
/** @return Returns the classModifiers. */
public String[] getClassModifiers() {
return classModifiers;
@@ -122,8 +223,17 @@
/** @return Returns the className. */
public String getClassName() {
- return className;
+ if (className != null) {
+ return className;
+ }
+ else if (theCorrespondingClass != null) {
+ return theCorrespondingClass.getName();
+ }
+ else {
+ return null;
+ }
}
+
/** @return Returns the super class name. */
public String getSuperClassName() {
@@ -137,32 +247,100 @@
/** @return Returns the handlerChainAnnotImpl. */
public HandlerChainAnnot getHandlerChainAnnot() {
- return handlerChainAnnot;
+ return handlerChainAnnot =
+ (HandlerChainAnnot) getCompositeAnnotation(handlerChainAnnot,
+ HandlerChainAnnot.class,
+ javax.jws.HandlerChain.class);
}
/** @return Returns the serviceModeAnnot. */
public ServiceModeAnnot getServiceModeAnnot() {
- return serviceModeAnnot;
+ return serviceModeAnnot =
+ (ServiceModeAnnot) getCompositeAnnotation(serviceModeAnnot,
+ ServiceModeAnnot.class,
+ javax.xml.ws.ServiceMode.class);
}
/** @return Returns the soapBindingAnnot. */
public SoapBindingAnnot getSoapBindingAnnot() {
- return soapBindingAnnot;
+ return soapBindingAnnot =
+ (SoapBindingAnnot) getCompositeAnnotation(soapBindingAnnot,
+ SoapBindingAnnot.class,
+ javax.jws.soap.SOAPBinding.class);
}
/** @return Returns the webFaultAnnot. */
public WebFaultAnnot getWebFaultAnnot() {
- return webFaultAnnot;
+ return webFaultAnnot =
+ (WebFaultAnnot) getCompositeAnnotation(webFaultAnnot,
+ WebFaultAnnot.class,
+ javax.xml.ws.WebFault.class);
}
/** @return Returns the webServiceClientAnnot. */
public WebServiceClientAnnot getWebServiceClientAnnot() {
- return webServiceClientAnnot;
+ return webServiceClientAnnot =
+ (WebServiceClientAnnot) getCompositeAnnotation(webServiceClientAnnot,
+ WebServiceClientAnnot.class,
+ javax.xml.ws.WebServiceClient.class);
+ }
+
+ public WebServiceClientAnnot getWebServiceClientAnnot(Object key) {
+ WebServiceClientAnnot annot = getWebServiceClientAnnot();
+ DescriptionBuilderComposite sparseComposite = getSparseComposite(key);
+ WebServiceClientAnnot sparseAnnot = null;
+ if (sparseComposite != null) {
+ sparseAnnot = sparseComposite.getWebServiceClientAnnot();
+ }
+ return WebServiceClientAnnot.createFromAnnotation(annot, sparseAnnot);
+ }
+
+ /**
+ * Return a composite annotation of the specified type. If the composite annotation is
+ * null, then the associated class (if not null) will be examined for the appropriate java
+ * annotation. If one is found, it will be used to create a new composite annotation.
+ *
+ * @param compositeAnnotation May be null. The current composite annotation. If this is
+ * non-null, it will simply be returned.
+ * @param compositeAnnotClass The class of the composite annotation. This is a subclass of
+ * the java annotation class.
+ * @param javaAnnotationClass The java annotation class. The associated class will be
+ * reflected on to see if this annotation exists. If so, it is used to create an instance of
+ * the composite annotation class.
+ * @return
+ */
+ private Annotation getCompositeAnnotation(Annotation compositeAnnotation,
+ Class compositeAnnotClass,
+ Class javaAnnotationClass) {
+ Annotation returnAnnotation = compositeAnnotation;
+ if (returnAnnotation == null && theCorrespondingClass != null) {
+ // Get the annotation from the class and if one exists, construct a composite annot for it
+ Annotation annotationFromClass = getAnnotationFromClass(theCorrespondingClass, javaAnnotationClass);
+ if (annotationFromClass != null) {
+ try {
+ Method createAnnot = compositeAnnotClass.getMethod("createFromAnnotation", Annotation.class);
+ returnAnnotation = (Annotation) createAnnot.invoke(null, annotationFromClass);
+ } catch (Exception e) {
+ if (log.isDebugEnabled()) {
+ log.debug("Unable to create composite annotation due to exception."
+ + " Composite Annotation: " + compositeAnnotation
+ + "; Composite Annot class: " + compositeAnnotClass
+ + "; Java Annot class: " + javaAnnotationClass, e);
+ }
+ // TODO: (JLB) NLS
+ throw ExceptionFactory.makeWebServiceException("Unable to create composite annotation", e);
+ }
+ }
+ }
+ return returnAnnotation;
}
/** @return Returns the webServiceProviderAnnot. */
public WebServiceProviderAnnot getWebServiceProviderAnnot() {
- return webServiceProviderAnnot;
+ return webServiceProviderAnnot =
+ (WebServiceProviderAnnot) getCompositeAnnotation(webServiceProviderAnnot,
+ WebServiceProviderAnnot.class,
+ javax.xml.ws.WebServiceProvider.class);
}
/** @return Returns the webServiceRefAnnot list. */
@@ -187,12 +365,14 @@
/** @return Returns the webServiceRefAnnot. */
public BindingTypeAnnot getBindingTypeAnnot() {
- return bindingTypeAnnot;
+ return (BindingTypeAnnot) getCompositeAnnotation(bindingTypeAnnot,
+ BindingTypeAnnot.class,
+ javax.xml.ws.BindingType.class);
}
/** @return Returns the webServiceContextAnnot. */
public WebServiceContextAnnot getWebServiceContextAnnot() {
- return webServiceContextAnnot;
+ return (WebServiceContextAnnot) webServiceContextAnnot;
}
/** @return Returns the wsdlDefinition */
@@ -446,22 +626,11 @@
fieldDescriptions.add(fieldDescription);
}
- /** @return Returns the ModuleClassType. */
- public ModuleClassType getClassType() {
-
- if (moduleClassType == null) {
- //TODO: Determine the class type
- }
- return moduleClassType;
- }
-
- /** @return Returns the ModuleClassType. */
public void setCustomWsdlGenerator(WsdlGenerator wsdlGenerator) {
this.wsdlGenerator = wsdlGenerator;
}
- /** @return Returns the ModuleClassType. */
public void setClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
@@ -482,6 +651,70 @@
public void setHandlerChainsType(HandlerChainsType handlerChainsType) {
this.handlerChainsType = handlerChainsType;
}
+
+ /**
+ * Answer does this composite represent a service requester (aka client) or a service
+ * provider (aka server).
+ *
+ * @return true if this is a service provider (aka an endpoint or a service implementation
+ * or a server)
+ *
+ */
+ public boolean isServiceProvider() {
+ return isServiceProvider;
+ }
+
+ /**
+ * Set the indication of whether this composite represents a service requester (aka client) or
+ * a service provider (aka server).
+ */
+ public void setIsServiceProvider(boolean value) {
+ isServiceProvider = value;
+ }
+
+ /**
+ * Set the class associated with this composite. For a service requester, this could be the
+ * Service class or the SEI class. For a service provider this will be null (unless the
+ * deprecated service construction logic in DescriptionFactory is used)
+ * @param theClass
+ */
+ public void setCorrespondingClass(Class theClass) {
+ this.theCorrespondingClass = theClass;
+ }
+
+ /**
+ * Returns the corresponding class associated with this composite, if any.
+ * @return
+ */
+ public Class getCorrespondingClass() {
+ return theCorrespondingClass;
+ }
+
+ /**
+ * @deprecated
+ */
+ private boolean isDeprecatedServiceProviderConstruction = false;
+ /**
+ * Answer if this composite represents a service provider that was constructed using the
+ * deprecated path (used for testing only and being removed). Once that deprecated path
+ * is removed, this method and all code blocks referencing it can be removed.
+ *
+ * @see org.apache.axis2.jaxws.description.DescriptionFactory.createServiceDescriptionFromServiceImpl
+ *
+ * @deprecated
+ * @return true if the this was constructed with the deprecated logic
+ */
+ public boolean isDeprecatedServiceProviderConstruction() {
+ return isDeprecatedServiceProviderConstruction;
+ }
+ /**
+ * @deprecated
+ * @param value
+ */
+ public void setIsDeprecatedServiceProviderConstruction(boolean value) {
+ isDeprecatedServiceProviderConstruction = value;
+ }
+
/**
* Convenience method for unit testing. We will print all of the
@@ -624,5 +857,21 @@
}
return wsdlDef;
+ }
+
+ /**
+ * Get an annotation by introspecting on a class. This is wrappered to avoid a Java2Security violation.
+ * @param cls Class that contains annotation
+ * @param annotation Class of requrested Annotation
+ * @return annotation or null
+ */
+ private static Annotation getAnnotationFromClass(final Class cls, final Class annotation) {
+ return (Annotation) AccessController.doPrivileged(new PrivilegedAction() {
+ public Object run() {
+
+ Annotation a = cls.getAnnotation(annotation);
+ return a;
+ }
+ });
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/DescriptionBuilderUtils.java Thu Jan 10 19:56:14 2008
@@ -23,6 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import javax.xml.namespace.QName;
+
/**
*
*/
@@ -347,6 +349,14 @@
}
}
return returnClass;
+ }
+
+ static boolean isEmpty(String string) {
+ return (string == null || "".equals(string));
+ }
+
+ static boolean isEmpty(QName qname) {
+ return qname == null || isEmpty(qname.getLocalPart());
}
}
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/HandlerChainAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/HandlerChainAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/HandlerChainAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/HandlerChainAnnot.java Thu Jan 10 19:56:14 2008
@@ -30,9 +30,23 @@
private HandlerChainAnnot() {
}
+
+ private HandlerChainAnnot(String file, String name) {
+ this.file = file;
+ this.name = name;
+ }
public static HandlerChainAnnot createHandlerChainAnnotImpl() {
return new HandlerChainAnnot();
+ }
+
+ public static HandlerChainAnnot createFromAnnotation(Annotation annotation) {
+ HandlerChainAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.jws.HandlerChain) {
+ javax.jws.HandlerChain hc = (javax.jws.HandlerChain) annotation;
+ returnAnnot = new HandlerChainAnnot(hc.file(), hc.name());
+ }
+ return returnAnnot;
}
public String file() {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/ServiceModeAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/ServiceModeAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/ServiceModeAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/ServiceModeAnnot.java Thu Jan 10 19:56:14 2008
@@ -42,6 +42,15 @@
public static ServiceModeAnnot createWebServiceAnnotImpl(Service.Mode value) {
return new ServiceModeAnnot(value);
}
+
+ public static ServiceModeAnnot createFromAnnotation(Annotation annotation) {
+ ServiceModeAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.xml.ws.ServiceMode) {
+ javax.xml.ws.ServiceMode sm = (javax.xml.ws.ServiceMode) annotation;
+ returnAnnot = new ServiceModeAnnot(sm.value());
+ }
+ return returnAnnot;
+ }
public Service.Mode value() {
return this.value;
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/SoapBindingAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/SoapBindingAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/SoapBindingAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/SoapBindingAnnot.java Thu Jan 10 19:56:14 2008
@@ -31,9 +31,26 @@
private SoapBindingAnnot() {
}
+
+ private SoapBindingAnnot(Style style, Use use, ParameterStyle paramStyle) {
+ this.style = style;
+ this.use = use;
+ this.parameterStyle = paramStyle;
+ }
public static SoapBindingAnnot createSoapBindingAnnotImpl() {
return new SoapBindingAnnot();
+ }
+ public static SoapBindingAnnot createFromAnnotation(Annotation annotation) {
+ SoapBindingAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.jws.soap.SOAPBinding) {
+ javax.jws.soap.SOAPBinding sb = (javax.jws.soap.SOAPBinding) annotation;
+ returnAnnot = new SoapBindingAnnot(sb.style(),
+ sb.use(),
+ sb.parameterStyle());
+ }
+
+ return returnAnnot;
}
public Style style() {
Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceAnnot.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceAnnot.java?rev=611042&r1=611041&r2=611042&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceAnnot.java (original)
+++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/builder/WebServiceAnnot.java Thu Jan 10 19:56:14 2008
@@ -69,6 +69,21 @@
endpointInterface,
portName);
}
+
+ public static WebServiceAnnot createFromAnnotation(Annotation annotation) {
+ WebServiceAnnot returnAnnot = null;
+ if (annotation != null && annotation instanceof javax.jws.WebService) {
+ javax.jws.WebService ws = (javax.jws.WebService) annotation;
+ return new WebServiceAnnot(ws.name(),
+ ws.targetNamespace(),
+ ws.serviceName(),
+ ws.wsdlLocation(),
+ ws.endpointInterface(),
+ ws.portName());
+
+ }
+ return returnAnnot;
+ }
public String name() {
return this.name;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org