cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [4/5] git commit: Update to only hack in the catalog resolver if catalogs are actually used. Fix the logic around it to work with in JDK xjc.
Date Fri, 02 May 2014 14:57:55 GMT
Update to only hack in the catalog resolver if catalogs are actually used.  Fix the logic around
it to work with in JDK xjc.


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/ac9eb627
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/ac9eb627
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/ac9eb627

Branch: refs/heads/2.6.x-fixes
Commit: ac9eb62726f6591174305e1612902dfdb18d374a
Parents: a9cab01
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Apr 30 14:22:32 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri May 2 09:54:06 2014 -0400

----------------------------------------------------------------------
 .../apache/cxf/catalog/OASISCatalogManager.java |  5 +++
 .../endpoint/dynamic/DynamicClientFactory.java  | 33 ++++++++++++++------
 2 files changed, 28 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/ac9eb627/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
----------------------------------------------------------------------
diff --git a/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java b/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
index 6c5e17e..2aa061e 100644
--- a/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
+++ b/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
@@ -70,6 +70,11 @@ public class OASISCatalogManager {
         catalog = getCatalog(resolver);
         loadContextCatalogs(DEFAULT_CATALOG_NAME);
     }
+    
+    public boolean hasCatalogs() {
+        return !loadedCatalogs.isEmpty();
+    }
+    
     private static Object getCatalog(EntityResolver resolver) {
         try {
             return ((CatalogResolver)resolver).getCatalog();

http://git-wip-us.apache.org/repos/asf/cxf/blob/ac9eb627/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
----------------------------------------------------------------------
diff --git a/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
b/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
index a503b75..8933daf 100644
--- a/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
+++ b/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
@@ -801,8 +801,8 @@ public class DynamicClientFactory {
 
     private void hackInNewInternalizationLogic(SchemaCompiler schemaCompiler,
                                                final OASISCatalogManager catalog) {
+        Object o = ((ReflectionInvokationHandler)Proxy.getInvocationHandler(schemaCompiler)).getTarget();
         try {
-            Object o = ((ReflectionInvokationHandler)Proxy.getInvocationHandler(schemaCompiler)).getTarget();
             Field f = o.getClass().getDeclaredField("forest");
             Object forest = ReflectionUtil.setAccessible(f).get(o);
             // Set the error handler
@@ -811,16 +811,29 @@ public class DynamicClientFactory {
                     m.invoke(forest, o);
                 }
             }
-            
-            f = forest.getClass().getDeclaredField("logic");
-            Object xil = ReflectionUtil.setAccessible(f).get(forest);
-            if (xil.getClass().getName().contains(".internal.")) {
-                xil = createWrapperLogic(xil, catalog);
-                ReflectionUtil.setAccessible(f).set(forest, xil);
-            }
         } catch (Throwable ex)  {
-            //ignore
-            ex.printStackTrace();
+            //ignorable, just won't get all the errors
+            LOG.info("Unable to set error handler on " + o.getClass());
+        }
+        if (catalog.hasCatalogs()) {
+            try {
+                Field f = o.getClass().getDeclaredField("forest");
+                Object forest = ReflectionUtil.setAccessible(f).get(o);
+                f = forest.getClass().getDeclaredField("logic");
+                Object xil = ReflectionUtil.setAccessible(f).get(forest);
+                if (!xil.getClass().getName().contains(".internal.")) {
+                    xil = createWrapperLogic(xil, catalog);
+                    if (xil != null) {
+                        ReflectionUtil.setAccessible(f).set(forest, xil);
+                    }
+                } else {
+                    LOG.warning("Cannot set a catalog resolver into the JDK internal XJC
compiler.  Catalog"
+                        + " resolved schemas may not work correctly");
+                }
+            } catch (Throwable ex)  {
+                LOG.log(Level.WARNING, "Cannot set a catalog resolver into the XJC compiler.
 Catalog"
+                    + " resolved schemas may not work correctly", ex);
+            }
         }
     }
     private Object createWrapperLogic(final Object xil, final OASISCatalogManager catalog)
{


Mime
View raw message