Skip to content

Instantly share code, notes, and snippets.

@johnpoth
Created December 15, 2016 08:44
Show Gist options
  • Save johnpoth/485768993f8fc39910bef468a7226dc3 to your computer and use it in GitHub Desktop.
Save johnpoth/485768993f8fc39910bef468a7226dc3 to your computer and use it in GitHub Desktop.
public URL getSchemaLocation(String namespace) {
final ClassLoader classLoader = getClass().getClassLoader();
if ("http://cxf.apache.org/blueprint/jaxws".equals(namespace)) {
return classLoader.getResource("schemas/blueprint/jaxws.xsd");
} else {
try {
Class<?> extNsHandlerClazz;
Bundle extBundle = FrameworkUtil.getBundle(Endpoint.class);
if (extBundle == null) {
// we may not be in OSGi environment
extNsHandlerClazz = classLoader.loadClass("org.apache.cxf.internal.CXFAPINamespaceHandler");
} else {
extNsHandlerClazz = extBundle.loadClass("org.apache.cxf.internal.CXFAPINamespaceHandler");
}
final NamespaceHandler handler = (NamespaceHandler) extNsHandlerClazz.newInstance();
// if the given namespace is the location, pass the corresponding namespace instead
if ("http://cxf.apache.org/schemas/configuration/cxf-beans.xsd".equals(namespace)) {
return handler.getSchemaLocation("http://cxf.apache.org/configuration/beans");
}
if ("http://cxf.apache.org/schemas/configuration/parameterized-types.xsd".equals(namespace)) {
return handler.getSchemaLocation("http://cxf.apache.org/configuration/parameterized-types");
}
return handler.getSchemaLocation(namespace);
} catch (Throwable t) {
LOG.warning("Could not locate ext namespace schema: " + t.getMessage());
return null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment