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 2014/05/02 15:42:30 UTC
[3/7] 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.
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/7a261789
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7a261789
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7a261789
Branch: refs/heads/2.7.x-fixes
Commit: 7a2617893efd8512f36181ff89b8b1c7bd696ee4
Parents: 51eddea
Author: Daniel Kulp <dk...@apache.org>
Authored: Wed Apr 30 14:22:32 2014 -0400
Committer: Daniel Kulp <dk...@apache.org>
Committed: Thu May 1 20:05:48 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/7a261789/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/7a261789/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 83216ca..6640af1 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
@@ -809,8 +809,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
@@ -819,16 +819,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) {