[jbossws-commits] JBossWS SVN: r8447 - in stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro: metadata and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Mon Oct 13 05:35:11 EDT 2008
Author: alessio.soldano at jboss.com
Date: 2008-10-13 05:35:11 -0400 (Mon, 13 Oct 2008)
New Revision: 8447
Added:
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/Constants.java
Modified:
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserJBWS.java
stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
Log:
[JBWS-2129] Moving wrapper gen invocation to DeploymentDescriptorParserJBWS and adding property to disable wrapper gen
Added: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/Constants.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/Constants.java (rev 0)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/Constants.java 2008-10-13 09:35:11 UTC (rev 8447)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.wsf.stack.metro;
+
+/**
+ * A collection of constants relevant to JBossWS-Metro
+ *
+ * @author alessio.soldano at jboss.com
+ *
+ */
+public interface Constants
+{
+ public static final String NO_WRAPPERS_GENERATION = "org.jboss.wsf.stack.metro.noWrappersGeneration";
+}
Property changes on: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/Constants.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java 2008-10-13 08:08:44 UTC (rev 8446)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserExt.java 2008-10-13 09:35:11 UTC (rev 8447)
@@ -25,30 +25,21 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.jws.WebMethod;
-import javax.jws.WebService;
-import javax.jws.soap.SOAPBinding.ParameterStyle;
-import javax.jws.soap.SOAPBinding.Style;
-import javax.jws.soap.SOAPBinding.Use;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
-import javax.xml.ws.WebFault;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.http.HTTPBinding;
import javax.xml.ws.soap.MTOMFeature;
@@ -115,8 +106,6 @@
private final ResourceLoader loader;
private final AdapterFactory<A> adapterFactory;
- private UnifiedVirtualFile archiveFile;
-
private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(DeploymentDescriptorParserExt.class);
/**
@@ -311,15 +300,8 @@
ensureNoContent(reader);
Invoker invoker = createInvoker(implementorClass);
+ generateWrappers(implementorClass, this.classLoader);
- //Generate wrappers
- if (isWrapperGenerationRequired(implementorClass, reader, this.classLoader))
- {
- WsgenWrapperGenerator wrapperGenerator = new WsgenWrapperGenerator(System.out);
- ClassLoader newClassLoader = wrapperGenerator.generate(implementationName, classLoader, archiveFile.toURL());
- Thread.currentThread().setContextClassLoader(newClassLoader);
- }
-
WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, invoker,
serviceName, portName, container, binding, primaryWSDL, docs.values(), createEntityResolver(this.loader), false);
adapters.add(adapterFactory.createAdapter(name, urlPattern, endpoint));
@@ -331,67 +313,16 @@
return adapters;
}
- private boolean isWrapperGenerationRequired(Class<?> endpoint, XMLStreamReader reader, ClassLoader classLoader)
- {
- WebService webServiceAnnotation = endpoint.getAnnotation(WebService.class);
- if (webServiceAnnotation == null)
- return false;
- String wsdlLocation = webServiceAnnotation.wsdlLocation();
- if (wsdlLocation != null && !"".equals(wsdlLocation))
- return false; //provided wsdlLocation means a top-down (contract first) development is used, thus the user should use wsimport
-
- String endpointInterface = webServiceAnnotation.endpointInterface();
- javax.jws.soap.SOAPBinding soapBinding;
- if (endpointInterface == null || "".equalsIgnoreCase(endpointInterface))
- {
- if (isFaultWrapperGenerationRequired(endpoint))
- return true;
- soapBinding = endpoint.getAnnotation(javax.jws.soap.SOAPBinding.class);
- }
- else
- {
- //Using the SEI to get annotations
- Class<?> sei = getImplementorClass(endpointInterface, reader, classLoader);
- if (isFaultWrapperGenerationRequired(sei))
- return true;
- soapBinding = sei.getAnnotation(javax.jws.soap.SOAPBinding.class);
- }
- if (soapBinding == null)
- return true; //no @SOAPBinding means default settings, ie. doc/lit wrapped
- return !(ParameterStyle.BARE.equals(soapBinding.parameterStyle()) || Style.RPC.equals(soapBinding.style()) || Use.ENCODED.equals(soapBinding.use()));
- }
-
- private boolean isFaultWrapperGenerationRequired(Class<?> clazz)
- {
- Method[] classMethods = clazz.getMethods();
- boolean webMethodAnnUsed = false;
- List<Method> webMethods = new LinkedList<Method>();
- for (Method m : classMethods)
- {
- if (m.getAnnotation(WebMethod.class) != null)
- {
- webMethods.add(m);
- webMethodAnnUsed = true;
- }
- }
- List<Method> methods = webMethodAnnUsed ? webMethods : Arrays.asList(classMethods);
- for (Method m : methods)
- {
- Class<?>[] exceptionClasses = m.getExceptionTypes();
- for (Class<?> exceptionClass : exceptionClasses)
- {
- if (exceptionClass.getAnnotation(WebFault.class) != null)
- return true;
- }
- }
- return false;
- }
-
protected Invoker createInvoker(Class<?> implementorClass)
{
Invoker invoker = InstanceResolver.createDefault(implementorClass).createInvoker();
return invoker;
}
+
+ protected void generateWrappers(Class<?> implementorClass, ClassLoader classLoader)
+ {
+ //default implementation does nothing
+ }
/**
* @param ddBindingId
@@ -675,9 +606,4 @@
throw new LocatableWebServiceException(ServerMessages.RUNTIME_PARSER_CLASS_NOT_FOUND(name), e, reader);
}
}
-
- public void setArchiveFile(UnifiedVirtualFile file)
- {
- this.archiveFile = file;
- }
}
Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserJBWS.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserJBWS.java 2008-10-13 08:08:44 UTC (rev 8446)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/DeploymentDescriptorParserJBWS.java 2008-10-13 09:35:11 UTC (rev 8447)
@@ -21,10 +21,24 @@
*/
package org.jboss.wsf.stack.metro;
+import java.lang.reflect.Method;
import java.net.MalformedURLException;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
import javax.ejb.Stateless;
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding.ParameterStyle;
+import javax.jws.soap.SOAPBinding.Style;
+import javax.jws.soap.SOAPBinding.Use;
+import javax.xml.ws.WebFault;
+import javax.xml.ws.WebServiceException;
+import org.jboss.logging.Logger;
+import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
+
import com.sun.xml.ws.api.server.Container;
import com.sun.xml.ws.api.server.InstanceResolver;
import com.sun.xml.ws.api.server.Invoker;
@@ -35,12 +49,16 @@
* A copy of DeploymentDescriptorParser that externalizes
*
* createInvoker(Class)
+ * generateWrappers(Class, XMLStreamReader, ClassLoader)
*
* @author Thomas.Diesler at jboss.org
+ * @author alessio.soldano at jboss.org
* @since 10-May-2007
*/
public class DeploymentDescriptorParserJBWS<A> extends DeploymentDescriptorParserExt<A>
{
+ private UnifiedVirtualFile archiveFile;
+
public DeploymentDescriptorParserJBWS(ClassLoader cl, ResourceLoader loader, Container container, AdapterFactory<A> adapterFactory) throws MalformedURLException
{
super(cl, loader, container, adapterFactory);
@@ -61,5 +79,93 @@
}
return invoker;
}
-
+
+ @Override
+ protected void generateWrappers(Class<?> implementorClass, ClassLoader classLoader)
+ {
+ //Generate wrappers
+ if (isWrapperGenerationEnabled() && isWrapperGenerationRequired(implementorClass, classLoader))
+ {
+ WsgenWrapperGenerator wrapperGenerator = new WsgenWrapperGenerator(System.out);
+ ClassLoader newClassLoader = wrapperGenerator.generate(implementorClass.getName(), classLoader, archiveFile.toURL());
+ Thread.currentThread().setContextClassLoader(newClassLoader);
+ }
+ }
+
+ private boolean isWrapperGenerationEnabled()
+ {
+ boolean noWrappersGeneration = "true".equalsIgnoreCase(System.getProperty(Constants.NO_WRAPPERS_GENERATION));
+ if (noWrappersGeneration)
+ Logger.getLogger(this.getClass()).debug("Wrapper generation disabled");
+ return !noWrappersGeneration;
+ }
+
+ private boolean isWrapperGenerationRequired(Class<?> endpoint, ClassLoader classLoader)
+ {
+ WebService webServiceAnnotation = endpoint.getAnnotation(WebService.class);
+ if (webServiceAnnotation == null)
+ return false;
+ String wsdlLocation = webServiceAnnotation.wsdlLocation();
+ if (wsdlLocation != null && !"".equals(wsdlLocation))
+ return false; //provided wsdlLocation means a top-down (contract first) development is used, thus the user should use wsimport
+
+ String endpointInterface = webServiceAnnotation.endpointInterface();
+ javax.jws.soap.SOAPBinding soapBinding;
+ if (endpointInterface == null || "".equalsIgnoreCase(endpointInterface))
+ {
+ if (isFaultWrapperGenerationRequired(endpoint))
+ return true;
+ soapBinding = endpoint.getAnnotation(javax.jws.soap.SOAPBinding.class);
+ }
+ else
+ {
+ //Using the SEI to get annotations
+ Class<?> sei;
+ try
+ {
+ sei = Class.forName(endpointInterface, true, classLoader);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new WebServiceException(e);
+ }
+ if (isFaultWrapperGenerationRequired(sei))
+ return true;
+ soapBinding = sei.getAnnotation(javax.jws.soap.SOAPBinding.class);
+ }
+ if (soapBinding == null)
+ return true; //no @SOAPBinding means default settings, ie. doc/lit wrapped
+ return !(ParameterStyle.BARE.equals(soapBinding.parameterStyle()) || Style.RPC.equals(soapBinding.style()) || Use.ENCODED.equals(soapBinding.use()));
+ }
+
+ private boolean isFaultWrapperGenerationRequired(Class<?> clazz)
+ {
+ Method[] classMethods = clazz.getMethods();
+ boolean webMethodAnnUsed = false;
+ List<Method> webMethods = new LinkedList<Method>();
+ for (Method m : classMethods)
+ {
+ if (m.getAnnotation(WebMethod.class) != null)
+ {
+ webMethods.add(m);
+ webMethodAnnUsed = true;
+ }
+ }
+ List<Method> methods = webMethodAnnUsed ? webMethods : Arrays.asList(classMethods);
+ for (Method m : methods)
+ {
+ Class<?>[] exceptionClasses = m.getExceptionTypes();
+ for (Class<?> exceptionClass : exceptionClasses)
+ {
+ if (exceptionClass.getAnnotation(WebFault.class) != null)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setArchiveFile(UnifiedVirtualFile file)
+ {
+ this.archiveFile = file;
+ }
}
Modified: stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java
===================================================================
--- stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-10-13 08:08:44 UTC (rev 8446)
+++ stack/metro/trunk/modules/server/src/main/java/org/jboss/wsf/stack/metro/metadata/RuntimeModelDeploymentAspect.java 2008-10-13 09:35:11 UTC (rev 8447)
@@ -103,15 +103,12 @@
// Parse the descriptor file and build endpoint infos
DeploymentDescriptorParserExt<ServletAdapter> parser =
- createDeploymentDescriptorParser(runtimeLoader, container, resourceLoader, adapterList);
+ createDeploymentDescriptorParser(runtimeLoader, container, resourceLoader, adapterList, vfsRoot);
- parser.setArchiveFile(vfsRoot);
-
URL sunJaxWsXml = getDDUrlFromContext(deployment);
List<ServletAdapter> adapters = parser.parse(sunJaxWsXml.toExternalForm(), sunJaxWsXml.openStream());
-
for(ServletAdapter adapter : adapters)
{
for(Endpoint ep : deployment.getService().getEndpoints())
@@ -159,14 +156,14 @@
ClassLoader classLoader,
JBossWSContainer container,
ResourceLoader resourceLoader,
- DeploymentDescriptorParser.AdapterFactory<ServletAdapter> adapterList
+ DeploymentDescriptorParser.AdapterFactory<ServletAdapter> adapterList,
+ UnifiedVirtualFile vfsRoot
)
throws MalformedURLException
{
- return new DeploymentDescriptorParserJBWS<ServletAdapter>
- (
- classLoader, resourceLoader, container, adapterList
- );
+ DeploymentDescriptorParserJBWS<ServletAdapter> parser = new DeploymentDescriptorParserJBWS<ServletAdapter>(classLoader, resourceLoader, container, adapterList);
+ parser.setArchiveFile(vfsRoot);
+ return parser;
}
/**
More information about the jbossws-commits
mailing list