Author: alessio.soldano(a)jboss.com
Date: 2011-04-14 12:28:19 -0400 (Thu, 14 Apr 2011)
New Revision: 14103
Added:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/SecurityActions.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java
Removed:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java
Modified:
stack/native/trunk/
stack/native/trunk/modules/core/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBContextFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/LogicalMessageImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderEJB3.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderJSE.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EagerInitializeDeploymentAspect.java
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EndpointServlet.java
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/server/integration/main/module.xml
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/api/main/module.xml
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/native/jbossws-native-core/main/module.xml
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/spi/main/module.xml
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-interop.xml
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jaxbintros/ProviderBeanJAXB.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1909/TestEndpointImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2285/LogicalHandler.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java
Log:
[JBWS-3224][JBWS-3265] Isolate deployment classloader from ws server integration
Property changes on: stack/native/trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /stack/native/branches/ropalka:13836-13879
+ /stack/native/branches/asoldano:14057
/stack/native/branches/ropalka:13836-13879
Modified:
stack/native/trunk/modules/core/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/javax/xml/ws/addressing/AddressingBuilder.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -77,22 +77,29 @@
private static AddressingBuilder newInstance(String className, ClassLoader
classLoader)
{
+ Class cls = null;
try
{
- Class cls;
- if (classLoader == null)
+ cls = loadClass(classLoader, className);
+ }
+ catch (Exception x)
+ {
+ //ignore
+ }
+ if (cls == null)
+ {
+ try
{
cls = Class.forName(className);
}
- else
+ catch (ClassNotFoundException x)
{
- cls = loadClass(classLoader, className);
+ throw new AddressingException("Provider " + className + " not
found", x);
}
- return (AddressingBuilder)cls.newInstance();
}
- catch (ClassNotFoundException x)
+ try
{
- throw new AddressingException("Provider " + className + " not
found", x);
+ return (AddressingBuilder)cls.newInstance();
}
catch (Exception x)
{
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/client/transport/NettyTransportHandler.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -28,8 +28,6 @@
import java.security.AccessController;
import java.util.Map;
import java.util.StringTokenizer;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
import org.jboss.logging.Logger;
import org.jboss.netty.bootstrap.ClientBootstrap;
@@ -37,7 +35,6 @@
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelPipelineFactory;
-import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.jboss.ws.Constants;
@@ -90,7 +87,7 @@
keepAliveProp = true;
}
factoryProvider =
(ClientSocketChannelFactoryProvider)ServiceLoader.loadService(ClientSocketChannelFactoryProvider.class.getName(),
- DefaultClientSocketChannelFactoryProvider.class.getName());
+ DefaultClientSocketChannelFactoryProvider.class.getName(),
NettyTransportHandler.class.getClassLoader());
}
private NettyTransportHandler(URL url, ChannelPipelineFactory pipelineFactory)
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBContextFactory.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBContextFactory.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/JAXBContextFactory.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -80,6 +80,6 @@
*/
public static JAXBContextFactory newInstance()
{
- return
(JAXBContextFactory)ServiceLoader.loadService(JAXBContextFactory.class.getName(),
DEFAULT_JAXB_CONTEXT_FACTORY);
+ return
(JAXBContextFactory)ServiceLoader.loadService(JAXBContextFactory.class.getName(),
DEFAULT_JAXB_CONTEXT_FACTORY, JAXBContextFactory.class.getClassLoader());
}
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/SOAPFaultHelperJAXWS.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -27,7 +27,6 @@
import javax.xml.rpc.encoding.TypeMapping;
import javax.xml.soap.Detail;
import javax.xml.soap.DetailEntry;
-import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPConstants;
@@ -47,11 +46,11 @@
import org.jboss.ws.Constants;
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.core.CommonSOAPFaultException;
-import org.jboss.ws.core.binding.BindingException;
import org.jboss.ws.core.binding.AbstractDeserializerFactory;
+import org.jboss.ws.core.binding.AbstractSerializerFactory;
+import org.jboss.ws.core.binding.BindingException;
import org.jboss.ws.core.binding.DeserializerSupport;
import org.jboss.ws.core.binding.SerializationContext;
-import org.jboss.ws.core.binding.AbstractSerializerFactory;
import org.jboss.ws.core.binding.SerializerSupport;
import org.jboss.ws.core.jaxrpc.SOAPFaultHelperJAXRPC;
import org.jboss.ws.core.soap.MessageContextAssociation;
@@ -67,8 +66,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
-import com.ibm.wsdl.extensions.soap12.SOAP12Constants;
-
/**
* Helper methods to translate between SOAPFault and SOAPFaultException
* as well as between Exception and SOAPMessage containing a fault.
@@ -329,8 +326,7 @@
private static SOAPMessageImpl createSOAPMessage() throws SOAPException
{
- MessageFactoryImpl factory = (MessageFactoryImpl)MessageFactory.newInstance();
-
+ MessageFactoryImpl factory = new MessageFactoryImpl();
if (isSOAP12() == true)
{
factory.setEnvNamespace(Constants.NS_SOAP12_ENV);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/LogicalMessageImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/LogicalMessageImpl.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/jaxws/handler/LogicalMessageImpl.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -45,7 +45,6 @@
import org.jboss.ws.core.soap.Style;
import org.jboss.ws.core.soap.XMLFragment;
import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.spi.util.ServiceLoader;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -112,7 +111,7 @@
try
{
soapBody.removeContents();
- EnvelopeBuilder envBuilder =
(EnvelopeBuilder)ServiceLoader.loadService(EnvelopeBuilder.class.getName(),
EnvelopeBuilderDOM.class.getName());
+ EnvelopeBuilder envBuilder = new EnvelopeBuilderDOM();
envBuilder.setStyle(style);
Element domBodyElement = DOMUtils.sourceToElement(source);
envBuilder.buildBodyElementRpc(soapBody, domBodyElement);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/server/WSDLRequestHandler.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -142,9 +142,7 @@
log.debug("Importing resource file: " +
impResourceFile.getCanonicalPath());
String wsdlLocFilePath = wsdlLocFile.getParentFile().getCanonicalPath();
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- ServerConfig serverConfig =
spiProvider.getSPI(ServerConfigFactory.class).getServerConfig();
- String wsdlDataLoc = serverConfig.getServerDataDir().getCanonicalPath() +
File.separatorChar + "wsdl";
+ String wsdlDataLoc = config.getServerDataDir().getCanonicalPath() +
File.separatorChar + "wsdl";
//allow wsdl file's parent or server's data/wsdl or overriden wsdl
publish directories only
String resourceAbsPath = impResourceFile.getCanonicalPath();
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/MessageFactoryImpl.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -288,7 +288,8 @@
}
else
{
- envBuilder =
(EnvelopeBuilder)ServiceLoader.loadService(EnvelopeBuilder.class.getName(), null);
+ //the classloader for jbossws-native-core has enough visibility to get the
proper envelope builder
+ envBuilder =
(EnvelopeBuilder)ServiceLoader.loadService(EnvelopeBuilder.class.getName(), null,
this.getClass().getClassLoader());
}
//if inputstream is empty, no need to build
if (inputStream.markSupported()) {
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPElementImpl.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -280,7 +280,7 @@
{
Document oldDoc = DOMUtils.peekOwnerDocument();
DOMUtils.setOwnerDocument(element.getOwnerDocument());
- soapElement = (SOAPElementImpl)
SOAPFactoryImpl.newInstance().createElement((Element) (soapElement.domNode));
+ soapElement = (SOAPElementImpl) new SOAPFactoryImpl().createElement((Element)
(soapElement.domNode));
DOMUtils.setOwnerDocument(oldDoc);
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/addressing/soap/SOAPAddressingPropertiesImpl.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -32,7 +32,6 @@
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPFactory;
import javax.xml.soap.SOAPFault;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
@@ -248,9 +247,9 @@
public void writeHeaders(SOAPMessage message) throws AddressingException
{
- try
- {
- SOAPFactoryImpl factory = (SOAPFactoryImpl)SOAPFactory.newInstance();
+ try
+ {
+ SOAPFactoryImpl factory = new SOAPFactoryImpl();
SOAPHeader soapHeader = message.getSOAPHeader();
if (soapHeader == null)
@@ -401,7 +400,7 @@
SOAPElement child = null;
try
{
- SOAPFactoryImpl factory = (SOAPFactoryImpl)SOAPFactory.newInstance();
+ SOAPFactoryImpl factory = new SOAPFactoryImpl();
if (obj instanceof Element)
{
child = factory.createElement((Element)obj);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderEJB3.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderEJB3.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderEJB3.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -28,6 +28,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.utils.DelegateClassLoader;
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -63,7 +64,7 @@
ClassLoader runtimeClassLoader = dep.getRuntimeClassLoader();
if(null == runtimeClassLoader)
throw new IllegalArgumentException("Runtime loader cannot be
null");
- wsMetaData.setClassLoader(runtimeClassLoader);
+ wsMetaData.setClassLoader(new DelegateClassLoader(runtimeClassLoader,
SecurityActions.getContextClassLoader()));
// The container objects below provide access to all of the ejb metadata
EJBArchiveMetaData apMetaData = dep.getAttachment(EJBArchiveMetaData.class);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderJSE.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderJSE.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/JAXWSMetaDataBuilderJSE.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -23,6 +23,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
+import org.jboss.ws.core.utils.DelegateClassLoader;
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
import org.jboss.wsf.spi.deployment.ArchiveDeployment;
import org.jboss.wsf.spi.deployment.Endpoint;
@@ -52,7 +53,7 @@
ClassLoader runtimeClassLoader = dep.getRuntimeClassLoader();
if(null == runtimeClassLoader)
throw new IllegalArgumentException("Runtime classloader cannot be
null");
- wsMetaData.setClassLoader(runtimeClassLoader);
+ wsMetaData.setClassLoader(new DelegateClassLoader(runtimeClassLoader,
SecurityActions.getContextClassLoader()));
// For every bean
for (Endpoint ep : dep.getService().getEndpoints())
Copied:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/SecurityActions.java
(from rev 14057,
stack/native/branches/asoldano/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/SecurityActions.java)
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/SecurityActions.java
(rev 0)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/builder/jaxws/SecurityActions.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -0,0 +1,131 @@
+/*
+ * 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.ws.metadata.builder.jaxws;
+
+import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
+/**
+ * Security actions for this package
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 19-Jun-2009
+ *
+ */
+class SecurityActions
+{
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ static ClassLoader setContextClassLoader(final ClassLoader cl)
+ {
+ if (System.getSecurityManager() == null)
+ {
+ ClassLoader result = Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ else
+ {
+ try
+ {
+ return AccessController.doPrivileged(new
PrivilegedExceptionAction<ClassLoader>() {
+ public ClassLoader run() throws Exception
+ {
+ try
+ {
+ ClassLoader result =
Thread.currentThread().getContextClassLoader();
+ if (cl != null)
+ Thread.currentThread().setContextClassLoader(cl);
+ return result;
+ }
+ catch (Exception e)
+ {
+ throw e;
+ }
+ catch (Error e)
+ {
+ throw e;
+ }
+ catch (Throwable e)
+ {
+ throw new RuntimeException("Error setting context
classloader", e);
+ }
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw new RuntimeException("Error running privileged action",
e.getCause());
+ }
+ }
+ }
+
+ static URL getResource(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResource(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<URL>() {
+ public URL run()
+ {
+ return cl.getResource(filename);
+ }
+ });
+ }
+ }
+}
\ No newline at end of file
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/config/JBossWSConfigFactory.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -24,6 +24,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.jboss.logging.Logger;
import org.jboss.ws.WSException;
@@ -53,19 +55,27 @@
private static String URN_JAXRPC_CONFIG = "urn:jboss:jaxrpc-config:2.0";
private static String URN_JAXWS_CONFIG = "urn:jboss:jaxws-config:2.0";
+
+ private ClassLoader loader;
// Hide constructor
- private JBossWSConfigFactory()
+ private JBossWSConfigFactory(ClassLoader loader)
{
+ this.loader = loader;
}
/** Create a new instance of the factory
*/
public static JBossWSConfigFactory newInstance()
{
- return new JBossWSConfigFactory();
+ return new JBossWSConfigFactory(getContextClassLoader());
}
+ public static JBossWSConfigFactory newInstance(ClassLoader loader)
+ {
+ return new JBossWSConfigFactory(loader);
+ }
+
public Object parse(URL configURL)
{
if(log.isDebugEnabled()) log.debug("parse: " + configURL);
@@ -184,7 +194,7 @@
{
try
{
- configURL = new ResourceLoaderAdapter().findChild(configFile).toURL();
+ configURL = new ResourceLoaderAdapter(loader).findChild(configFile).toURL();
}
catch (IOException ex)
{
@@ -197,4 +207,27 @@
return configURL;
}
+
+ /**
+ * Get context classloader.
+ *
+ * @return the current context classloader
+ */
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
{
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/metadata/umdm/EndpointMetaData.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -914,7 +914,7 @@
if (log.isDebugEnabled())
log.debug("Create new config [name=" + configName + ",file="
+ configFile + "]");
- JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance();
+ JBossWSConfigFactory factory = JBossWSConfigFactory.newInstance(getClassLoader());
List<RMPortConfig> rmPortMetaData = null;
if (base != null)
{
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EagerInitializeDeploymentAspect.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EagerInitializeDeploymentAspect.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EagerInitializeDeploymentAspect.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -21,6 +21,7 @@
*/
package org.jboss.wsf.stack.jbws;
+import org.jboss.ws.core.utils.DelegateClassLoader;
import org.jboss.ws.metadata.umdm.UnifiedMetaData;
import org.jboss.wsf.common.integration.AbstractDeploymentAspect;
import org.jboss.wsf.spi.deployment.Deployment;
@@ -44,7 +45,7 @@
if(null == runtimeClassLoader)
throw new IllegalArgumentException("Runtime classloader may not be
null");
- umd.setClassLoader(runtimeClassLoader);
+ umd.setClassLoader(new DelegateClassLoader(runtimeClassLoader,
SecurityActions.getContextClassLoader()));
umd.eagerInitialize();
}
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EndpointServlet.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EndpointServlet.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/wsf/stack/jbws/EndpointServlet.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -21,17 +21,23 @@
*/
package org.jboss.wsf.stack.jbws;
+import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import org.jboss.logging.Logger;
import org.jboss.wsf.spi.deployment.Endpoint;
+import org.jboss.wsf.spi.deployment.ServletDelegate;
import org.jboss.wsf.spi.management.EndpointResolver;
import org.jboss.wsf.common.injection.InjectionHelper;
import org.jboss.wsf.common.injection.PreDestroyHolder;
import org.jboss.wsf.common.servlet.AbstractEndpointServlet;
import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* A Native endpoint servlet that is installed for every web service endpoint
@@ -39,7 +45,7 @@
* @author heiko.braun(a)jboss.com
* @author richard.opalka(a)jboss.com
*/
-public final class EndpointServlet extends AbstractEndpointServlet
+public final class EndpointServlet extends AbstractEndpointServlet implements
ServletDelegate
{
// provide logging
@@ -114,4 +120,46 @@
}
}
+ @Override
+ public void doHead(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.doHead(request, response);
+ }
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.doGet(request, response);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.doPost(request, response);
+ }
+
+ @Override
+ public void doPut(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.doPut(request, response);
+ }
+
+ @Override
+ public void doDelete(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.doDelete(request, response);
+ }
+
+ @Override
+ public void service(HttpServletRequest request, HttpServletResponse response,
ServletContext context)
+ throws ServletException, IOException
+ {
+ this.service(request, response);
+ }
+
}
Modified:
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/server/integration/main/module.xml
===================================================================
---
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/server/integration/main/module.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/as/webservices/server/integration/main/module.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -33,8 +33,17 @@
<module name="org.jboss.ws.api" export="true"/>
<module name="org.jboss.ws.spi" export="true"/>
<module name="org.jboss.ws.common" export="true"/>
+ <module name="org.jboss.ws.jaxws-client" services="export"
export="true"/>
<module name="org.jboss.ws.native.jbossws-native-factories"
services="export" export="true"/>
- <module name="org.jboss.ws.native.jbossws-native-core"
services="export" export="true"/>
+ <module name="org.jboss.ws.native.jbossws-native-core"
services="export" export="true">
+ <imports>
+ <include path="META-INF"/>
+ </imports>
+ <exports>
+ <include path="META-INF"/>
+ </exports>
+ </module>
+ <module name="org.jboss.ws.native.jbossws-native-services"
services="export" export="true"/>
<module name="org.apache.xalan" services="export"
export="true"/>
<module name="org.apache.xerces" services="export"
export="true"/>
<module name="org.jboss.as.webservices" services="export"
export="true"/>
Modified:
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/api/main/module.xml
===================================================================
---
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/api/main/module.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/api/main/module.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -30,6 +30,9 @@
<dependencies>
<module name="javax.api"/>
+ <module name="com.sun.xml.messaging.saaj"
services="export" export="true"/>
+ <module name="javax.xml.ws.api"/>
<module name="org.jboss.logging"/>
+ <module name="org.jboss.modules"/>
</dependencies>
</module>
Modified:
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/native/jbossws-native-core/main/module.xml
===================================================================
---
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/native/jbossws-native-core/main/module.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/native/jbossws-native-core/main/module.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -51,7 +51,7 @@
<module name="org.jboss.ws.api" />
<module name="org.jboss.ws.spi" />
<module name="org.jboss.ws.common" />
- <module name="org.jboss.ws.jaxws-client" />
+ <module name="org.jboss.ws.jaxws-client"
services="import"/>
<module name="org.jboss.ws.native.jbossws-native-factories"
services="import"/>
<module name="org.jboss.ws.native.jbossws-native-services"
services="import"/>
<module name="org.jboss.common-core" />
Modified:
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/spi/main/module.xml
===================================================================
---
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/spi/main/module.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/resources/src/main/resources/modules/org/jboss/ws/spi/main/module.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -30,6 +30,7 @@
<dependencies>
<module name="javax.api"/>
+ <module name="javax.servlet.api"/>
<module name="javax.xml.stream.api"/>
<module name="javax.xml.ws.api"/>
<module name="org.jboss.logging"/>
Modified:
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-interop.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-interop.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-interop.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -115,6 +115,9 @@
<fileset dir="${tests.output.dir}/test-resources/interop/wsse/">
<include name="*.*"/>
</fileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jbossws-interop-wsse10Encrypt-client.jar -->
<jar
destfile="${tests.output.dir}/test-libs/jbossws-interop-wsse10Encrypt-client.jar">
@@ -141,6 +144,9 @@
<fileset dir="${tests.output.dir}/test-resources/interop/wsse/">
<include name="*.*"/>
</fileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jbossws-interop-wsse10Sign-client.jar -->
<jar
destfile="${tests.output.dir}/test-libs/jbossws-interop-wsse10Sign-client.jar">
@@ -193,6 +199,9 @@
<fileset
dir="${tests.output.dir}/test-resources/interop/nov2007/wsse/">
<include name="*.*"/>
</fileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jbossws-interop-nov2007-wsseEncrypt.jar -->
<jar
destfile="${tests.output.dir}/test-libs/jbossws-interop-nov2007-wsseEncrypt-client.jar">
@@ -222,6 +231,9 @@
<fileset
dir="${tests.output.dir}/test-resources/interop/nov2007/wsse/">
<include name="*.*"/>
</fileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jbossws-interop-nov2007-wsseEncrypt3DES.jar -->
<jar
destfile="${tests.output.dir}/test-libs/jbossws-interop-nov2007-wsseEncrypt3DES-client.jar">
@@ -245,6 +257,9 @@
<fileset
dir="${tests.output.dir}/test-resources/interop/nov2007/wsse/">
<include name="*.*"/>
</fileset>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jbossws-interop-nov2007-wsseUsernameTokenHTTPS-client.jar -->
<jar
destfile="${tests.output.dir}/test-libs/jbossws-interop-nov2007-wsseUsernameTokenHTTPS-client.jar">
Modified: stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/scripts/build-jars-jaxws.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -86,6 +86,9 @@
<classes dir="${tests.output.dir}/test-classes">
<include
name="org/jboss/test/ws/jaxws/fastinfoset/FastInfosetEndpoint.class" />
</classes>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-handlerlifecycle -->
@@ -122,12 +125,16 @@
<war warfile="${tests.output.dir}/test-libs/jaxws-jaxbintros.war"
webxml="${tests.output.dir}/test-resources/jaxws/jaxbintros/WEB-INF/web.xml">
<classes dir="${tests.output.dir}/test-classes">
<include name="org/jboss/test/ws/jaxws/jaxbintros/**/*.class" />
+ <include name="org/jboss/test/helper/DOMWriter.class" />
</classes>
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jaxbintros/WEB-INF">
<include name="*.xml" />
<include name="**/*.wsdl" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws771 -->
@@ -144,6 +151,9 @@
<include name="org/jboss/test/ws/jaxws/jbws871/RpcArrayEndpoint.class"
/>
<include
name="org/jboss/test/ws/jaxws/jbws871/RpcArrayEndpointImpl.class" />
</classes>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<jar
destfile="${tests.output.dir}/test-libs/jaxws-jbws871-rpc-client.jar">
<fileset dir="${tests.output.dir}/test-classes">
@@ -210,6 +220,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws1814/WEB-INF">
<include name="*" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws1850 -->
@@ -303,6 +316,9 @@
<metainf dir="${tests.output.dir}/test-resources/jaxws/jbws2014/">
<include name="wsse.*" />
</metainf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</jar>
<jar
destfile="${tests.output.dir}/test-libs/jaxws-jbws2014-encrypt.jar">
<fileset dir="${tests.output.dir}/test-classes">
@@ -315,6 +331,9 @@
<metainf dir="${tests.output.dir}/test-resources/jaxws/jbws2014/">
<include name="wsse.*" />
</metainf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</jar>
<!-- jaxws-jbws2116-->
@@ -433,6 +452,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2259/WEB-INF">
<include name="jaxws-endpoint-config.xml" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2285 -->
@@ -441,10 +463,14 @@
<include name="org/jboss/test/ws/jaxws/jbws2285/*.class" />
<exclude name="org/jboss/test/ws/jaxws/jbws2285/JBWS2285TestCase.class"
/>
<include name="org/jboss/test/ws/jaxws/jbws2285/server-handlers.xml"
/>
+ <include name="org/jboss/test/helper/DOMWriter.class" />
</classes>
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2285/WEB-INF">
<include name="jboss-web.xml" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2319 -->
@@ -453,10 +479,14 @@
<include name="org/jboss/test/ws/jaxws/jbws2319/*.class" />
<exclude name="org/jboss/test/ws/jaxws/jbws2319/JBWS2285TestCase.class"
/>
<include name="org/jboss/test/ws/jaxws/jbws2319/server-handlers.xml"
/>
+ <include name="org/jboss/test/helper/DOMWriter.class" />
</classes>
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2319/WEB-INF">
<include name="jboss-web.xml" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2437 -->
@@ -477,6 +507,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2526/WEB-INF">
<include name="wsdl/**" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2565 -->
@@ -524,6 +557,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2698/WEB-INF">
<include name="jboss-web.xml" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2706 -->
@@ -581,6 +617,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/jbws2949/WEB-INF">
<include name="jboss-web.xml" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-jbws2969 -->
@@ -870,6 +909,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/wseventing/WEB-INF">
<include name="wsdl/**" />
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-wsrm -->
@@ -885,6 +927,9 @@
</webinf>
<zipfileset
dir="${tests.output.dir}/test-resources/jaxws/wsrm/WEB-INF/unsecure/wsdl"
prefix="WEB-INF/wsdl" />
<zipfileset
file="${tests.output.dir}/test-resources/jaxws/wsrm/WEB-INF/unsecure/standard-jaxws-endpoint-config.xml"
prefix="META-INF" />
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<war warfile="${tests.output.dir}/test-libs/jaxws-secured-wsrm.war"
webxml="${tests.output.dir}/test-resources/jaxws/wsrm/WEB-INF/secure/web.xml">
@@ -906,6 +951,9 @@
</webinf>
<zipfileset
dir="${tests.output.dir}/test-resources/jaxws/wsrm/WEB-INF/secure/wsdl"
prefix="WEB-INF/wsdl" />
<zipfileset
file="${tests.output.dir}/test-resources/jaxws/wsrm/WEB-INF/secure/standard-jaxws-endpoint-config.xml"
prefix="META-INF" />
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<jar jarfile="${tests.output.dir}/test-libs/jaxws-wsrm-client.jar">
Modified:
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/scripts/build-samples-jaxws.xml 2011-04-14
16:28:19 UTC (rev 14103)
@@ -280,6 +280,9 @@
<include name="wsdl/ws-eventing.xsd"/>
<include name="wsdl/ws-addr.xsd"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<jar
destfile="${tests.output.dir}/test-libs/jaxws-samples-wseventing-sink.jar">
<fileset dir="${tests.output.dir}/test-classes">
@@ -295,6 +298,9 @@
</classes>
<zipfileset
dir="${tests.output.dir}/test-resources/jaxws/samples/wsrm/WEB-INF/wsdl"
prefix="WEB-INF/wsdl"/>
<zipfileset
file="${tests.output.dir}/test-resources/jaxws/samples/wsrm/WEB-INF/wsrm-jaxws-endpoint-config.xml"
prefix="META-INF"/>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<jar
jarfile="${tests.output.dir}/test-libs/jaxws-samples-wsrm-client.jar">
@@ -321,6 +327,9 @@
<include name="wsse.keystore"/>
<include name="wsse.truststore"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecurity-sign -->
@@ -340,6 +349,9 @@
<include name="wsse.keystore"/>
<include name="wsse.truststore"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecurity-sign-fault -->
@@ -359,6 +371,9 @@
<include name="wsse.keystore"/>
<include name="wsse.truststore"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecurity-sign-encrypt-fault -->
@@ -378,6 +393,9 @@
<include name="wsse.keystore"/>
<include name="wsse.truststore"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecurity-username -->
@@ -391,6 +409,9 @@
<include name="jboss-web.xml"/>
<include name="jboss-wsse-server.xml"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecurityAnnotatedpolicy-encrypt -->
@@ -409,6 +430,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wssecurityAnnotatedpolicy/WEB-INF">
<include name="Policy.xml"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- jaxws-samples-wssecuritypolicy-encrypt -->
@@ -427,6 +451,9 @@
<webinf
dir="${tests.output.dir}/test-resources/jaxws/samples/wssecuritypolicy/WEB-INF">
<include name="wsdl/**"/>
</webinf>
+ <manifest>
+ <attribute name="Dependencies"
value="org.jboss.ws.native.jbossws-native-core"/>
+ </manifest>
</war>
<!-- Please add alphabetically -->
Deleted:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java
===================================================================
---
stack/native/branches/asoldano/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java 2011-04-11
22:38:29 UTC (rev 14057)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -1,671 +0,0 @@
-/*
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (
http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache(a)apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <
http://www.apache.org/>.
- */
-package org.jboss.test.helper;
-
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * Traverse a DOM tree in order to print a document that is parsed.
- *
- * @author Andy Clark, IBM
- * @author Thomas.Diesler(a)jboss.org
- * @author <a href="mailto:mvecera@redhat.com">Martin Vecera</a>
- * @author <a href="mailto:alessio.soldano@jboss.com">Alessio
Soldano</a>
- */
-@SuppressWarnings("unchecked")
-public class DOMWriter
-{
- private static final Pattern PATTERN =
Pattern.compile("[&<>'\"\r\n]");
- // Print writer
- private PrintWriter out;
- // True, if canonical output
- private boolean canonical;
- // True, if pretty printing should be used
- private boolean prettyprint;
- // True, if the XML declaration should be written
- private boolean writeXMLDeclaration;
- // True, if whitespace should be ignored
- private boolean ignoreWhitespace;
- // Explicit character set encoding
- private String charsetName;
- // indent for the pretty printer
- private int prettyIndent;
- // True, if the XML declaration has been written
- private boolean wroteXMLDeclaration;
- // The node that started the write
- private Node rootNode;
- // True if we want namespace completion
- private boolean completeNamespaces = true;
- // The current default namespace
- private String currentDefaultNamespace;
-
- public DOMWriter(Writer w)
- {
- this.out = new PrintWriter(w);
- }
-
- public DOMWriter(Writer w, String charsetName)
- {
- this.out = new PrintWriter(w);
- this.charsetName = charsetName;
- this.writeXMLDeclaration = true;
- }
-
- public DOMWriter(OutputStream stream)
- {
- try
- {
- this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
- }
- catch (UnsupportedEncodingException e)
- {
- // ignore, UTF-8 should be available
- }
- }
-
- public DOMWriter(OutputStream stream, String charsetName)
- {
- try
- {
- this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
- this.charsetName = charsetName;
- this.writeXMLDeclaration = true;
- }
- catch (UnsupportedEncodingException e)
- {
- throw new IllegalArgumentException("Unsupported encoding: " +
charsetName);
- }
- }
-
- /**
- * Print a node with explicit prettyprinting.
- * The defaults for all other DOMWriter properties apply.
- *
- */
- public static String printNode(Node node, boolean prettyprint)
- {
- StringWriter strw = new StringWriter();
- new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
- return strw.toString();
- }
-
- public boolean isCanonical()
- {
- return canonical;
- }
-
- /**
- * Set wheter entities should appear in their canonical form.
- * The default is false.
- */
- public DOMWriter setCanonical(boolean canonical)
- {
- this.canonical = canonical;
- return this;
- }
-
- public boolean isIgnoreWhitespace()
- {
- return ignoreWhitespace;
- }
-
- /**
- * Set whether whitespace should be ignored.
- * The default is false.
- */
- public DOMWriter setIgnoreWhitespace(boolean ignoreWhitespace)
- {
- this.ignoreWhitespace = ignoreWhitespace;
- return this;
- }
-
- /**
- * Set wheter subelements should have their namespaces completed.
- * Setting this to false may lead to invalid XML fragments.
- * The default is true.
- */
- public DOMWriter setCompleteNamespaces(boolean complete)
- {
- this.completeNamespaces = complete;
- return this;
- }
-
- public boolean isPrettyprint()
- {
- return prettyprint;
- }
-
- /**
- * Set wheter element should be indented.
- * The default is false.
- */
- public DOMWriter setPrettyprint(boolean prettyprint)
- {
- this.prettyprint = prettyprint;
- return this;
- }
-
- public boolean isWriteXMLDeclaration()
- {
- return writeXMLDeclaration;
- }
-
- /**
- * Set wheter the XML declaration should be written.
- * The default is false.
- */
- public DOMWriter setWriteXMLDeclaration(boolean flag)
- {
- this.writeXMLDeclaration = flag;
- return this;
- }
-
- public void print(Node node)
- {
- if (prettyprint && ignoreWhitespace)
- throw new IllegalStateException("Cannot pretty print and ignore
whitespace");
-
- rootNode = node;
- printInternal(node, false);
- }
-
- private void printInternal(Node node, boolean indentEndMarker)
- {
- // is there anything to do?
- if (node == null)
- {
- return;
- }
-
- // JBAS-2117 - Don't skip the DOCUMENT_NODE
- // if (node instanceof Document) node = ((Document)node).getDocumentElement();
-
- if (wroteXMLDeclaration == false && writeXMLDeclaration == true &&
canonical == false)
- {
- out.print("<?xml version='1.0'");
- if (charsetName != null)
- out.print(" encoding='" + charsetName + "'");
-
- out.print("?>");
- if (prettyprint)
- out.println();
-
- wroteXMLDeclaration = true;
- }
-
- int type = node.getNodeType();
- boolean hasChildNodes = node.getChildNodes().getLength() > 0;
-
- String nodeName = node.getNodeName();
- switch (type)
- {
- // print document
- case Node.DOCUMENT_NODE:
- {
- NodeList children = node.getChildNodes();
- int len = children.getLength();
- for (int iChild = 0; iChild < len; iChild++)
- {
- printInternal(children.item(iChild), false);
- }
- out.flush();
- break;
- }
-
- // print element with attributes
- case Node.ELEMENT_NODE:
- {
- Element element = (Element)node;
- if (prettyprint)
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
- prettyIndent++;
- }
-
- out.print('<');
- out.print(nodeName);
-
- Map nsMap = new HashMap();
- String elPrefix = node.getPrefix();
- String elNamespaceURI = node.getNamespaceURI();
- if (elPrefix != null)
- {
- String nsURI = getNamespaceURI(elPrefix, element, rootNode);
- nsMap.put(elPrefix, nsURI);
- }
-
- Attr attrs[] = sortAttributes(node.getAttributes());
- for (int i = 0; i < attrs.length; i++)
- {
- Attr attr = attrs[i];
- String atPrefix = attr.getPrefix();
- String atName = attr.getNodeName();
- String atValue = normalize(attr.getNodeValue(), canonical);
-
- if (atName.equals("xmlns"))
- currentDefaultNamespace = atValue;
-
- if (atPrefix != null && !atPrefix.equals("xmlns")
&& !atPrefix.equals("xml"))
- {
- String nsURI = getNamespaceURI(atPrefix, element, rootNode);
- nsMap.put(atPrefix, nsURI);
- // xsi:type='ns1:SubType', xsi:type='xsd:string'
- if (atName.equals(atPrefix + ":type") &&
atValue.indexOf(":") > 0)
- {
- // xsi defined on the envelope
- if (nsURI == null)
- nsURI = getNamespaceURI(atPrefix, element, null);
-
- if
("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
- {
- String typePrefix = atValue.substring(0,
atValue.indexOf(":"));
- String typeURI = getNamespaceURI(typePrefix, element, rootNode);
- nsMap.put(typePrefix, typeURI);
- }
- }
- }
-
- out.print(" " + atName + "='" + atValue +
"'");
- }
-
- // Add namespace declaration for prefixes
- // that are defined further up the tree
- if (completeNamespaces)
- {
- Iterator itPrefix = nsMap.keySet().iterator();
- while (itPrefix.hasNext())
- {
- String prefix = (String)itPrefix.next();
- String nsURI = (String)nsMap.get(prefix);
- if (nsURI == null)
- {
- nsURI = getNamespaceURI(prefix, element, null);
- out.print(" xmlns:" + prefix + "='" + nsURI
+ "'");
- }
- }
- }
-
- // The SAX ContentHandler will by default not add the namespace declaration
- // <Hello xmlns='http://somens'>World</Hello>
- if (elPrefix == null && elNamespaceURI != null)
- {
- String defaultNamespace = element.getAttribute("xmlns");
- if (defaultNamespace.length() == 0 &&
!elNamespaceURI.equals(currentDefaultNamespace))
- {
- out.print(" xmlns='" + elNamespaceURI +
"'");
- currentDefaultNamespace = elNamespaceURI;
- }
- }
-
- if (hasChildNodes)
- {
- out.print('>');
- }
-
- // Find out if the end marker is indented
- indentEndMarker = isEndMarkerIndented(node);
-
- if (indentEndMarker)
- {
- out.print('\n');
- }
-
- NodeList childNodes = node.getChildNodes();
- int len = childNodes.getLength();
- for (int i = 0; i < len; i++)
- {
- Node childNode = childNodes.item(i);
- printInternal(childNode, false);
- }
- break;
- }
-
- // handle entity reference nodes
- case Node.ENTITY_REFERENCE_NODE:
- {
- if (canonical)
- {
- NodeList children = node.getChildNodes();
- if (children != null)
- {
- int len = children.getLength();
- for (int i = 0; i < len; i++)
- {
- printInternal(children.item(i), false);
- }
- }
- }
- else
- {
- out.print('&');
- out.print(nodeName);
- out.print(';');
- }
- break;
- }
-
- // print cdata sections
- case Node.CDATA_SECTION_NODE:
- {
- if (canonical)
- {
- out.print(normalize(node.getNodeValue(), canonical));
- }
- else
- {
- out.print("<![CDATA[");
- out.print(node.getNodeValue());
- out.print("]]>");
- }
- break;
- }
-
- // print text
- case Node.TEXT_NODE:
- {
- String text = normalize(node.getNodeValue(), canonical);
- if (text.trim().length() > 0)
- {
- out.print(text);
- }
- else if (prettyprint == false && ignoreWhitespace == false)
- {
- out.print(text);
- }
- break;
- }
-
- // print processing instruction
- case Node.PROCESSING_INSTRUCTION_NODE:
- {
- out.print("<?");
- out.print(nodeName);
- String data = node.getNodeValue();
- if (data != null && data.length() > 0)
- {
- out.print(' ');
- out.print(data);
- }
- out.print("?>");
- break;
- }
-
- // print comment
- case Node.COMMENT_NODE:
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
-
- out.print("<!--");
- String data = node.getNodeValue();
- if (data != null)
- {
- out.print(data);
- }
- out.print("-->");
-
- if (prettyprint)
- {
- out.print('\n');
- }
-
- break;
- }
- }
-
- if (type == Node.ELEMENT_NODE)
- {
- if (prettyprint)
- prettyIndent--;
-
- if (hasChildNodes == false)
- {
- out.print("/>");
- }
- else
- {
- if (indentEndMarker)
- {
- for (int i = 0; i < prettyIndent; i++)
- {
- out.print(' ');
- }
- }
-
- out.print("</");
- out.print(nodeName);
- out.print('>');
- }
-
- if (prettyIndent > 0)
- {
- out.print('\n');
- }
- }
- out.flush();
- }
-
- private String getNamespaceURI(String prefix, Element element, Node stopNode)
- {
- Node parent = element.getParentNode();
- String nsURI = element.getAttribute("xmlns:" + prefix);
- if (nsURI.length() == 0 && element != stopNode && parent instanceof
Element)
- return getNamespaceURI(prefix, (Element)parent, stopNode);
-
- return (nsURI.length() > 0 ? nsURI : null);
- }
-
- private boolean isEndMarkerIndented(Node node)
- {
- if (prettyprint)
- {
- NodeList childNodes = node.getChildNodes();
- int len = childNodes.getLength();
- for (int i = 0; i < len; i++)
- {
- Node children = childNodes.item(i);
- if (children.getNodeType() == Node.ELEMENT_NODE)
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /** Returns a sorted list of attributes. */
- private Attr[] sortAttributes(NamedNodeMap attrs)
- {
-
- int len = (attrs != null) ? attrs.getLength() : 0;
- Attr array[] = new Attr[len];
- for (int i = 0; i < len; i++)
- {
- array[i] = (Attr)attrs.item(i);
- }
- for (int i = 0; i < len - 1; i++)
- {
- String name = array[i].getNodeName();
- int index = i;
- for (int j = i + 1; j < len; j++)
- {
- String curName = array[j].getNodeName();
- if (curName.compareTo(name) < 0)
- {
- name = curName;
- index = j;
- }
- }
- if (index != i)
- {
- Attr temp = array[i];
- array[i] = array[index];
- array[index] = temp;
- }
- }
- return (array);
- }
-
- /** Normalizes the given string. */
- public static String normalize(String strValue, boolean canonical)
- {
- Matcher m = PATTERN.matcher(strValue);
- if (m.find())
- {
- int pos = m.start(); // we can use previous match to skip some part at the
string beginning
- int len = strValue.length(); // just a single call to length()
- char[] input = new char[len]; // this is to ommit calls to String.charAt()
- strValue.getChars(0, len, input, 0);
- StringBuilder sb = new StringBuilder(len * 3); // faster than StringBuffer, not
thread safe
-
- int copyStart = 0;
-
- for (int i = pos; i < len; i++)
- {
- char ch = input[i];
- switch (ch)
- {
- case '<' :
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append("<");
- break;
- case '>' :
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append(">");
- break;
- case '"' :
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append(""");
- break;
- case '\'' :
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append("'");
- break;
- case '&' :
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append("&");
- break;
- case '\r' :
- case '\n' :
- if (canonical)
- {
- if (copyStart < i)
- {
- sb.append(input, copyStart, i - copyStart);
- }
- copyStart = i + 1;
- sb.append("&#");
- sb.append(Integer.toString(ch));
- sb.append(';');
- break;
- }
-
- }
- }
- if (copyStart < len)
- {
- sb.append(input, copyStart, len - copyStart);
- }
-
- return sb.toString();
- }
- else
- {
- return strValue;
- }
- }
-}
Copied:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java
(from rev 14057,
stack/native/branches/asoldano/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java)
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/helper/DOMWriter.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -0,0 +1,671 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowlegement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (
http://www.apache.org/)."
+ * Alternately, this acknowlegement may appear in the software itself,
+ * if and wherever such third-party acknowlegements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Tomcat", and "Apache
Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Group.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <
http://www.apache.org/>.
+ */
+package org.jboss.test.helper;
+
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Traverse a DOM tree in order to print a document that is parsed.
+ *
+ * @author Andy Clark, IBM
+ * @author Thomas.Diesler(a)jboss.org
+ * @author <a href="mailto:mvecera@redhat.com">Martin Vecera</a>
+ * @author <a href="mailto:alessio.soldano@jboss.com">Alessio
Soldano</a>
+ */
+@SuppressWarnings("unchecked")
+public class DOMWriter
+{
+ private static final Pattern PATTERN =
Pattern.compile("[&<>'\"\r\n]");
+ // Print writer
+ private PrintWriter out;
+ // True, if canonical output
+ private boolean canonical;
+ // True, if pretty printing should be used
+ private boolean prettyprint;
+ // True, if the XML declaration should be written
+ private boolean writeXMLDeclaration;
+ // True, if whitespace should be ignored
+ private boolean ignoreWhitespace;
+ // Explicit character set encoding
+ private String charsetName;
+ // indent for the pretty printer
+ private int prettyIndent;
+ // True, if the XML declaration has been written
+ private boolean wroteXMLDeclaration;
+ // The node that started the write
+ private Node rootNode;
+ // True if we want namespace completion
+ private boolean completeNamespaces = true;
+ // The current default namespace
+ private String currentDefaultNamespace;
+
+ public DOMWriter(Writer w)
+ {
+ this.out = new PrintWriter(w);
+ }
+
+ public DOMWriter(Writer w, String charsetName)
+ {
+ this.out = new PrintWriter(w);
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+
+ public DOMWriter(OutputStream stream)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, "UTF-8"));
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ // ignore, UTF-8 should be available
+ }
+ }
+
+ public DOMWriter(OutputStream stream, String charsetName)
+ {
+ try
+ {
+ this.out = new PrintWriter(new OutputStreamWriter(stream, charsetName));
+ this.charsetName = charsetName;
+ this.writeXMLDeclaration = true;
+ }
+ catch (UnsupportedEncodingException e)
+ {
+ throw new IllegalArgumentException("Unsupported encoding: " +
charsetName);
+ }
+ }
+
+ /**
+ * Print a node with explicit prettyprinting.
+ * The defaults for all other DOMWriter properties apply.
+ *
+ */
+ public static String printNode(Node node, boolean prettyprint)
+ {
+ StringWriter strw = new StringWriter();
+ new DOMWriter(strw).setPrettyprint(prettyprint).print(node);
+ return strw.toString();
+ }
+
+ public boolean isCanonical()
+ {
+ return canonical;
+ }
+
+ /**
+ * Set wheter entities should appear in their canonical form.
+ * The default is false.
+ */
+ public DOMWriter setCanonical(boolean canonical)
+ {
+ this.canonical = canonical;
+ return this;
+ }
+
+ public boolean isIgnoreWhitespace()
+ {
+ return ignoreWhitespace;
+ }
+
+ /**
+ * Set whether whitespace should be ignored.
+ * The default is false.
+ */
+ public DOMWriter setIgnoreWhitespace(boolean ignoreWhitespace)
+ {
+ this.ignoreWhitespace = ignoreWhitespace;
+ return this;
+ }
+
+ /**
+ * Set wheter subelements should have their namespaces completed.
+ * Setting this to false may lead to invalid XML fragments.
+ * The default is true.
+ */
+ public DOMWriter setCompleteNamespaces(boolean complete)
+ {
+ this.completeNamespaces = complete;
+ return this;
+ }
+
+ public boolean isPrettyprint()
+ {
+ return prettyprint;
+ }
+
+ /**
+ * Set wheter element should be indented.
+ * The default is false.
+ */
+ public DOMWriter setPrettyprint(boolean prettyprint)
+ {
+ this.prettyprint = prettyprint;
+ return this;
+ }
+
+ public boolean isWriteXMLDeclaration()
+ {
+ return writeXMLDeclaration;
+ }
+
+ /**
+ * Set wheter the XML declaration should be written.
+ * The default is false.
+ */
+ public DOMWriter setWriteXMLDeclaration(boolean flag)
+ {
+ this.writeXMLDeclaration = flag;
+ return this;
+ }
+
+ public void print(Node node)
+ {
+ if (prettyprint && ignoreWhitespace)
+ throw new IllegalStateException("Cannot pretty print and ignore
whitespace");
+
+ rootNode = node;
+ printInternal(node, false);
+ }
+
+ private void printInternal(Node node, boolean indentEndMarker)
+ {
+ // is there anything to do?
+ if (node == null)
+ {
+ return;
+ }
+
+ // JBAS-2117 - Don't skip the DOCUMENT_NODE
+ // if (node instanceof Document) node = ((Document)node).getDocumentElement();
+
+ if (wroteXMLDeclaration == false && writeXMLDeclaration == true &&
canonical == false)
+ {
+ out.print("<?xml version='1.0'");
+ if (charsetName != null)
+ out.print(" encoding='" + charsetName + "'");
+
+ out.print("?>");
+ if (prettyprint)
+ out.println();
+
+ wroteXMLDeclaration = true;
+ }
+
+ int type = node.getNodeType();
+ boolean hasChildNodes = node.getChildNodes().getLength() > 0;
+
+ String nodeName = node.getNodeName();
+ switch (type)
+ {
+ // print document
+ case Node.DOCUMENT_NODE:
+ {
+ NodeList children = node.getChildNodes();
+ int len = children.getLength();
+ for (int iChild = 0; iChild < len; iChild++)
+ {
+ printInternal(children.item(iChild), false);
+ }
+ out.flush();
+ break;
+ }
+
+ // print element with attributes
+ case Node.ELEMENT_NODE:
+ {
+ Element element = (Element)node;
+ if (prettyprint)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ prettyIndent++;
+ }
+
+ out.print('<');
+ out.print(nodeName);
+
+ Map nsMap = new HashMap();
+ String elPrefix = node.getPrefix();
+ String elNamespaceURI = node.getNamespaceURI();
+ if (elPrefix != null)
+ {
+ String nsURI = getNamespaceURI(elPrefix, element, rootNode);
+ nsMap.put(elPrefix, nsURI);
+ }
+
+ Attr attrs[] = sortAttributes(node.getAttributes());
+ for (int i = 0; i < attrs.length; i++)
+ {
+ Attr attr = attrs[i];
+ String atPrefix = attr.getPrefix();
+ String atName = attr.getNodeName();
+ String atValue = normalize(attr.getNodeValue(), canonical);
+
+ if (atName.equals("xmlns"))
+ currentDefaultNamespace = atValue;
+
+ if (atPrefix != null && !atPrefix.equals("xmlns")
&& !atPrefix.equals("xml"))
+ {
+ String nsURI = getNamespaceURI(atPrefix, element, rootNode);
+ nsMap.put(atPrefix, nsURI);
+ // xsi:type='ns1:SubType', xsi:type='xsd:string'
+ if (atName.equals(atPrefix + ":type") &&
atValue.indexOf(":") > 0)
+ {
+ // xsi defined on the envelope
+ if (nsURI == null)
+ nsURI = getNamespaceURI(atPrefix, element, null);
+
+ if
("http://www.w3.org/2001/XMLSchema-instance".equals(nsURI))
+ {
+ String typePrefix = atValue.substring(0,
atValue.indexOf(":"));
+ String typeURI = getNamespaceURI(typePrefix, element, rootNode);
+ nsMap.put(typePrefix, typeURI);
+ }
+ }
+ }
+
+ out.print(" " + atName + "='" + atValue +
"'");
+ }
+
+ // Add namespace declaration for prefixes
+ // that are defined further up the tree
+ if (completeNamespaces)
+ {
+ Iterator itPrefix = nsMap.keySet().iterator();
+ while (itPrefix.hasNext())
+ {
+ String prefix = (String)itPrefix.next();
+ String nsURI = (String)nsMap.get(prefix);
+ if (nsURI == null)
+ {
+ nsURI = getNamespaceURI(prefix, element, null);
+ out.print(" xmlns:" + prefix + "='" + nsURI
+ "'");
+ }
+ }
+ }
+
+ // The SAX ContentHandler will by default not add the namespace declaration
+ // <Hello xmlns='http://somens'>World</Hello>
+ if (elPrefix == null && elNamespaceURI != null)
+ {
+ String defaultNamespace = element.getAttribute("xmlns");
+ if (defaultNamespace.length() == 0 &&
!elNamespaceURI.equals(currentDefaultNamespace))
+ {
+ out.print(" xmlns='" + elNamespaceURI +
"'");
+ currentDefaultNamespace = elNamespaceURI;
+ }
+ }
+
+ if (hasChildNodes)
+ {
+ out.print('>');
+ }
+
+ // Find out if the end marker is indented
+ indentEndMarker = isEndMarkerIndented(node);
+
+ if (indentEndMarker)
+ {
+ out.print('\n');
+ }
+
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node childNode = childNodes.item(i);
+ printInternal(childNode, false);
+ }
+ break;
+ }
+
+ // handle entity reference nodes
+ case Node.ENTITY_REFERENCE_NODE:
+ {
+ if (canonical)
+ {
+ NodeList children = node.getChildNodes();
+ if (children != null)
+ {
+ int len = children.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ printInternal(children.item(i), false);
+ }
+ }
+ }
+ else
+ {
+ out.print('&');
+ out.print(nodeName);
+ out.print(';');
+ }
+ break;
+ }
+
+ // print cdata sections
+ case Node.CDATA_SECTION_NODE:
+ {
+ if (canonical)
+ {
+ out.print(normalize(node.getNodeValue(), canonical));
+ }
+ else
+ {
+ out.print("<![CDATA[");
+ out.print(node.getNodeValue());
+ out.print("]]>");
+ }
+ break;
+ }
+
+ // print text
+ case Node.TEXT_NODE:
+ {
+ String text = normalize(node.getNodeValue(), canonical);
+ if (text.trim().length() > 0)
+ {
+ out.print(text);
+ }
+ else if (prettyprint == false && ignoreWhitespace == false)
+ {
+ out.print(text);
+ }
+ break;
+ }
+
+ // print processing instruction
+ case Node.PROCESSING_INSTRUCTION_NODE:
+ {
+ out.print("<?");
+ out.print(nodeName);
+ String data = node.getNodeValue();
+ if (data != null && data.length() > 0)
+ {
+ out.print(' ');
+ out.print(data);
+ }
+ out.print("?>");
+ break;
+ }
+
+ // print comment
+ case Node.COMMENT_NODE:
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+
+ out.print("<!--");
+ String data = node.getNodeValue();
+ if (data != null)
+ {
+ out.print(data);
+ }
+ out.print("-->");
+
+ if (prettyprint)
+ {
+ out.print('\n');
+ }
+
+ break;
+ }
+ }
+
+ if (type == Node.ELEMENT_NODE)
+ {
+ if (prettyprint)
+ prettyIndent--;
+
+ if (hasChildNodes == false)
+ {
+ out.print("/>");
+ }
+ else
+ {
+ if (indentEndMarker)
+ {
+ for (int i = 0; i < prettyIndent; i++)
+ {
+ out.print(' ');
+ }
+ }
+
+ out.print("</");
+ out.print(nodeName);
+ out.print('>');
+ }
+
+ if (prettyIndent > 0)
+ {
+ out.print('\n');
+ }
+ }
+ out.flush();
+ }
+
+ private String getNamespaceURI(String prefix, Element element, Node stopNode)
+ {
+ Node parent = element.getParentNode();
+ String nsURI = element.getAttribute("xmlns:" + prefix);
+ if (nsURI.length() == 0 && element != stopNode && parent instanceof
Element)
+ return getNamespaceURI(prefix, (Element)parent, stopNode);
+
+ return (nsURI.length() > 0 ? nsURI : null);
+ }
+
+ private boolean isEndMarkerIndented(Node node)
+ {
+ if (prettyprint)
+ {
+ NodeList childNodes = node.getChildNodes();
+ int len = childNodes.getLength();
+ for (int i = 0; i < len; i++)
+ {
+ Node children = childNodes.item(i);
+ if (children.getNodeType() == Node.ELEMENT_NODE)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /** Returns a sorted list of attributes. */
+ private Attr[] sortAttributes(NamedNodeMap attrs)
+ {
+
+ int len = (attrs != null) ? attrs.getLength() : 0;
+ Attr array[] = new Attr[len];
+ for (int i = 0; i < len; i++)
+ {
+ array[i] = (Attr)attrs.item(i);
+ }
+ for (int i = 0; i < len - 1; i++)
+ {
+ String name = array[i].getNodeName();
+ int index = i;
+ for (int j = i + 1; j < len; j++)
+ {
+ String curName = array[j].getNodeName();
+ if (curName.compareTo(name) < 0)
+ {
+ name = curName;
+ index = j;
+ }
+ }
+ if (index != i)
+ {
+ Attr temp = array[i];
+ array[i] = array[index];
+ array[index] = temp;
+ }
+ }
+ return (array);
+ }
+
+ /** Normalizes the given string. */
+ public static String normalize(String strValue, boolean canonical)
+ {
+ Matcher m = PATTERN.matcher(strValue);
+ if (m.find())
+ {
+ int pos = m.start(); // we can use previous match to skip some part at the
string beginning
+ int len = strValue.length(); // just a single call to length()
+ char[] input = new char[len]; // this is to ommit calls to String.charAt()
+ strValue.getChars(0, len, input, 0);
+ StringBuilder sb = new StringBuilder(len * 3); // faster than StringBuffer, not
thread safe
+
+ int copyStart = 0;
+
+ for (int i = pos; i < len; i++)
+ {
+ char ch = input[i];
+ switch (ch)
+ {
+ case '<' :
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append("<");
+ break;
+ case '>' :
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append(">");
+ break;
+ case '"' :
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append(""");
+ break;
+ case '\'' :
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append("'");
+ break;
+ case '&' :
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append("&");
+ break;
+ case '\r' :
+ case '\n' :
+ if (canonical)
+ {
+ if (copyStart < i)
+ {
+ sb.append(input, copyStart, i - copyStart);
+ }
+ copyStart = i + 1;
+ sb.append("&#");
+ sb.append(Integer.toString(ch));
+ sb.append(';');
+ break;
+ }
+
+ }
+ }
+ if (copyStart < len)
+ {
+ sb.append(input, copyStart, len - copyStart);
+ }
+
+ return sb.toString();
+ }
+ else
+ {
+ return strValue;
+ }
+ }
+}
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jaxbintros/ProviderBeanJAXB.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jaxbintros/ProviderBeanJAXB.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jaxbintros/ProviderBeanJAXB.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -22,8 +22,8 @@
package org.jboss.test.ws.jaxws.jaxbintros;
import org.jboss.logging.Logger;
+import org.jboss.test.helper.DOMWriter;
import org.jboss.ws.core.jaxws.JAXBContextFactory;
-import org.jboss.wsf.common.DOMWriter;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1909/TestEndpointImpl.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1909/TestEndpointImpl.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1909/TestEndpointImpl.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -31,19 +31,22 @@
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.management.ObjectName;
+import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;
import org.jboss.logging.Logger;
-import org.jboss.wsf.common.DOMUtils;
-import org.jboss.wsf.common.ObjectNameFactory;
import org.jboss.wsf.spi.SPIProvider;
import org.jboss.wsf.spi.SPIProviderResolver;
+import org.jboss.wsf.spi.classloading.ClassLoaderProvider;
import org.jboss.wsf.spi.deployment.Endpoint;
import org.jboss.wsf.spi.invocation.RequestHandler;
import org.jboss.wsf.spi.management.EndpointRegistry;
import org.jboss.wsf.spi.management.EndpointRegistryFactory;
+import org.jboss.wsf.util.DOMUtils;
import org.w3c.dom.Element;
@WebService(serviceName = "TestEndpointService", name =
"TestEndpoint", targetNamespace = "http://org.jboss.ws/jbws1909")
@@ -66,29 +69,50 @@
log.info(key + "=" + msgContext.get(key));
}
- SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
- EndpointRegistry registry =
spiProvider.getSPI(EndpointRegistryFactory.class).getEndpointRegistry();
+ ClassLoader cl =
ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader();
+ SPIProvider spiProvider = SPIProviderResolver.getInstance(cl).getProvider();
+ EndpointRegistry registry = spiProvider.getSPI(EndpointRegistryFactory.class,
cl).getEndpointRegistry();
- ObjectName oname =
ObjectNameFactory.create("jboss.ws:context=jaxws-jbws1909,endpoint=TestEndpointImpl");
- Endpoint endpoint = registry.getEndpoint(oname);
- RequestHandler reqHandler = endpoint.getRequestHandler();
-
try
{
+ ObjectName oname = new
ObjectName("jboss.ws:context=jaxws-jbws1909,endpoint=TestEndpointImpl");
+ Endpoint endpoint = registry.getEndpoint(oname);
+ RequestHandler reqHandler = endpoint.getRequestHandler();
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
reqHandler.handleWSDLRequest(endpoint, baos, null); // The context is null
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- Element root = DOMUtils.parse(bais);
+ Element root = DOMUtils.parse(bais, getDocumentBuilder());
Element serviceEl = DOMUtils.getFirstChildElement(root, new
QName("http://schemas.xmlsoap.org/wsdl/", "service"));
String serviceName = DOMUtils.getAttributeValue(serviceEl, "name");
input += "|" + serviceName;
}
- catch (IOException ex)
+ catch (Exception ex)
{
throw new RuntimeException(ex);
}
return input;
}
+
+ private DocumentBuilder getDocumentBuilder()
+ {
+ DocumentBuilderFactory factory = null;
+ try
+ {
+ factory = DocumentBuilderFactory.newInstance();
+ factory.setValidating(false);
+ factory.setNamespaceAware(true);
+ factory.setExpandEntityReferences(false);
+ factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ return builder;
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException("Unable to create document builder", e);
+ }
+ }
+
}
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2285/LogicalHandler.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2285/LogicalHandler.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2285/LogicalHandler.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -29,8 +29,8 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.jboss.logging.Logger;
+import org.jboss.test.helper.DOMWriter;
import org.jboss.ws.WSException;
-import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.common.handler.GenericLogicalHandler;
/**
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java 2011-04-14
16:08:22 UTC (rev 14102)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2319/SOAPHandler.java 2011-04-14
16:28:19 UTC (rev 14103)
@@ -29,8 +29,8 @@
import javax.xml.ws.handler.soap.SOAPMessageContext;
import org.jboss.logging.Logger;
+import org.jboss.test.helper.DOMWriter;
import org.jboss.ws.WSException;
-import org.jboss.wsf.common.DOMWriter;
import org.jboss.wsf.common.handler.GenericSOAPHandler;
import org.w3c.dom.Document;
import org.w3c.dom.Node;