cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r544642 - in /incubator/cxf/trunk: distribution/src/main/assembly/ rt/core/src/main/java/org/apache/cxf/catalog/ rt/core/src/main/java/org/apache/cxf/wsdl11/ rt/core/src/main/resources/META-INF/ rt/core/src/main/resources/META-INF/cxf/ syst...
Date Tue, 05 Jun 2007 21:30:47 GMT
Author: dkulp
Date: Tue Jun  5 14:30:46 2007
New Revision: 544642

URL: http://svn.apache.org/viewvc?view=rev&rev=544642
Log:
Update OASIS catalog stuff to be a real bus extension so we don't create new Catalogs for
every wsdl/schema we processes.


Modified:
    incubator/cxf/trunk/distribution/src/main/assembly/src.xml
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ResourceManagerWSDLLocator.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/bus-extensions.xml
    incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java

Modified: incubator/cxf/trunk/distribution/src/main/assembly/src.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/distribution/src/main/assembly/src.xml?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/distribution/src/main/assembly/src.xml (original)
+++ incubator/cxf/trunk/distribution/src/main/assembly/src.xml Tue Jun  5 14:30:46 2007
@@ -23,54 +23,56 @@
     <includeBaseDirectory>false</includeBaseDirectory>
     <formats>
         <format>tar.gz</format>
-	<format>zip</format>
+        <format>zip</format>
     </formats>
 
     <fileSets>
-	 <fileSet>
-             <directory>src/main/release</directory>
-	     <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
-	     <includes>
-	         <include>DISCLAIMER</include>
-		 <include>LICENSE</include>
-		 <include>licenses/*.*</include>
-		 <include>README</include>
-		 <include>BUILDING.txt</include>
-             </includes>
-	 </fileSet>
-         <fileSet>
-             <directory>target/maven-shared-archive-resources/META-INF</directory>
-             <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
-             <includes>
-                 <include>NOTICE</include>
-             </includes>
-         </fileSet>
-	 <fileSet>
-	     <directory>..</directory>
-	     <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
-	     <includes>
-	         <include>**/*</include>
-             </includes>
-             <excludes>
-		 <exclude>build.xml</exclude>
-		 <exclude>distribution/build.xml</exclude>
-		 <exclude>benchmark</exclude>
-		 <exclude>benchmark/**/*</exclude>
-	         <exclude>**/target</exclude>
-		 <exclude>**/target/**/*</exclude>
-		 <exclude>**/build</exclude>
-		 <exclude>**/build/**/*</exclude>
-		 <exclude>**/.settings</exclude>
-		 <exclude>**/.classpath</exclude>
-		 <exclude>**/.project</exclude>
-		 <exclude>**/.wtpmodules</exclude>
-		 <exclude>**/surefire*</exclude>
-		 <exclude>**/cobertura.ser</exclude>
-		 <exclude>bin</exclude>
-		 <exclude>bin/*</exclude>
-		 <exclude>**/var/journal</exclude>
-		 <exclude>**/build.out*</exclude>
-             </excludes>
-	 </fileSet>
-     </fileSets>
+        <fileSet>
+            <directory>src/main/release</directory>
+            <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
+            <includes>
+                <include>DISCLAIMER</include>
+                <include>LICENSE</include>
+                <include>licenses/*.*</include>
+                <include>README</include>
+                <include>BUILDING.txt</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>target/maven-shared-archive-resources/META-INF</directory>
+            <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
+            <includes>
+                <include>NOTICE</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>..</directory>
+            <outputDirectory>cxf-${cxf.version}-src</outputDirectory>
+            <includes>
+                <include>**/*</include>
+            </includes>
+            <excludes>
+                <exclude>build.xml</exclude>
+                <exclude>distribution/build.xml</exclude>
+                <exclude>benchmark</exclude>
+                <exclude>benchmark/**/*</exclude>
+                <exclude>**/target</exclude>
+                <exclude>**/target/**/*</exclude>
+                <exclude>**/build</exclude>
+                <exclude>**/build/**/*</exclude>
+                <exclude>**/.settings</exclude>
+                <exclude>**/pmd-eclipse.log</exclude>
+                <exclude>**/.classpath</exclude>
+                <exclude>**/.project</exclude>
+                <exclude>**/.wtpmodules</exclude>
+                <exclude>**/surefire*</exclude>
+                <exclude>**/cobertura.ser</exclude>
+                <exclude>bin</exclude>
+                <exclude>bin/*</exclude>
+                <exclude>**/var/journal</exclude>
+                <exclude>**/build.out*</exclude>
+                <exclude>STATUS</exclude>
+            </excludes>
+        </fileSet>
+    </fileSets>
 </assembly>

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogWSDLLocator.java
Tue Jun  5 14:30:46 2007
@@ -38,10 +38,10 @@
     private Catalog catalogResolver;
     private String baseUri;
     
