cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1515497 - in /cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf: bus/spring/BusApplicationContext.java bus/spring/BusEntityResolver.java test/TestApplicationContext.java
Date Mon, 19 Aug 2013 16:31:54 GMT
Author: dkulp
Date: Mon Aug 19 16:31:54 2013
New Revision: 1515497

URL: http://svn.apache.org/r1515497
Log:
Merged revisions 1514034 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1514034 | dkulp | 2013-08-14 16:40:57 -0400 (Wed, 14 Aug 2013) | 2 lines

  [CXF-5181] Spring doesn't set the proper systemId so relative schema imports don't work
very well.

........

Modified:
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestApplicationContext.java

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java?rev=1515497&r1=1515496&r2=1515497&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
Mon Aug 19 16:31:54 2013
@@ -301,7 +301,7 @@ public class BusApplicationContext exten
     
     void setEntityResolvers(XmlBeanDefinitionReader reader) {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        reader.setEntityResolver(new BusEntityResolver(new BeansDtdResolver(),
+        reader.setEntityResolver(new BusEntityResolver(cl, new BeansDtdResolver(),
             new PluggableSchemaResolver(cl)));
     }
     @Override

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java?rev=1515497&r1=1515496&r2=1515497&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusEntityResolver.java
Mon Aug 19 16:31:54 2013
@@ -20,6 +20,9 @@
 package org.apache.cxf.bus.spring;
 
 import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -29,6 +32,10 @@ import org.xml.sax.SAXException;
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.springframework.beans.factory.xml.DelegatingEntityResolver;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.support.PropertiesLoaderUtils;
+import org.springframework.util.CollectionUtils;
 
 /**
  * 
@@ -39,11 +46,23 @@ public class BusEntityResolver extends D
     
     private EntityResolver dtdResolver;
     private EntityResolver schemaResolver;
+    private Map<String, String> schemaMappings;
+    private ClassLoader classLoader;
     
-    public BusEntityResolver(EntityResolver dr, EntityResolver sr) {
+    public BusEntityResolver(ClassLoader loader, EntityResolver dr, EntityResolver sr) {
         super(dr, sr);
+        classLoader = loader;
         dtdResolver = dr;
         schemaResolver = sr;
+        
+        try {
+            Properties mappings = PropertiesLoaderUtils.loadAllProperties("META-INF/spring.schemas",

+                                                                          classLoader);
+            schemaMappings = new ConcurrentHashMap<String, String>(mappings.size());
+            CollectionUtils.mergePropertiesIntoMap(mappings, schemaMappings);
+        } catch (IOException e) {
+            //ignore
+        }
     }
 
     @Override
@@ -57,6 +76,14 @@ public class BusEntityResolver extends D
                 source = dtdResolver.resolveEntity(publicId, systemId); 
             }
         }
+        String resourceLocation = schemaMappings.get(systemId);
+        if (resourceLocation != null && publicId == null) {
+            Resource resource = new ClassPathResource(resourceLocation, classLoader);
+            if (resource != null && resource.exists()) {
+                source.setPublicId(systemId);    
+                source.setSystemId(resource.getURL().toString());
+            }
+        }
         return source;
     }    
 }

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestApplicationContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestApplicationContext.java?rev=1515497&r1=1515496&r2=1515497&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestApplicationContext.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/test/TestApplicationContext.java
Mon Aug 19 16:31:54 2013
@@ -42,7 +42,7 @@ public class TestApplicationContext exte
     @Override
     protected void initBeanDefinitionReader(XmlBeanDefinitionReader reader) {
         ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        reader.setEntityResolver(new BusEntityResolver(new BeansDtdResolver(),
+        reader.setEntityResolver(new BusEntityResolver(cl, new BeansDtdResolver(),
             new PluggableSchemaResolver(cl)));
     }
    



Mime
View raw message