Author: alessio.soldano(a)jboss.com
Date: 2008-09-29 07:01:57 -0400 (Mon, 29 Sep 2008)
New Revision: 8283
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/ObjectContent.java
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
Log:
[JBPAPP-919] Porting fixes for JBWS-2270 and JBWS-2207
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java 2008-09-29
06:14:54 UTC (rev 8282)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/Constants.java 2008-09-29
11:01:57 UTC (rev 8283)
@@ -315,4 +315,6 @@
static final String WSDL20_PATTERN_OUT_OPT_IN =
"http://www.w3.org/2004/08/wsdl/out-opt-in";
static final String ASYNC_METHOD_SUFFIX = "Async";
+
+ static final String EAGER_INITIALIZE_JAXB_CONTEXT_CACHE =
"org.jboss.ws.eagerInitializeJAXBContextCache";
}
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java 2008-09-29
06:14:54 UTC (rev 8282)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBDeserializer.java 2008-09-29
11:01:57 UTC (rev 8283)
@@ -23,18 +23,6 @@
// $Id$
-import org.jboss.ws.extensions.xop.jaxws.AttachmentUnmarshallerImpl;
-import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.TypeMappingImpl;
-import org.jboss.ws.core.binding.ComplexTypeDeserializer;
-import org.jboss.ws.core.binding.SerializationContext;
-import org.jboss.ws.core.soap.MessageContextAssociation;
-import org.jboss.ws.metadata.umdm.EndpointMetaData;
-import org.jboss.ws.metadata.umdm.ServerEndpointMetaData;
-import org.jboss.logging.Logger;
-import org.jboss.wsf.spi.deployment.Endpoint;
-import org.jboss.wsf.spi.binding.BindingCustomization;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
@@ -42,6 +30,14 @@
import javax.xml.transform.Source;
import javax.xml.ws.WebServiceException;
+import org.jboss.logging.Logger;
+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.extensions.xop.jaxws.AttachmentUnmarshallerImpl;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+
/**
* A Deserializer that can handle complex types by delegating to JAXB.
*
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2008-09-29
06:14:54 UTC (rev 8282)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/jaxws/JAXBSerializer.java 2008-09-29
11:01:57 UTC (rev 8283)
@@ -23,14 +23,8 @@
// $Id$
-import org.jboss.logging.Logger;
-import org.jboss.ws.extensions.xop.jaxws.AttachmentMarshallerImpl;
-import org.jboss.ws.core.binding.BindingException;
-import org.jboss.ws.core.binding.ComplexTypeSerializer;
-import org.jboss.ws.core.binding.SerializationContext;
-import org.jboss.ws.core.binding.BufferedStreamResult;
-import org.jboss.wsf.spi.binding.BindingCustomization;
-import org.w3c.dom.NamedNodeMap;
+import java.util.Arrays;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
@@ -40,6 +34,15 @@
import javax.xml.transform.Result;
import javax.xml.ws.WebServiceException;
+import org.jboss.logging.Logger;
+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.extensions.xop.jaxws.AttachmentMarshallerImpl;
+import org.jboss.wsf.spi.binding.BindingCustomization;
+import org.w3c.dom.NamedNodeMap;
+
/**
* A Serializer that can handle complex types by delegating to JAXB.
*
@@ -63,11 +66,9 @@
Result result = null;
try
{
- // The serialization context contains the base type, which is needed for JAXB to
marshall xsi:type correctly.
- // This should be more efficient and accurate than searching the type mapping
Class expectedType = serContext.getJavaType();
- Class actualType = value.getClass();
- Class[] types = shouldFilter(actualType) ? new Class[]{expectedType} : new
Class[]{expectedType, actualType};
+ Class[] types = getClassesForContextCreation(serContext, value);
+
JAXBContext jaxbContext = getJAXBContext(types);
Marshaller marshaller = jaxbContext.createMarshaller();
@@ -91,6 +92,26 @@
}
/**
+ * Selects the array of classes to use to create the JAXBContext, as
+ * using the array of types registered for the current endpoint saves time.
+ *
+ * @param serContext
+ * @param value
+ * @return
+ */
+ private Class[] getClassesForContextCreation(SerializationContext serContext, Object
value)
+ {
+ // The serialization context contains the base type, which is needed for JAXB to
marshall xsi:type correctly.
+ // This should be more efficient and accurate than searching the type mapping
+ Class expectedType = serContext.getJavaType();
+ Class actualType = value.getClass();
+ Class[] types = shouldFilter(actualType) ? new Class[] { expectedType } : new
Class[] { expectedType, actualType };
+ Class[] registeredTypes =
(Class[])serContext.getProperty(SerializationContextJAXWS.JAXB_CONTEXT_TYPES);
+ List<Class> typesList = Arrays.asList(registeredTypes);
+ return typesList.containsAll(Arrays.asList(types)) ? registeredTypes : types;
+ }
+
+ /**
* Retrieve JAXBContext from cache or create new one and cache it.
* @param types
* @return JAXBContext
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/ObjectContent.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/ObjectContent.java 2008-09-29
06:14:54 UTC (rev 8282)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/ObjectContent.java 2008-09-29
11:01:57 UTC (rev 8283)
@@ -22,6 +22,7 @@
package org.jboss.ws.core.soap;
import java.lang.reflect.Method;
+import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.transform.Result;
@@ -36,6 +37,9 @@
import org.jboss.ws.core.binding.SerializerSupport;
import org.jboss.ws.core.binding.TypeMappingImpl;
import org.jboss.ws.core.jaxrpc.binding.NullValueSerializer;
+import org.jboss.ws.core.jaxws.SerializationContextJAXWS;
+import org.jboss.ws.metadata.umdm.OperationMetaData;
+import org.jboss.ws.metadata.umdm.ParameterMetaData;
import org.jboss.wsf.common.JavaUtils;
/**
@@ -140,6 +144,10 @@
SerializationContext serContext = msgContext.getSerializationContext();
serContext.setJavaType(javaType);
+ ParameterMetaData pmd = container.getParamMetaData();
+ OperationMetaData opMetaData = pmd.getOperationMetaData();
+ List<Class> registeredTypes =
opMetaData.getEndpointMetaData().getRegisteredTypes();
+ serContext.setProperty(SerializationContextJAXWS.JAXB_CONTEXT_TYPES,
registeredTypes.toArray(new Class[0]));
TypeMappingImpl typeMapping = serContext.getTypeMapping();
XMLFragment xmlFragment = null;
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-09-29
06:14:54 UTC (rev 8282)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-09-29
11:01:57 UTC (rev 8283)
@@ -39,6 +39,7 @@
import java.util.Set;
import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.xml.bind.JAXBContext;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import javax.xml.ws.Service.Mode;
@@ -505,6 +506,7 @@
eagerInitializeOperations();
eagerInitializeTypes();
eagerInitializeAccessors();
+ eagerInitializeJAXBContextCache();
}
private void eagerInitializeOperations()
@@ -640,6 +642,30 @@
}
}
+ private void eagerInitializeJAXBContextCache()
+ {
+ // 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]);
+ JAXBContext context = JAXBContextFactory.newInstance().createContext(classes,
bindingCustomization);
+ jaxbCache.add(classes, context);
+ }
+ catch (Exception e)
+ {
+ // ignore
+ }
+ }
+ }
+
private void createAccessor(ParameterMetaData paramMetaData, JAXBRIContext jaxbCtx)
{
AccessorFactoryCreator factoryCreator = paramMetaData.getAccessorFactoryCreator();
Show replies by date