Author: klape
Date: 2012-01-19 10:13:47 -0500 (Thu, 19 Jan 2012)
New Revision: 15501
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
Log:
Checking in changes from patch JBWS-2975 for one-off JBPAPP-7821
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java 2012-01-19
15:10:26 UTC (rev 15500)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/CustomizableJAXBContextFactory.java 2012-01-19
15:13:47 UTC (rev 15501)
@@ -87,16 +87,35 @@
public JAXBContext createContext(Class[] clazzes, BindingCustomization bcust) throws
WSException
{
+ JAXBContext jaxbCtx = null;
try
{
- JAXBContext jaxbCtx = JAXBContext.newInstance(clazzes, bcust);
- incrementContextCount();
- return jaxbCtx;
+ jaxbCtx = JAXBContext.newInstance(clazzes, bcust);
+ incrementContextCount();
}
catch (JAXBException e)
- {
- throw new WSException("Failed to create JAXBContext", e);
+ {
+ if (bcust != null &&
bcust.get("com.sun.xml.bind.defaultNamespaceRemap") != null)
+ {
+ String dns = (String)
bcust.get("com.sun.xml.bind.defaultNamespaceRemap");
+ bcust.remove("com.sun.xml.bind.defaultNamespaceRemap");
+ bcust.put("com.sun.xml.internal.bind.defaultNamespaceRemap", dns);
+ try
+ {
+ jaxbCtx = JAXBContext.newInstance(clazzes, bcust);
+ incrementContextCount();
+ }
+ catch (JAXBException ex)
+ {
+ throw new WSException("Failed to create JAXBContext", ex);
+ }
+ }
+ else
+ {
+ throw new WSException("Failed to create JAXBContext", e);
+ }
}
+ return jaxbCtx;
}
public JAXBRIContext createContext(Class[] classes, Collection<TypeReference>
refs, String defaultNS, boolean c14n, BindingCustomization bcust)
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java 2012-01-19
15:10:26 UTC (rev 15500)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java 2012-01-19
15:13:47 UTC (rev 15501)
@@ -23,19 +23,26 @@
// $Id$
+import java.lang.reflect.Method;
+
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.ws.WebServiceException;
import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.binding.BindingException;
import org.jboss.ws.core.binding.ComplexTypeDeserializer;
import org.jboss.ws.core.binding.SerializationContext;
import org.jboss.ws.core.binding.TypeMappingImpl;
+import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.xop.jaxws.AttachmentUnmarshallerImpl;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.wsf.spi.binding.BindingCustomization;
/**
@@ -94,9 +101,32 @@
JAXBContext context = cache.get(types);
if(null==context)
{
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
+ String defaultNS = epMetaData.getPortTypeName().getNamespaceURI();
BindingCustomization bindingCustomization = getBindingCustomization();
+ for (Class<?> clz : types)
+ {
+ if (clz.getName().endsWith("ObjectFactory"))
+ {
+ for (Method meth : clz.getMethods())
+ {
+ XmlElementDecl elementDecl = meth.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("com.sun.xml.bind.defaultNamespaceRemap",
defaultNS);
+ }
context = JAXBContextFactory.newInstance().createContext(types,
bindingCustomization);
- cache.add(types, context);
}
return context;
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2012-01-19
15:10:26 UTC (rev 15500)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2012-01-19
15:13:47 UTC (rev 15501)
@@ -23,23 +23,29 @@
// $Id$
+import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Marshaller;
+import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
import javax.xml.ws.WebServiceException;
import org.jboss.logging.Logger;
+import org.jboss.ws.WSException;
+import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.binding.BindingException;
import org.jboss.ws.core.binding.BufferedStreamResult;
import org.jboss.ws.core.binding.ComplexTypeSerializer;
import org.jboss.ws.core.binding.SerializationContext;
+import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.xop.jaxws.AttachmentMarshallerImpl;
+import org.jboss.ws.metadata.umdm.EndpointMetaData;
import org.jboss.wsf.spi.binding.BindingCustomization;
import org.w3c.dom.NamedNodeMap;
@@ -119,9 +125,33 @@
private JAXBContext getJAXBContext(Class[] types){
JAXBContextCache cache = JAXBContextCache.getContextCache();
JAXBContext context = cache.get(types);
- if(null==context)
- {
+ if(null == context)
+ {
+ CommonMessageContext msgContext =
MessageContextAssociation.peekMessageContext();
+ EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
+ String defaultNS = epMetaData.getPortTypeName().getNamespaceURI();
BindingCustomization bindingCustomization = getBindingCustomization();
+ for (Class<?> clz : types)
+ {
+ if (clz.getName().endsWith("ObjectFactory"))
+ {
+ for (Method meth : clz.getMethods())
+ {
+ XmlElementDecl elementDecl = meth.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("com.sun.xml.bind.defaultNamespaceRemap",
defaultNS);
+ }
context = JAXBContextFactory.newInstance().createContext(types,
bindingCustomization);
cache.add(types, context);
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2012-01-19
15:10:26 UTC (rev 15500)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP08_JBPAPP-7821/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2012-01-19
15:13:47 UTC (rev 15501)
@@ -44,6 +44,7 @@
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.annotation.XmlElementDecl;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.ws.Service.Mode;
@@ -58,6 +59,7 @@
import org.jboss.ws.core.jaxrpc.binding.JBossXBSerializerFactory;
import org.jboss.ws.core.jaxrpc.binding.SOAPArrayDeserializerFactory;
import org.jboss.ws.core.jaxrpc.binding.SOAPArraySerializerFactory;
+import org.jboss.ws.core.jaxws.JAXBBindingCustomization;
import org.jboss.ws.core.jaxws.JAXBContextCache;
import org.jboss.ws.core.jaxws.JAXBContextFactory;
import org.jboss.ws.core.jaxws.JAXBDeserializerFactory;
@@ -661,6 +663,28 @@
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);
}
Show replies by date