cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/2] 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 Wed, 30 Apr 2014 18:53:52 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 2156bf58d -> cfda95f21


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/cfda95f2
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/cfda95f2
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/cfda95f2

Branch: refs/heads/master
Commit: cfda95f21681b4193ca9b8c3c5749b2c067aac15
Parents: aa0179d
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Apr 30 14:22:32 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Apr 30 14:53:45 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/cfda95f2/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java b/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
index 6c5e17e..2aa061e 100644
--- a/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
+++ b/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/cfda95f2/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
----------------------------------------------------------------------
diff --git a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
index 1f81847..2562ccc 100644
--- a/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
+++ b/rt/frontend/simple/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
@@ -810,8 +810,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
@@ -820,16 +820,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