Skip to content

Commit

Permalink
Merge pull request #21471 from neuwerk/xlxpCXfNamespacePrefixMapper
Browse files Browse the repository at this point in the history
jaxws-2.2: Update CXF to account for changes in XLXP and clean up projects
  • Loading branch information
neuwerk authored Jun 19, 2022
2 parents 1a9478f + 7e2f381 commit 574282a
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 551 deletions.
7 changes: 0 additions & 7 deletions dev/com.ibm.ws.cxf.client/.classpath

This file was deleted.

23 changes: 0 additions & 23 deletions dev/com.ibm.ws.cxf.client/.project

This file was deleted.

2 changes: 0 additions & 2 deletions dev/com.ibm.ws.cxf.client/.settings/bndtools.core.prefs

This file was deleted.

This file was deleted.

289 changes: 0 additions & 289 deletions dev/com.ibm.ws.cxf.client/.settings/org.eclipse.jdt.core.prefs

This file was deleted.

60 changes: 0 additions & 60 deletions dev/com.ibm.ws.cxf.client/.settings/org.eclipse.jdt.ui.prefs

This file was deleted.

36 changes: 0 additions & 36 deletions dev/com.ibm.ws.cxf.client/bnd.bnd

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.lang.NoClassDefFoundError;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
Expand Down Expand Up @@ -626,10 +627,20 @@ private static synchronized ClassLoader getXJCClassLoader() {

public static Object setNamespaceMapper(Bus bus, final Map<String, String> nspref,
Marshaller marshaller) throws PropertyException {
LOG.info("****@TTJJ className of mapper is: " + marshaller.getClass() + " nspref stands for " + nspref);
ClassLoaderService classLoaderService = bus.getExtension(ClassLoaderService.class);
// if(marshaller.getClass().getName().startsWith("com.ibm")) {
// try {
// Object mapper = classLoaderService.createNamespaceWrapperInstance(marshaller.getClass(), nspref);
// } catch (NoClassDefFound) {
// if(NoClassDefFoundError e) {
// // do nothing since XLXP has messed with the way this property gets read.
// }
// }
// }
Object mapper = classLoaderService.createNamespaceWrapperInstance(marshaller.getClass(), nspref);
if (mapper != null) {
if (marshaller.getClass().getName().contains(".internal.")) {
if ((marshaller.getClass().getName().contains("com.sun") && marshaller.getClass().getName().contains(".internal."))) {
marshaller.setProperty("com.sun.xml.internal.bind.namespacePrefixMapper",
mapper);
} else if (marshaller.getClass().getName().contains("com.sun")) {
Expand All @@ -641,6 +652,8 @@ public static Object setNamespaceMapper(Bus bus, final Map<String, String> nspre
//Liberty change begin
} else if (marshaller.getClass().getName().startsWith("org.glassfish.")) {
marshaller.setProperty("org.glassfish.jaxb.namespacePrefixMapper", mapper);
} else if (marshaller.getClass().getName().startsWith("com.ibm")) {
marshaller.setProperty("com.ibm.jtc.jax.xml.bind.namespacePrefixMapper", mapper);
}
//Liberty change end
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ public synchronized Class<?> createNamespaceWrapperClass(Class<?> mcls, Map<Stri

if (mcls.getName().contains("eclipse")) {
return createEclipseNamespaceMapper(mcls, map);
} else if (mcls.getName().contains(".internal")) {
} else if (mcls.getName().contains("com.sun") && mcls.getName().contains(".internal")) {
postFix = "Internal";
} else if (mcls.getName().contains("com.sun")) {
postFix = "RI";
//Liberty change begin
} else if (mcls.getName().startsWith("org.glassfish")) {
postFix = "Glassfish";
} else if (mcls.getName().startsWith("com.ibm")) {
postFix = "IBM";
}
//Liberty change end

Expand All @@ -65,7 +67,23 @@ public synchronized Class<?> createNamespaceWrapperClass(Class<?> mcls, Map<Stri
if (cls == null) {
try {
byte[] bts = createNamespaceWrapperInternal(postFix);
className = "org.apache.cxf.jaxb.NamespaceMapper" + postFix;
className = "org.apache.cxf.jaxb.NamespaceMapper" + postFix;

if(postFix.equals("IBM")) {
try {
return loadClass(className, NamespaceClassCreator.class, bts);
} catch(NoClassDefFoundError e) {
postFix = "RI";
className = "org.apache.cxf.jaxb.NamespaceMapper";
className += postFix;
cls = findClass(className, NamespaceClassCreator.class);

bts = createNamespaceWrapperInternal(postFix);
return loadClass(className, NamespaceClassCreator.class, bts);

}
}

return loadClass(className, NamespaceClassCreator.class, bts);
} catch (RuntimeException ex) {
// continue
Expand Down Expand Up @@ -300,11 +318,17 @@ private byte[] createEclipseNamespaceMapper() {
private byte[] createNamespaceWrapperInternal(String postFix) {

//Liberty change begin
String superName = "Glassfish".equals(postFix) ?
String superName;

if(postFix.equals("IBM")) {
superName = "com/ibm/jtc/jax/xml/bind/namespacePrefixMapper";
} else {
superName = "Glassfish".equals(postFix) ?
"org/glassfish/jaxb/runtime/marshaller/NamespacePrefixMapper" :
("com/sun/xml/"
+ ("RI".equals(postFix) ? "" : "internal/")
+ "bind/marshaller/NamespacePrefixMapper");
}
//Liberty change end
String postFixedName = "org/apache/cxf/jaxb/NamespaceMapper" + postFix;
ASMHelper.ClassWriter cw = helper.createClassWriter();
Expand Down
2 changes: 2 additions & 0 deletions dev/com.ibm.ws.org.apache.cxf.rt.security.3.4.1/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#*******************************************************************************
-include= jar:${fileuri;${repo;org.apache.cxf:cxf-rt-security;3.4.1;EXACT}}!/META-INF/MANIFEST.MF,bnd.overrides

-sub: *.bnd

-includeresource: \
@${repo;org.apache.cxf:cxf-rt-security;3.4.1;EXACT}!/!META-INF/maven/*|META-INF/MANIFEST.MF, \
@${repo;org.apache.cxf:cxf-rt-security;3.4.1;EXACT}!/META-INF/DEPENDENCIES, \
Expand Down
Loading

0 comments on commit 574282a

Please sign in to comment.