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 pr...@apache.org on 2008/02/11 15:26:51 UTC

svn commit: r620488 - in /webservices/axis2/trunk/java/modules: jaxws-api/src/javax/xml/ws/wsaddressing/ jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/addressing/ jaxws/src/org/apache/axis2/jaxws/addressing/factory/ jaxws/src/org/a...

Author: pradine
Date: Mon Feb 11 06:26:46 2008
New Revision: 620488

URL: http://svn.apache.org/viewvc?rev=620488&view=rev
Log:
Various JAX-WS 2.1 improvements related to WS-Addressing support.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java   (with props)
Modified:
    webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java
    webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/package-info.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/Axis2EndpointReferenceFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactory.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactoryImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/package-info.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtils.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java

Modified: webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/W3CEndpointReference.java Mon Feb 11 06:26:46 2008
@@ -23,7 +23,6 @@
 import java.util.Map;
 
 import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
@@ -32,8 +31,8 @@
 import javax.xml.bind.annotation.XmlAnyAttribute;
 import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.namespace.QName;
@@ -64,6 +63,7 @@
  * 
  * 
  */
+@XmlRootElement(name = "EndpointReference")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "EndpointReferenceType", propOrder = {
     "address",
@@ -72,12 +72,8 @@
     "any"
 })
 public final class W3CEndpointReference extends EndpointReference {
-    @XmlTransient
     protected static volatile JAXBContext jaxbContext;
-    @XmlTransient
     protected static final String NS = "http://www.w3.org/2005/08/addressing";
-    @XmlTransient
-    protected static final QName NAME = new QName(NS, "EndpointReference", "wsa");
     
     @XmlElement(name = "Address", required = true)
     protected AttributedURIType address;
@@ -99,9 +95,7 @@
         try {
             JAXBContext jaxbContext = getJAXBContext();
             Unmarshaller um = jaxbContext.createUnmarshaller();
-            JAXBElement<W3CEndpointReference> element =
-                um.unmarshal(eprInfoset, W3CEndpointReference.class);
-            W3CEndpointReference w3cEPR = element.getValue();
+            W3CEndpointReference w3cEPR = (W3CEndpointReference) um.unmarshal(eprInfoset);
             
             address = w3cEPR.address;
             referenceParameters = w3cEPR.referenceParameters;
@@ -126,9 +120,7 @@
             JAXBContext jaxbContext = getJAXBContext();
             Marshaller m = jaxbContext.createMarshaller();
             m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
-            JAXBElement<W3CEndpointReference> element =
-                new JAXBElement<W3CEndpointReference>(NAME, W3CEndpointReference.class, this);
-            m.marshal(element, result);
+            m.marshal(this, result);
         }
         catch (Exception e) {
             //TODO NLS enable

Modified: webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/package-info.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/package-info.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/package-info.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-api/src/javax/xml/ws/wsaddressing/package-info.java Mon Feb 11 06:26:46 2008
@@ -16,5 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/08/addressing", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/08/addressing",
+                                     elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+                                     location = "http://www.w3.org/2006/03/addressing/ws-addr.xsd")
 package javax.xml.ws.wsaddressing;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/BindingProvider.java Mon Feb 11 06:26:46 2008
@@ -253,14 +253,27 @@
     public org.apache.axis2.addressing.EndpointReference getAxis2EndpointReference(String addressingNamespace) {
         org.apache.axis2.addressing.EndpointReference epr = this.epr;
         
-        if (epr == null || !addressingNamespace.equals(this.addressingNamespace)) {
-            String address = endpointDesc.getEndpointAddress();
+        //TODO NLS enable.
+        if (addressingNamespace == null)
+            throw ExceptionFactory.makeWebServiceException("The addressing namespace cannot be null.");
+        
+        if (epr == null) {
+            String address =
+                (String) requestContext.get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
+            if (address == null)
+                address = endpointDesc.getEndpointAddress();
             QName service = endpointDesc.getServiceQName();
             QName port = endpointDesc.getPortQName();
-            URL wsdlURL = ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
+            URL wsdlURL =
+                ((ServiceDescriptionWSDL) endpointDesc.getServiceDescription()).getWSDLLocation();
             String wsdlLocation = (wsdlURL != null) ? wsdlURL.toString() : null;
 
             epr = EndpointReferenceUtils.createAxis2EndpointReference(address, service, port, wsdlLocation, addressingNamespace);
+        }
+        else if (!addressingNamespace.equals(this.addressingNamespace)) {
+            //TODO NLS enable
+            throw ExceptionFactory.makeWebServiceException("BindingProvider has been cofigured for namespace " +
+                    this.addressingNamespace + ", but a request has been made for namespace " + addressingNamespace);
         }
         
         return epr;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/SubmissionEndpointReference.java Mon Feb 11 06:26:46 2008
@@ -23,7 +23,6 @@
 import java.util.Map;
 
 import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Marshaller;
 import javax.xml.bind.Unmarshaller;
@@ -33,8 +32,8 @@
 import javax.xml.bind.annotation.XmlAnyElement;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlSchemaType;
-import javax.xml.bind.annotation.XmlTransient;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlValue;
 import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
@@ -69,6 +68,7 @@
  * 
  * 
  */
+@XmlRootElement(name = "EndpointReference")
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlType(name = "EndpointReferenceType", propOrder = {
     "address",
@@ -79,13 +79,8 @@
     "any"
 })
 public class SubmissionEndpointReference extends EndpointReference {
-    @XmlTransient
     protected static volatile JAXBContext jaxbContext;
-    @XmlTransient
     protected static final String NS = "http://schemas.xmlsoap.org/ws/2004/08/addressing";
-    @XmlTransient
-    protected static final QName NAME = new QName(NS, "EndpointReference", "wsa");
-    
 
     @XmlElement(name = "Address", required = true)
     protected AttributedURI address;
@@ -111,9 +106,8 @@
         try {
             JAXBContext jaxbContext = getJAXBContext();
             Unmarshaller um = jaxbContext.createUnmarshaller();
-            JAXBElement<SubmissionEndpointReference> element =
-                um.unmarshal(eprInfoset, SubmissionEndpointReference.class);
-            SubmissionEndpointReference subEPR = element.getValue();
+            SubmissionEndpointReference subEPR =
+                (SubmissionEndpointReference) um.unmarshal(eprInfoset);
             
             address = subEPR.address;
             referenceParameters = subEPR.referenceParameters;
@@ -140,9 +134,7 @@
             JAXBContext jaxbContext = getJAXBContext();
             Marshaller m = jaxbContext.createMarshaller();
             m.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
-            JAXBElement<SubmissionEndpointReference> element =
-                new JAXBElement<SubmissionEndpointReference>(NAME, SubmissionEndpointReference.class, this);
-            m.marshal(element, result);
+            m.marshal(this, result);
         }
         catch (Exception e) {
             //TODO NLS enable

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/Axis2EndpointReferenceFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/Axis2EndpointReferenceFactoryImpl.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/Axis2EndpointReferenceFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/Axis2EndpointReferenceFactoryImpl.java Mon Feb 11 06:26:46 2008
@@ -29,34 +29,25 @@
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.addressing.util.EndpointKey;
 import org.apache.axis2.jaxws.addressing.util.EndpointMap;
+import org.apache.axis2.jaxws.addressing.util.EndpointMapManager;
 import org.apache.axis2.jaxws.util.WSDL4JWrapper;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 
 public class Axis2EndpointReferenceFactoryImpl implements Axis2EndpointReferenceFactory {
-    private final EndpointMap map = new EndpointMap();
-    
     public Axis2EndpointReferenceFactoryImpl() {
     	super();
     }
     
-    public void addAddress(QName serviceName, QName endpoint, String address) {
-        EndpointKey key = new EndpointKey(serviceName, endpoint);
-        
-        if (address == null)
-            throw new IllegalStateException("The specified address is not a valid value: " + address);
-        
-        map.put(key, address);
-    }
-    
     public EndpointReference createEndpointReference(String address) {
         if (address == null)
-            throw new IllegalStateException("The specified address is not a valid value: " + address);
+            throw new IllegalStateException("The endpoint address URI is null.");
 
         return new EndpointReference(address);
     }
     
     public EndpointReference createEndpointReference(QName serviceName, QName endpoint) {
         EndpointKey key = new EndpointKey(serviceName, endpoint);
+        EndpointMap map = EndpointMapManager.getEndpointMap();
         String address = map.get(key);
         
         return createEndpointReference(address);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactory.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactory.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactory.java Mon Feb 11 06:26:46 2008
@@ -18,11 +18,12 @@
  */
 package org.apache.axis2.jaxws.addressing.factory;
 
+import javax.xml.bind.JAXBException;
 import javax.xml.transform.Source;
 import javax.xml.ws.EndpointReference;
 
 public interface JAXWSEndpointReferenceFactory {
-    public EndpointReference createEndpointReference(Source eprInfoset, String addressingNamespace);
+    public EndpointReference createEndpointReference(Source eprInfoset) throws JAXBException;
     
     public String getAddressingNamespace(Class clazz);
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactoryImpl.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactoryImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/factory/JAXWSEndpointReferenceFactoryImpl.java Mon Feb 11 06:26:46 2008
@@ -18,6 +18,9 @@
  */
 package org.apache.axis2.jaxws.addressing.factory;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.transform.Source;
 import javax.xml.ws.EndpointReference;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
@@ -28,29 +31,16 @@
 import org.apache.axis2.jaxws.addressing.SubmissionEndpointReference;
 
 public class JAXWSEndpointReferenceFactoryImpl implements JAXWSEndpointReferenceFactory {
+    private static volatile JAXBContext jaxbContext;
+
     public JAXWSEndpointReferenceFactoryImpl() {
         super();
     }
     
-    private W3CEndpointReference createW3CEndpointReference(Source eprInfoset) {
-        return new W3CEndpointReference(eprInfoset);
-    }
-    
-    private SubmissionEndpointReference createSubmissionEndpointReference(Source eprInfost) {
-        return new SubmissionEndpointReference(eprInfost);
-    }
-    
-    public EndpointReference createEndpointReference(Source eprInfoset, String addressingNamespace) {
-        EndpointReference endpointReference = null;
+    public EndpointReference createEndpointReference(Source eprInfoset) throws JAXBException {
+        Unmarshaller um = getJAXBContext().createUnmarshaller();
         
-        if (Final.WSA_NAMESPACE.equals(addressingNamespace))
-            endpointReference = createW3CEndpointReference(eprInfoset);
-        else if (Submission.WSA_NAMESPACE.equals(addressingNamespace))
-            endpointReference = createSubmissionEndpointReference(eprInfoset);
-        else //TODO NLS enable.
-            throw ExceptionFactory.makeWebServiceException("Unknown addressing namespace: " + addressingNamespace);
-        
-        return endpointReference;
+        return (EndpointReference) um.unmarshal(eprInfoset);
     }
     
     public String getAddressingNamespace(Class clazz) {
@@ -61,8 +51,22 @@
         else if (SubmissionEndpointReference.class.isAssignableFrom(clazz))
             addressingNamespace = Submission.WSA_NAMESPACE;
         else //TODO NLS enable.
-            throw ExceptionFactory.makeWebServiceException("Unknown class type: " + clazz.getCanonicalName());
+            throw ExceptionFactory.makeWebServiceException("Unknown class type: " + clazz);
         
         return addressingNamespace;
+    }
+    
+    private JAXBContext getJAXBContext() throws JAXBException {
+        //This is an implementation of double-checked locking.
+        //It works because jaxbContext is volatile.
+        if (jaxbContext == null) {
+            synchronized (JAXWSEndpointReferenceFactoryImpl.class) {
+                if (jaxbContext == null)
+                    jaxbContext = JAXBContext.newInstance(W3CEndpointReference.class,
+                                                          SubmissionEndpointReference.class);
+            }
+        }
+        
+        return jaxbContext;
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/package-info.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/package-info.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/package-info.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/package-info.java Mon Feb 11 06:26:46 2008
@@ -16,5 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
+@javax.xml.bind.annotation.XmlSchema(namespace = "http://schemas.xmlsoap.org/ws/2004/08/addressing",
+                                     elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
+                                     location = "http://schemas.xmlsoap.org/ws/2004/08/addressing")
 package org.apache.axis2.jaxws.addressing;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointKey.java Mon Feb 11 06:26:46 2008
@@ -21,8 +21,8 @@
 import javax.xml.namespace.QName;
 
 public class EndpointKey {
-    private QName service;
-    private QName endpoint;
+    private final QName service;
+    private final QName endpoint;
     
     public EndpointKey(QName service, QName endpoint) {
         if (service == null)

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMap.java Mon Feb 11 06:26:46 2008
@@ -18,11 +18,11 @@
  */
 package org.apache.axis2.jaxws.addressing.util;
 
-import java.util.HashMap;
+import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.axis2.jaxws.addressing.util.EndpointKey;
 
-public class EndpointMap extends HashMap<EndpointKey, String> {
+public class EndpointMap extends ConcurrentHashMap<EndpointKey, String> {
     
     
     /**

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java?rev=620488&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java Mon Feb 11 06:26:46 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.addressing.util;
+
+public class EndpointMapManager {
+    private static ThreadLocal<EndpointMap> variable = new ThreadLocal<EndpointMap>();
+    
+    public static EndpointMap setEndpointMap(EndpointMap newMap) {
+        EndpointMap oldMap = variable.get();
+        variable.set(newMap);
+        
+        return oldMap;
+    }
+    
+    public static EndpointMap getEndpointMap() {
+        EndpointMap currentMap = variable.get();
+        
+        if (currentMap == null) {
+            currentMap = getDefaultEndpointMap();
+            setEndpointMap(currentMap);
+        }
+        
+        return currentMap;
+    }
+    
+    private static EndpointMap getDefaultEndpointMap() {
+        return new EndpointMap();
+    }
+}

Propchange: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointMapManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtils.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtils.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/addressing/util/EndpointReferenceUtils.java Mon Feb 11 06:26:46 2008
@@ -67,7 +67,7 @@
         Element eprElement = XMLUtils.toDOM(omElement);
         Source eprInfoset = new DOMSource(eprElement);
         
-        return jaxwsEPRFactory.createEndpointReference(eprInfoset, addressingNamespace);
+        return jaxwsEPRFactory.createEndpointReference(eprInfoset);
     }
 
     /**
@@ -75,14 +75,14 @@
      * subclass of {@link javax.xml.ws.EndpointReference}.
      * 
      * @param <T>
-     * @param source
+     * @param eprInfoset
      * @param addressingNamespace
      * @return
      * @throws Exception
      */
-    public static javax.xml.ws.EndpointReference convertFromSource(Source source, String addressingNamespace)
+    public static javax.xml.ws.EndpointReference convertFromSource(Source eprInfoset)
     throws Exception {
-        return jaxwsEPRFactory.createEndpointReference(source, addressingNamespace);
+        return jaxwsEPRFactory.createEndpointReference(eprInfoset);
     }
     
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/config/AddressingConfigurator.java Mon Feb 11 06:26:46 2008
@@ -49,8 +49,7 @@
             (AddressingFeature) bnd.getWebServiceFeature(AddressingFeature.ID);
         SubmissionAddressingFeature submissionAddressingFeature =
             (SubmissionAddressingFeature) bnd.getWebServiceFeature(SubmissionAddressingFeature.ID);
-        String specifiedAddressingNamespace = provider.getAddressingNamespace();
-        String enabledAddressingNamespace =
+        String addressingNamespace =
             (String) messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
         Boolean disableAddressing =
             (Boolean) messageContext.getProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES);
@@ -62,34 +61,21 @@
             boolean submissionAddressingEnabled = submissionAddressingFeature.isEnabled();
             
             if (w3cAddressingEnabled && submissionAddressingEnabled) {
-                //If WS-Addressing has already been enabled then stop,
-                //as this configurator has probably already run once.
-                if (!disableAddressing)
-                    return;
-                
-                //If an EPR hasn't been specified then default to 2005/08 addressing,
-                //else use the namespace of the EPR.
-                if (specifiedAddressingNamespace == null)
-                    specifiedAddressingNamespace = Final.WSA_NAMESPACE;
-                
+                //Use the addressing namespace of the specified EPR,
+                //else default to 2005/08
+                addressingNamespace = provider.getAddressingNamespace();
+                if (addressingNamespace == null)
+                    addressingNamespace = Final.WSA_NAMESPACE;
                 disableAddressing = Boolean.FALSE;
             }
             else if (w3cAddressingEnabled) {
                 //Enable only 2005/08 addressing
-                if (Submission.WSA_NAMESPACE.equals(specifiedAddressingNamespace))
-                    throw ExceptionFactory.makeWebServiceException("Illegal configuration.");
-                else
-                    specifiedAddressingNamespace = Final.WSA_NAMESPACE;
-                
+                addressingNamespace = Final.WSA_NAMESPACE;
                 disableAddressing = Boolean.FALSE;
             }
             else if (submissionAddressingEnabled) {
                 //Enable only 2004/08 addressing
-                if (Final.WSA_NAMESPACE.equals(specifiedAddressingNamespace))
-                    throw ExceptionFactory.makeWebServiceException("Illegal configuration.");
-                else
-                    specifiedAddressingNamespace = Submission.WSA_NAMESPACE;
-                
+                addressingNamespace = Submission.WSA_NAMESPACE;
                 disableAddressing = Boolean.FALSE;
             }
             else {
@@ -103,18 +89,16 @@
 
             if (w3cAddressingEnabled) {
                 //Enable 2005/08 addressing
-                if (Submission.WSA_NAMESPACE.equals(specifiedAddressingNamespace))
-                    throw ExceptionFactory.makeWebServiceException("Illegal configuration.");
-                else
-                    specifiedAddressingNamespace = Final.WSA_NAMESPACE;
-                
+                addressingNamespace = Final.WSA_NAMESPACE;
                 disableAddressing = Boolean.FALSE;
             }
             else {
                 //Disable 2005/08 addressing
-                if (enabledAddressingNamespace == null ||
-                        Final.WSA_NAMESPACE.equals(enabledAddressingNamespace))
+                if (addressingNamespace == null ||
+                        Final.WSA_NAMESPACE.equals(addressingNamespace))
                     disableAddressing = Boolean.TRUE;
+                else
+                    disableAddressing = Boolean.FALSE;
             }                
         }
         else if (submissionAddressingFeature != null) {
@@ -123,18 +107,16 @@
             
             if (submissionAddressingEnabled) {
                 //Enable 2004/08 addressing
-                if (Final.WSA_NAMESPACE.equals(specifiedAddressingNamespace))
-                    throw ExceptionFactory.makeWebServiceException("Illegal configuration.");
-                else
-                    specifiedAddressingNamespace = Submission.WSA_NAMESPACE;
-                
+                addressingNamespace = Submission.WSA_NAMESPACE;
                 disableAddressing = Boolean.FALSE;
             }
             else {
                 //Disable 2004/08 addressing
-                if (enabledAddressingNamespace == null ||
-                        Submission.WSA_NAMESPACE.equals(enabledAddressingNamespace))
+                if (addressingNamespace == null ||
+                        Submission.WSA_NAMESPACE.equals(addressingNamespace))
                     disableAddressing = Boolean.TRUE;
+                else
+                    disableAddressing = Boolean.FALSE;
             }                
         }
         else {
@@ -144,7 +126,7 @@
         
         if (!disableAddressing) {
             try {
-                EndpointReference epr = provider.getAxis2EndpointReference(specifiedAddressingNamespace);
+                EndpointReference epr = provider.getAxis2EndpointReference(addressingNamespace);
                 org.apache.axis2.context.MessageContext axis2MessageContext = messageContext.getAxisMessageContext();
                 axis2MessageContext.setTo(epr);
                 
@@ -159,7 +141,7 @@
             }
         }
 
-        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, specifiedAddressingNamespace);                        
+        messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, addressingNamespace);                        
         messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, disableAddressing);
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/EndpointController.java Mon Feb 11 06:26:46 2008
@@ -25,8 +25,9 @@
 import org.apache.axis2.description.WSDL2Constants;
 import org.apache.axis2.java.security.AccessController;
 import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.addressing.factory.Axis2EndpointReferenceFactory;
-import org.apache.axis2.jaxws.addressing.factory.Axis2EndpointReferenceFactoryImpl;
+import org.apache.axis2.jaxws.addressing.util.EndpointKey;
+import org.apache.axis2.jaxws.addressing.util.EndpointMap;
+import org.apache.axis2.jaxws.addressing.util.EndpointMapManager;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.core.util.MessageContextUtils;
 import org.apache.axis2.jaxws.description.DescriptionFactory;
@@ -35,7 +36,6 @@
 import org.apache.axis2.jaxws.handler.HandlerChainProcessor;
 import org.apache.axis2.jaxws.handler.HandlerInvocationContext;
 import org.apache.axis2.jaxws.handler.HandlerInvoker;
-import org.apache.axis2.jaxws.handler.HandlerInvokerUtils;
 import org.apache.axis2.jaxws.handler.HandlerResolverImpl;
 import org.apache.axis2.jaxws.handler.factory.HandlerInvokerFactory;
 import org.apache.axis2.jaxws.i18n.Messages;
@@ -45,9 +45,6 @@
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.server.dispatcher.EndpointDispatcher;
 import org.apache.axis2.jaxws.server.dispatcher.factory.EndpointDispatcherFactory;
-import org.apache.axis2.jaxws.server.endpoint.Utils;
-import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager;
-import org.apache.axis2.jaxws.server.endpoint.lifecycle.factory.EndpointLifecycleManagerFactory;
 import org.apache.axis2.jaxws.spi.Constants;
 import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2004_Constants;
 import org.apache.axis2.wsdl.WSDLConstants.WSDL20_2006Constants;
@@ -401,6 +398,10 @@
             Parameter param = axisSvc.getParameter(EndpointDescription.AXIS_SERVICE_PARAMETER);
 
             EndpointDescription ed = (EndpointDescription)param.getValue();
+            param = axisSvc.getParameter(EndpointMap.class.getCanonicalName());
+            EndpointMap map = (EndpointMap) param.getValue();
+            EndpointMapManager.setEndpointMap(map);
+            
             return ed;
         } else {
             // TODO: This is using a deprecated factory method to create the ServiceDescription.
@@ -416,14 +417,24 @@
             EndpointDescription ed = sd.getEndpointDescriptions_AsCollection().iterator().next();
             
             // TODO: This is only temporary until the deprecated method is no longer used
-            QName service = ed.getServiceQName();
-            QName endpoint = ed.getPortQName();
-            axisSvc = ed.getAxisService();
-            
             try {
-                Axis2EndpointReferenceFactoryImpl axis2EPRFactory =
-                	(Axis2EndpointReferenceFactoryImpl) FactoryRegistry.getFactory(Axis2EndpointReferenceFactory.class);
-                axis2EPRFactory.addAddress(service, endpoint, axisSvc.getEPRs()[0]);
+                QName service = ed.getServiceQName();
+                QName endpoint = ed.getPortQName();
+                EndpointKey key = new EndpointKey(service, endpoint);
+                axisSvc = ed.getAxisService();                
+                Parameter param = axisSvc.getParameter(EndpointMap.class.getCanonicalName());
+                EndpointMap map = null;
+                
+                if (param == null) {
+                    map = EndpointMapManager.getEndpointMap();
+                    axisSvc.addParameter(EndpointMap.class.getCanonicalName(), map);
+                }
+                else {
+                    map = (EndpointMap) param.getValue();
+                    EndpointMapManager.setEndpointMap(map);
+                }
+                
+                map.put(key, axisSvc.getEPRs()[0]);
             }
             catch (Exception e) {
                 throw ExceptionFactory.makeWebServiceException(e);
@@ -431,12 +442,6 @@
             
             return ed;
         }
-    }
-
-    private EndpointLifecycleManager createEndpointlifecycleManager() {
-        EndpointLifecycleManagerFactory elmf = (EndpointLifecycleManagerFactory)FactoryRegistry
-                .getFactory(EndpointLifecycleManagerFactory.class);
-        return elmf.createEndpointLifecycleManager();
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java?rev=620488&r1=620487&r2=620488&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/Provider.java Mon Feb 11 06:26:46 2008
@@ -20,9 +20,6 @@
 
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamResult;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.EndpointReference;
 import javax.xml.ws.Service;
@@ -30,7 +27,6 @@
 import javax.xml.ws.spi.ServiceDelegate;
 import javax.xml.ws.wsaddressing.W3CEndpointReference;
 
-import org.apache.axiom.om.OMElement;
 import org.apache.axis2.addressing.EndpointReferenceHelper;
 import org.apache.axis2.addressing.metadata.ServiceName;
 import org.apache.axis2.addressing.metadata.WSDLLocation;
@@ -38,11 +34,8 @@
 import org.apache.axis2.jaxws.addressing.util.EndpointReferenceUtils;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.server.endpoint.EndpointImpl;
-import org.apache.axis2.util.XMLUtils;
 import org.w3c.dom.Element;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.net.URL;
 import java.util.List;
 
@@ -149,15 +142,7 @@
         EndpointReference jaxwsEPR = null;
 
         try {
-            Transformer xformer = TransformerFactory.newInstance().newTransformer();
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            xformer.transform(eprInfoset, new StreamResult(baos));
-            
-            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-            OMElement eprElement = (OMElement) XMLUtils.toOM(bais);
-            String addressingNamespace = EndpointReferenceHelper.fromOM(null, eprElement);
-            
-            jaxwsEPR = EndpointReferenceUtils.convertFromSource(eprInfoset, addressingNamespace);
+            jaxwsEPR = EndpointReferenceUtils.convertFromSource(eprInfoset);
         }
         catch (Exception e) {
             //TODO NLS enable.



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