-    public CatalogWSDLLocator(String wsdlUrl, Catalog catalogResolver) {
+    public CatalogWSDLLocator(String wsdlUrl, OASISCatalogManager catalogManager) {
         this.wsdlUrl = wsdlUrl;
         this.baseUri = this.wsdlUrl;
-        this.catalogResolver = catalogResolver;
+        this.catalogResolver = catalogManager.getCatalog();
         this.resolver = new ExtendedURIResolver();
     }
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/CatalogXmlSchemaURIResolver.java
Tue Jun  5 14:30:46 2007
@@ -35,9 +35,9 @@
     private ExtendedURIResolver resolver;
     private Catalog catalogResolver;
     
-    public CatalogXmlSchemaURIResolver(Catalog catalogResolver) {
+    public CatalogXmlSchemaURIResolver(OASISCatalogManager catalogManager) {
         this.resolver = new ExtendedURIResolver();
-        this.catalogResolver = catalogResolver;
+        this.catalogResolver = catalogManager.getCatalog();
     }
 
     public InputSource resolveEntity(String targetNamespace, String schemaLocation, String
baseUri) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
Tue Jun  5 14:30:46 2007
@@ -20,21 +20,30 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+
 import org.apache.cxf.Bus;
 import org.apache.xml.resolver.Catalog;
 import org.apache.xml.resolver.CatalogManager;
 import org.apache.xml.resolver.tools.CatalogResolver;
 
 public class OASISCatalogManager {
+    public static final String DEFAULT_CATALOG_NAME = "META-INF/jax-ws-catalog.xml";
 
     private static final Logger LOG =
         Logger.getLogger(OASISCatalogManager.class.getName());
 
     private Catalog resolver;
+    private Set<URL> loadedCatalogs = Collections.synchronizedSet(new HashSet<URL>());
+    private Bus bus;  
     
     public OASISCatalogManager() {
         CatalogManager catalogManager = new CatalogManager();
@@ -44,45 +53,71 @@
         this.resolver = catalogResolver.getCatalog();
     }
     
+    public Bus getBus() {
+        return bus;
+    }
+    
+    @Resource
+    public void setBus(Bus bus) {        
+        this.bus = bus;
+    }
+    
+    @PostConstruct
+    public void register() {
+        if (null != bus) {
+            bus.setExtension(this, OASISCatalogManager.class);
+        }
+        loadContextCatalogs();
+    }
+    
     public Catalog getCatalog() {
         return this.resolver;
     }
 
     public void loadContextCatalogs() {
+        loadContextCatalogs(DEFAULT_CATALOG_NAME);
+    }
+    public void loadContextCatalogs(String name) {
         try {
-            loadCatalogs(Thread.currentThread().getContextClassLoader());
+            loadCatalogs(Thread.currentThread().getContextClassLoader(), name);
         } catch (IOException e) {
-            LOG.log(Level.WARNING, "Error loading META-INF/jax-ws-catalog.xml catalog files",
e);
+            LOG.log(Level.WARNING, "Error loading " + name + " catalog files", e);
         }
     }
     
-    public void loadCatalogs(ClassLoader classLoader) throws IOException {
+    public void loadCatalogs(ClassLoader classLoader, String name) throws IOException {
         if (classLoader == null) {
             return;
         }
         
-        Enumeration<URL> catalogs = classLoader.getResources("META-INF/jax-ws-catalog.xml");
+        Enumeration<URL> catalogs = classLoader.getResources(name);
         while (catalogs.hasMoreElements()) {
             URL catalogURL = catalogs.nextElement();
-            this.resolver.parseCatalog(catalogURL);
+            if (!loadedCatalogs.contains(catalogURL)) {
+                this.resolver.parseCatalog(catalogURL);
+                loadedCatalogs.add(catalogURL);
+            }
         }
     }
     
     public void loadCatalog(URL catalogURL) throws IOException {
-        this.resolver.parseCatalog(catalogURL);
+        if (!loadedCatalogs.contains(catalogURL)) {
+            this.resolver.parseCatalog(catalogURL);
+            loadedCatalogs.add(catalogURL);
+        }
     }
 
-    private static Catalog getContextCatalog() {
+    private static OASISCatalogManager getContextCatalog() {
         OASISCatalogManager oasisCatalog = new OASISCatalogManager();
         oasisCatalog.loadContextCatalogs();
-        return oasisCatalog.getCatalog();
+        return oasisCatalog;
     }
 
-    public static Catalog getCatalog(Bus bus) {
+    public static OASISCatalogManager getCatalogManager(Bus bus) {
         if (bus == null) {
             return getContextCatalog();
         }
-        Catalog catalog = bus.getExtension(Catalog.class);
+        OASISCatalogManager catalog = bus.getExtension(OASISCatalogManager.class);
         if (catalog == null) {
             return getContextCatalog();
         } else {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ResourceManagerWSDLLocator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ResourceManagerWSDLLocator.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ResourceManagerWSDLLocator.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/ResourceManagerWSDLLocator.java
Tue Jun  5 14:30:46 2007
@@ -48,7 +48,7 @@
                                       Bus bus) {
         this.wsdlUrl = wsdlUrl;
         this.bus = bus;
-        this.parent = new CatalogWSDLLocator(wsdlUrl, OASISCatalogManager.getCatalog(bus));
+        this.parent = new CatalogWSDLLocator(wsdlUrl, OASISCatalogManager.getCatalogManager(bus));
     }
 
 

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLManagerImpl.java Tue
Jun  5 14:30:46 2007
@@ -191,7 +191,7 @@
         reader.setFeature("javax.wsdl.verbose", false);
         reader.setExtensionRegistry(registry);
         CatalogWSDLLocator catLocator = 
-            new CatalogWSDLLocator(url, OASISCatalogManager.getCatalog(bus));
+            new CatalogWSDLLocator(url, OASISCatalogManager.getCatalogManager(bus));
         ResourceManagerWSDLLocator wsdlLocator = new ResourceManagerWSDLLocator(url,
                                                                                 catLocator,
                                                                                 bus);

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
Tue Jun  5 14:30:46 2007
@@ -325,7 +325,7 @@
                     
                     schemaCol.setBaseUri(def.getDocumentBaseURI());
                     CatalogXmlSchemaURIResolver schemaResolver = 
-                        new CatalogXmlSchemaURIResolver(OASISCatalogManager.getCatalog(bus));
+                        new CatalogXmlSchemaURIResolver(OASISCatalogManager.getCatalogManager(bus));
                     schemaCol.setSchemaResolver(schemaResolver);
                     XmlSchema xmlSchema = schemaCol.read(schemaElem, systemId);
 

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/bus-extensions.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/bus-extensions.xml?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/bus-extensions.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/bus-extensions.xml Tue Jun  5
14:30:46 2007
@@ -41,5 +41,7 @@
        	   interface="org.apache.cxf.endpoint.EndpointResolverRegistry"/>
     <extension class="org.apache.cxf.headers.HeaderManagerImpl"
        	   interface="org.apache.cxf.headers.HeaderManager"/>
+    <extension class="org.apache.cxf.catalog.OASISCatalogManager"
+       	   interface="org.apache.cxf.catalog.OASISCatalogManager"/>
            
 </extensions>

Modified: incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml (original)
+++ incubator/cxf/trunk/rt/core/src/main/resources/META-INF/cxf/cxf.xml Tue Jun  5 14:30:46
2007
@@ -102,4 +102,7 @@
     <bean id="org.apache.cxf.headers.HeaderManager" class="org.apache.cxf.headers.HeaderManagerImpl">
         <property name="bus" ref="cxf"/>
     </bean>
+    <bean id="org.apache.cxf.catalog.OASISCatalogManager" class="org.apache.cxf.catalog.OASISCatalogManager">
+        <property name="bus" ref="cxf"/>
+    </bean>
 </beans>

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java?view=diff&rev=544642&r1=544641&r2=544642
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/OASISCatalogTest.java
Tue Jun  5 14:30:46 2007
@@ -35,7 +35,6 @@
 import org.apache.hello_world.Greeter;
 import org.apache.hello_world.services.SOAPService;
 
-import org.apache.xml.resolver.Catalog;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -69,7 +68,7 @@
         // set Catalog on the Bus
         Bus bus = BusFactory.getDefaultBus();
         OASISCatalogManager catalog = new OASISCatalogManager();
-        bus.setExtension(catalog.getCatalog(), Catalog.class);
+        bus.setExtension(catalog, OASISCatalogManager.class);
         
         try {
             SOAPService service = new SOAPService(wsdl, serviceName);
@@ -102,7 +101,7 @@
        
         CatalogWSDLLocator wsdlLocator =
             new CatalogWSDLLocator(wsdl.toString(),
-                                   OASISCatalogManager.getCatalog(null));
+                                   OASISCatalogManager.getCatalogManager(null));
         wsdlReader.setFeature("javax.wsdl.verbose", false);
         wsdlReader.readWSDL(wsdlLocator);
     }
@@ -119,7 +118,7 @@
        
         OASISCatalogManager catalog = new OASISCatalogManager();
         CatalogWSDLLocator wsdlLocator =
-            new CatalogWSDLLocator(wsdl.toString(), catalog.getCatalog());
+            new CatalogWSDLLocator(wsdl.toString(), catalog);
         try {
             wsdlReader.readWSDL(wsdlLocator);
             fail("Test did not fail as expected");



Mime
View raw message