{
//initialize jaxb context cache
if ("true".equalsIgnoreCase(System.getProperty(Constants.EAGER_INITIALIZE_JAXB_CONTEXT_CACHE)))
{
log.debug("Initializing JAXBContext cache...");
BindingCustomization bindingCustomization = null;
if (this instanceof ServerEndpointMetaData)
{
bindingCustomization = ((ServerEndpointMetaData)this).getEndpoint().getAttachment(BindingCustomization.class);
}
try
{
Class[] classes = getRegisteredTypes().toArray(new Class[0]);
String defaultNS = portTypeName.getNamespaceURI();
for (Class<?> clz : classes)
{
if (clz.getName().endsWith("ObjectFactory"))
{
for (Method method : clz.getMethods())
{
XmlElementDecl elementDecl = method.getAnnotation(XmlElementDecl.class);
if (elementDecl != null && XmlElementDecl.GLOBAL.class.equals(elementDecl.scope())
&& elementDecl.namespace() != null && elementDecl.namespace().length() > 0)
{
defaultNS = null;
}
}
}
}
if (defaultNS != null)
{
if (bindingCustomization == null)
bindingCustomization = new JAXBBindingCustomization();
bindingCustomization.put(JAXBBindingCustomization.DEFAULT_NAMESPACE_REMAP, defaultNS);
}
JAXBContext context = JAXBContextFactory.newInstance().createContext(classes, bindingCustomization);
jaxbCache.add(classes, context);
}
catch (Exception e)