Author: thomas.diesler(a)jboss.com
Date: 2008-02-28 08:53:13 -0500 (Thu, 28 Feb 2008)
New Revision: 5845
Added:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/InitalizableMetaData.java
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/accessor/JAXBAccessorFactoryCreator.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/FaultMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/OperationMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1857/JBWS1857TestCase.java
Log:
[JBWS-1857] JAXBContext created for every wrapper type
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/accessor/JAXBAccessorFactoryCreator.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/accessor/JAXBAccessorFactoryCreator.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/accessor/JAXBAccessorFactoryCreator.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -23,7 +23,6 @@
//$Id$
-import org.jboss.ws.core.jaxws.JAXBContextFactory;
import org.jboss.ws.metadata.umdm.FaultMetaData;
import org.jboss.ws.metadata.umdm.ParameterMetaData;
@@ -31,17 +30,24 @@
public class JAXBAccessorFactoryCreator implements AccessorFactoryCreator
{
+ private JAXBRIContext ctx;
+
+ public void setJAXBContext(JAXBRIContext ctx)
+ {
+ this.ctx = ctx;
+ }
+
public AccessorFactory create(ParameterMetaData parameter)
{
- Class clazz = parameter.getJavaType();
- JAXBRIContext ctx =
(JAXBRIContext)JAXBContextFactory.newInstance().createContext(clazz);
- return new JAXBAccessorFactory(clazz, ctx);
+ if (ctx == null)
+ throw new IllegalStateException("JAXBContext not available");
+ return new JAXBAccessorFactory(parameter.getJavaType(), ctx);
}
public AccessorFactory create(FaultMetaData fault)
{
- Class clazz = fault.getFaultBean();
- JAXBRIContext ctx =
(JAXBRIContext)JAXBContextFactory.newInstance().createContext(clazz);
- return new JAXBAccessorFactory(clazz, ctx);
+ if (ctx == null)
+ throw new IllegalStateException("JAXBContext not available");
+ return new JAXBAccessorFactory(fault.getFaultBean(), ctx);
}
}
\ No newline at end of file
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -23,8 +23,8 @@
// $Id$
+import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
-import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -34,9 +34,9 @@
import java.util.List;
import java.util.Map;
import java.util.Observable;
+import java.util.Observer;
import java.util.Properties;
import java.util.Set;
-import java.util.Observer;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.xml.namespace.QName;
@@ -54,6 +54,7 @@
import org.jboss.ws.core.jaxrpc.binding.SOAPArrayDeserializerFactory;
import org.jboss.ws.core.jaxrpc.binding.SOAPArraySerializerFactory;
import org.jboss.ws.core.jaxws.JAXBContextCache;
+import org.jboss.ws.core.jaxws.JAXBContextFactory;
import org.jboss.ws.core.jaxws.JAXBDeserializerFactory;
import org.jboss.ws.core.jaxws.JAXBSerializerFactory;
import org.jboss.ws.core.jaxws.client.DispatchBinding;
@@ -61,6 +62,9 @@
import org.jboss.ws.core.soap.Use;
import org.jboss.ws.extensions.wsrm.config.RMConfig;
import org.jboss.ws.extensions.wsrm.config.RMPortConfig;
+import org.jboss.ws.metadata.accessor.AccessorFactory;
+import org.jboss.ws.metadata.accessor.AccessorFactoryCreator;
+import org.jboss.ws.metadata.accessor.JAXBAccessorFactoryCreator;
import org.jboss.ws.metadata.config.CommonConfig;
import org.jboss.ws.metadata.config.Configurable;
import org.jboss.ws.metadata.config.ConfigurationProvider;
@@ -72,13 +76,15 @@
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedPortComponentRefMetaData;
import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData.HandlerType;
+import com.sun.xml.bind.api.JAXBRIContext;
+
/**
* A Service component describes a set of endpoints.
*
* @author Thomas.Diesler(a)jboss.org
* @since 12-May-2005
*/
-public abstract class EndpointMetaData extends ExtensibleMetaData implements
ConfigurationProvider
+public abstract class EndpointMetaData extends ExtensibleMetaData implements
ConfigurationProvider, InitalizableMetaData
{
// provide logging
private static Logger log = Logger.getLogger(EndpointMetaData.class);
@@ -524,6 +530,7 @@
eagerInitializeOperations();
eagerInitializeTypes();
+ eagerInitializeAccessors();
}
private void eagerInitializeOperations()
@@ -610,6 +617,53 @@
}
}
+ private void eagerInitializeAccessors()
+ {
+ // Collect the list of all used types
+ List<Class> types = new ArrayList<Class>();
+ for (OperationMetaData opMetaData : operations)
+ {
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ types.add(paramMetaData.getJavaType());
+ }
+
+ ParameterMetaData retParam = opMetaData.getReturnParameter();
+ if (retParam != null)
+ types.add(retParam.getJavaType());
+ }
+
+ // Create a JAXBContext for those types
+ Class[] typeArr = new Class[types.size()];
+ JAXBRIContext jaxbCtx =
(JAXBRIContext)JAXBContextFactory.newInstance().createContext(types.toArray(typeArr));
+
+ // Create the accessors using a shared JAXBContext
+ for (OperationMetaData opMetaData : operations)
+ {
+ for (ParameterMetaData paramMetaData : opMetaData.getParameters())
+ {
+ createAccessor(paramMetaData, jaxbCtx);
+ }
+
+ ParameterMetaData retParam = opMetaData.getReturnParameter();
+ if (retParam != null)
+ createAccessor(retParam, jaxbCtx);
+ }
+ }
+
+ private void createAccessor(ParameterMetaData paramMetaData, JAXBRIContext jaxbCtx)
+ {
+ AccessorFactoryCreator factoryCreator = paramMetaData.getAccessorFactoryCreator();
+ if (factoryCreator instanceof JAXBAccessorFactoryCreator)
+ {
+ ((JAXBAccessorFactoryCreator)factoryCreator).setJAXBContext(jaxbCtx);
+ AccessorFactory factory = factoryCreator.create(paramMetaData);
+ for (WrappedParameter wrapped : paramMetaData.getWrappedParameters())
+ wrapped.setAccessor(factory.create(wrapped));
+ }
+ }
+
+
// ---------------------------------------------------------------
// Configuration provider impl
Modified: stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/FaultMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/FaultMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/FaultMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -52,7 +52,7 @@
* @author jason.greene(a)jboss.com
* @since 12-May-2005
*/
-public class FaultMetaData
+public class FaultMetaData implements InitalizableMetaData
{
// provide logging
private final Logger log = Logger.getLogger(FaultMetaData.class);
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/HandlerMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -42,7 +42,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 05-May-2006
*/
-public abstract class HandlerMetaData implements Serializable
+public abstract class HandlerMetaData implements InitalizableMetaData, Serializable
{
// provide logging
private final Logger log = Logger.getLogger(HandlerMetaData.class);
Added:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/InitalizableMetaData.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/InitalizableMetaData.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/InitalizableMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ws.metadata.umdm;
+
+// $Id$
+
+
+/**
+ * Metadata that is Inizializable
+ *
+ * @author Thomas.Diesler(a)jboss.org
+ * @since 28-Feb-2008
+ */
+public interface InitalizableMetaData
+{
+ void eagerInitialize();
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/InitalizableMetaData.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/OperationMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/OperationMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/OperationMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -34,6 +34,7 @@
import javax.xml.rpc.ParameterMode;
import org.jboss.logging.Logger;
+import org.jboss.util.NotImplementedException;
import org.jboss.ws.WSException;
import org.jboss.ws.core.soap.Style;
import org.jboss.ws.core.soap.Use;
@@ -48,7 +49,7 @@
* @author <a href="mailto:jason.greene@jboss.com">Jason T.
Greene</a>
* @since 12-May-2004
*/
-public class OperationMetaData extends ExtensibleMetaData
+public class OperationMetaData extends ExtensibleMetaData implements
InitalizableMetaData
{
// provide logging
private final Logger log = Logger.getLogger(OperationMetaData.class);
@@ -446,6 +447,12 @@
fault.validate();
}
+ public void eagerInitialize()
+ {
+ // Call eagerInitialize(List<Method> unsynchronizedMethods) instead
+ throw new NotImplementedException();
+ }
+
/**
* @see UnifiedMetaData#eagerInitialize()
*/
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ParameterMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -55,7 +55,7 @@
* @author <a href="mailto:jason.greene@jboss.com">Jason T.
Greene</a>
* @since 12-May-2005
*/
-public class ParameterMetaData
+public class ParameterMetaData implements InitalizableMetaData
{
// provide logging
private final Logger log = Logger.getLogger(ParameterMetaData.class);
@@ -211,7 +211,8 @@
// Remove potential prefix
if (xmlType.getNamespaceURI().length() > 0)
this.xmlType = new QName(xmlType.getNamespaceURI(), xmlType.getLocalPart());
- else this.xmlType = xmlType;
+ else
+ this.xmlType = xmlType;
// Special case to identify attachments
if (Constants.NS_ATTACHMENT_MIME_TYPE.equals(xmlType.getNamespaceURI()))
@@ -294,7 +295,8 @@
setMode(ParameterMode.INOUT);
else if ("OUT".equals(mode))
setMode(ParameterMode.OUT);
- else throw new IllegalArgumentException("Invalid mode: " + mode);
+ else
+ throw new IllegalArgumentException("Invalid mode: " + mode);
}
public void setMode(ParameterMode mode)
@@ -381,7 +383,6 @@
this.soapArrayCompType = compXmlType;
}
-
@Deprecated
// FIXME This hack should be removed
public boolean isMessageType()
@@ -468,18 +469,13 @@
Type epType = getOperationMetaData().getEndpointMetaData().getType();
if (getOperationMetaData().isDocumentWrapped() && !isInHeader() &&
!isSwA() && !isMessageType())
{
- if (loadWrapperBean() == null)
- {
- if (epType == EndpointMetaData.Type.JAXRPC)
- throw new WSException("Autogeneration of wrapper beans not
supported with JAXRPC");
+ if (loadWrapperBean() == null)
+ {
+ if (epType == EndpointMetaData.Type.JAXRPC)
+ throw new WSException("Autogeneration of wrapper beans not supported
with JAXRPC");
- new DynamicWrapperGenerator( getClassLoader() ).generate(this);
- }
-
- // Initialize accessors
- AccessorFactory factory = accessorFactoryCreator.create(this);
- for (WrappedParameter wrapped : wrappedParameters)
- wrapped.setAccessor(factory.create(wrapped));
+ new DynamicWrapperGenerator(getClassLoader()).generate(this);
+ }
}
javaType = getJavaType();
@@ -504,8 +500,9 @@
AttachmentScanResult scanResult = scanner.scanBean(javaType);
if (scanResult != null)
{
- if(log.isDebugEnabled()) log.debug("Identified attachment reference:
" + xmlName + ", type="+scanResult.getType());
- if(scanResult.getType() == AttachmentScanResult.Type.XOP)
+ if (log.isDebugEnabled())
+ log.debug("Identified attachment reference: " + xmlName +
", type=" + scanResult.getType());
+ if (scanResult.getType() == AttachmentScanResult.Type.XOP)
setXOP(true);
else
setSwaRef(true);
@@ -546,7 +543,8 @@
}
catch (Exception ex)
{
- if(log.isDebugEnabled()) log.debug("Invalid wrapper type:" +
typeName, ex);
+ if (log.isDebugEnabled())
+ log.debug("Invalid wrapper type:" + typeName, ex);
return false;
}
}
@@ -554,6 +552,11 @@
return true;
}
+ public AccessorFactoryCreator getAccessorFactoryCreator()
+ {
+ return accessorFactoryCreator;
+ }
+
public void setAccessorFactoryCreator(AccessorFactoryCreator accessorFactoryCreator)
{
this.accessorFactoryCreator = accessorFactoryCreator;
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/ServiceMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -60,7 +60,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 12-May-2005
*/
-public class ServiceMetaData
+public class ServiceMetaData implements InitalizableMetaData
{
// provide logging
private static final Logger log = Logger.getLogger(ServiceMetaData.class);
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/main/java/org/jboss/ws/metadata/umdm/UnifiedMetaData.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -48,7 +48,7 @@
* @author <a href="mailto:jason.greene@jboss.com">Jason T.
Greene</a>
* @since 12-May-2005
*/
-public class UnifiedMetaData
+public class UnifiedMetaData implements InitalizableMetaData
{
// provide logging
private static Logger log = Logger.getLogger(UnifiedMetaData.class);
Modified:
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1857/JBWS1857TestCase.java
===================================================================
---
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1857/JBWS1857TestCase.java 2008-02-28
12:13:05 UTC (rev 5844)
+++
stack/native/trunk/src/test/java/org/jboss/test/ws/jaxws/jbws1857/JBWS1857TestCase.java 2008-02-28
13:53:13 UTC (rev 5845)
@@ -47,6 +47,11 @@
QName serviceName = new QName("http://example.com",
"StammdatenService");
Service service = Service.create(wsdlFile.toURL(), serviceName);
+
+ long start = System.currentTimeMillis();
Stammdaten port = service.getPort(Stammdaten.class);
+ long time = start - System.currentTimeMillis();
+
+ assertTrue("Creation of the port took too long", time < 20000);
}
}