You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2010/06/18 19:47:10 UTC

svn commit: r956067 - in /cxf/trunk: common/common/src/main/java/org/apache/cxf/common/util/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/java/org/apache/cxf/service/factory/ rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ ...

Author: dkulp
Date: Fri Jun 18 17:47:10 2010
New Revision: 956067

URL: http://svn.apache.org/viewvc?rev=956067&view=rev
Log:
[CXF-2851] Reconfigure how schemaLocations are handled
Patch from Nilup Bandara applied

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java Fri Jun 18 17:47:10 2010
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.common.util;
 
+import java.lang.ref.Reference;
 import java.lang.ref.ReferenceQueue;
 import java.lang.ref.WeakReference;
 import java.util.Collection;
@@ -138,11 +139,10 @@ public class WeakIdentityHashMap<K, V> i
     }
 
     private synchronized void reap() {
-        Object zombie = queue.poll();
+        Reference<? extends K> zombie = queue.poll();
 
         while (zombie != null) {
-            IdentityWeakReference victim = (IdentityWeakReference)zombie;
-            backingStore.remove(victim);
+            backingStore.remove(zombie);
             zombie = queue.poll();
         }
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/EndpointImpl.java Fri Jun 18 17:47:10 2010
@@ -127,14 +127,14 @@ public class EndpointImpl extends Abstra
             BindingFactory bf = null;
             try {
                 bf = bus.getExtension(BindingFactoryManager.class).getBindingFactory(namespace);
+                if (null == bf) {
+                    Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
+                    throw new EndpointException(msg);
+                }
                 binding = bf.createBinding(bi);
             } catch (BusException ex) {
                 throw new EndpointException(ex);
             }
-            if (null == bf) {
-                Message msg = new Message("NO_BINDING_FACTORY", BUNDLE, namespace);
-                throw new EndpointException(msg);
-            }
         }    
     }
     

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/AbstractServiceFactoryBean.java Fri Jun 18 17:47:10 2010
@@ -19,20 +19,37 @@
 
 package org.apache.cxf.service.factory;
 
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
 
 import org.apache.cxf.Bus;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataBinding;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.OneWayProcessorInterceptor;
 import org.apache.cxf.interceptor.OutgoingChainInterceptor;
 import org.apache.cxf.interceptor.ServiceInvokerInterceptor;
+import org.apache.cxf.resource.ResourceManager;
+import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.service.Service;
 
 public abstract class AbstractServiceFactoryBean {
+    private static final Logger LOG = LogUtils.getL7dLogger(AbstractServiceFactoryBean.class);
+    
     protected boolean dataBindingSet;
+    protected List<String> schemaLocations;
 
     private Bus bus;
     private DataBinding dataBinding;
@@ -63,6 +80,9 @@ public abstract class AbstractServiceFac
     }
     
     protected void initializeDataBindings() {
+        if (getDataBinding() instanceof AbstractDataBinding && schemaLocations != null) {
+            fillDataBindingSchemas();
+        }
         getDataBinding().initialize(getService());
         
         service.setDataBinding(getDataBinding());
@@ -106,5 +126,33 @@ public abstract class AbstractServiceFac
     protected void setService(Service service) {
         this.service = service;
     }
+    
+    private void fillDataBindingSchemas() {
+        ResourceManager rr = getBus().getExtension(ResourceManager.class);
+        List<DOMSource> schemas = new ArrayList<DOMSource>();
+        for (String l : schemaLocations) {
+            URL url = rr.resolveResource(l, URL.class);
+            if (url == null) {
+                URIResolver res;
+                try {
+                    res = new URIResolver(l);
+                } catch (IOException e) {
+                    throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e);
+                }
+                if (!res.isResolved()) {
+                    throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l));
+                }
+                url = res.getURL();
+            }
+            Document d;
+            try {
+                d = DOMUtils.readXml(url.openStream());
+            } catch (Exception e) {
+                throw new ServiceConstructionException(new Message("ERROR_READING_SCHEMA", LOG, l), e);
+            }
+            schemas.add(new DOMSource(d, url.toString()));
+        }
+        ((AbstractDataBinding)getDataBinding()).setSchemas(schemas);
+    }
  
 }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/service/factory/Messages.properties Fri Jun 18 17:47:10 2010
@@ -19,3 +19,5 @@
 #
 #
 NO_METHOD_FOR_OP=No method was found for the WSDL operation {0}.
+INVALID_SCHEMA_URL=Could not load schema {0}
+ERROR_READING_SCHEMA=There was an error reading the schema {0}.
\ No newline at end of file

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/Messages.properties Fri Jun 18 17:47:10 2010
@@ -19,4 +19,4 @@
 #
 #
 COULD.NOT.RESOLVE.BINDING=Could not resolve a binding for {0}
-ERROR_READING_SCHEMA=There was an error reading the schema {0}.
\ No newline at end of file
+

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Fri Jun 18 17:47:10 2010
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.service.factory;
 
-import java.io.IOException;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Array;
 import java.lang.reflect.Field;
@@ -53,11 +52,9 @@ import javax.xml.bind.annotation.XmlList
 import javax.xml.bind.annotation.XmlMimeType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
-import javax.xml.transform.dom.DOMSource;
 
 import org.w3c.dom.DOMError;
 import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.Document;
 
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -70,7 +67,6 @@ import org.apache.cxf.common.util.String
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.common.xmlschema.XmlSchemaUtils;
 import org.apache.cxf.common.xmlschema.XmlSchemaValidationManager;
-import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.mime.MimeAttribute;
 import org.apache.cxf.databinding.source.mime.MimeSerializer;
@@ -83,14 +79,12 @@ import org.apache.cxf.frontend.FaultInfo
 import org.apache.cxf.frontend.MethodDispatcher;
 import org.apache.cxf.frontend.SimpleMethodDispatcher;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.MethodComparator;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.FaultOutInterceptor;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.resource.ResourceManager;
-import org.apache.cxf.resource.URIResolver;
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.ServiceImpl;
 import org.apache.cxf.service.ServiceModelSchemaValidator;
@@ -120,11 +114,12 @@ import org.apache.ws.commons.schema.XmlS
 import org.apache.ws.commons.schema.XmlSchemaObject;
 import org.apache.ws.commons.schema.XmlSchemaObjectTable;
 import org.apache.ws.commons.schema.XmlSchemaSequence;
-
 import org.apache.ws.commons.schema.XmlSchemaType;
 import org.apache.ws.commons.schema.constants.Constants;
 import org.apache.ws.commons.schema.utils.NamespaceMap;
 
+
+
 /**
  * Introspects a class and builds a {@link Service} from it. If a WSDL URL is
  * specified, a Service model will be directly from the WSDL and then metadata
@@ -181,7 +176,6 @@ public class ReflectionServiceFactoryBea
     private Map<Method, Boolean> isRpcCache = new HashMap<Method, Boolean>();
     private String styleCache;
     private Boolean defWrappedCache;
-    private List<String> schemaLocations;
     
     public ReflectionServiceFactoryBean() {
         getServiceConfigurations().add(0, new DefaultServiceConfiguration());
@@ -229,39 +223,6 @@ public class ReflectionServiceFactoryBea
             }
             retVal = db;
         }
-        if (retVal instanceof AbstractDataBinding && schemaLocations != null) {
-            ResourceManager rr = getBus().getExtension(ResourceManager.class);
-
-            List<DOMSource> schemas = new ArrayList<DOMSource>();
-            for (String l : schemaLocations) {
-                URL url = rr.resolveResource(l, URL.class);
-
-                if (url == null) {
-                    URIResolver res;
-                    try {
-                        res = new URIResolver(l);
-                    } catch (IOException e) {
-                        throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l), e);
-                    }
-
-                    if (!res.isResolved()) {
-                        throw new ServiceConstructionException(new Message("INVALID_SCHEMA_URL", LOG, l));
-                    }
-                    url = res.getURL();
-                }
-
-                Document d;
-                try {
-                    d = DOMUtils.readXml(url.openStream());
-                } catch (Exception e) {
-                    throw new ServiceConstructionException(
-                        new Message("ERROR_READING_SCHEMA", LOG, l), e);
-                }
-                schemas.add(new DOMSource(d, url.toString()));
-            }
-
-            ((AbstractDataBinding)retVal).setSchemas(schemas);
-        }
         return retVal;
     }
     public void reset() {

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties?rev=956067&r1=956066&r2=956067&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties Fri Jun 18 17:47:10 2010
@@ -33,4 +33,4 @@ INTRACTABLE_PART= Message part {0} of Me
 JAXWS_ANNOTATION_FOUND=A JAX-WS Annotation was found on {0} while using the Simple frontend.  For better results, use the JAX-WS frontend.
 XSD_VALIDATION_ERROR= Error in W3C XML Schema associated with service: {0}
 COULD_NOT_UNWRAP=Could not unwrap Operation {0} to match method "{1}"
-INVALID_SCHEMA_URL=Could not load schema {0}
\ No newline at end of file
+