JBossWS SVN: r13349 - in stack/cxf/trunk: modules/resources/src/main/resources/resources and 2 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:27:42 -0500 (Sat, 27 Nov 2010)
New Revision: 13349
Modified:
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.bat
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.sh
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.bat
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.sh
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat
stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh
stack/cxf/trunk/modules/resources/src/main/resources/resources/deploy.conf
stack/cxf/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
stack/cxf/trunk/src/main/distro/build-project-gen.xml
stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml
Log:
[JBWS-2709] jbossws-cxf stack changes for installing jbossws-api.jar
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.bat
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.bat 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.bat 2010-11-28 02:27:42 UTC (rev 13349)
@@ -30,6 +30,7 @@
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/jbossall-client.jar
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/log4j.jar
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/mail.jar
+set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/jbossws-api.jar
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/jbossws-spi.jar
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/jbossws-common.jar
set WSCONSUME_CLASSPATH=%WSCONSUME_CLASSPATH%;%JBOSS_HOME%/client/jbossws-framework.jar
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.sh
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.sh 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsconsume.sh 2010-11-28 02:27:42 UTC (rev 13349)
@@ -69,6 +69,7 @@
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/jbossall-client.jar"
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/log4j.jar"
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/mail.jar"
+WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/jbossws-api.jar"
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/jbossws-spi.jar"
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/jbossws-common.jar"
WSCONSUME_CLASSPATH="$WSCONSUME_CLASSPATH:$LIBDIR/jbossws-framework.jar"
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.bat
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.bat 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.bat 2010-11-28 02:27:42 UTC (rev 13349)
@@ -23,6 +23,7 @@
rem shared libs
set WSPROVIDE_CLASSPATH=%WSPROVIDE_CLASSPATH%;%JAVAC_JAR%
+set WSPROVIDE_CLASSPATH=%WSPROVIDE_CLASSPATH%;%JBOSS_HOME%/client/jbossws-api.jar
set WSPROVIDE_CLASSPATH=%WSPROVIDE_CLASSPATH%;%JBOSS_HOME%/client/jbossws-spi.jar
set WSPROVIDE_CLASSPATH=%WSPROVIDE_CLASSPATH%;%JBOSS_HOME%/client/jbossws-common.jar
set WSPROVIDE_CLASSPATH=%WSPROVIDE_CLASSPATH%;%JBOSS_HOME%/client/jbossws-framework.jar
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.sh
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.sh 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsprovide.sh 2010-11-28 02:27:42 UTC (rev 13349)
@@ -65,6 +65,7 @@
# shared libs
WSPROVIDE_CLASSPATH="$WSPROVIDE_CLASSPATH:$JAVA_HOME/lib/tools.jar"
+WSPROVIDE_CLASSPATH="$WSPROVIDE_CLASSPATH:$LIBDIR/jbossws-api.jar"
WSPROVIDE_CLASSPATH="$WSPROVIDE_CLASSPATH:$LIBDIR/jbossws-spi.jar"
WSPROVIDE_CLASSPATH="$WSPROVIDE_CLASSPATH:$LIBDIR/jbossws-common.jar"
WSPROVIDE_CLASSPATH="$WSPROVIDE_CLASSPATH:$LIBDIR/jbossws-framework.jar"
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.bat 2010-11-28 02:27:42 UTC (rev 13349)
@@ -52,6 +52,7 @@
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/jbossxb.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/jbossws-common.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/jbossws-framework.jar
+set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/jbossws-api.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/jbossws-spi.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/FastInfoset.jar
set WSRUNCLIENT_CLASSPATH=%WSRUNCLIENT_CLASSPATH%;%JBOSS_HOME%/client/log4j.jar
Modified: stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/bin/wsrunclient.sh 2010-11-28 02:27:42 UTC (rev 13349)
@@ -72,6 +72,7 @@
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/jbossxb.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/jbossws-common.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/jbossws-framework.jar"
+WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/jbossws-api.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/jbossws-spi.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/FastInfoset.jar"
WSRUNCLIENT_CLASSPATH="$WSRUNCLIENT_CLASSPATH:$JBOSS_HOME/client/log4j.jar"
Modified: stack/cxf/trunk/modules/resources/src/main/resources/resources/deploy.conf
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/resources/deploy.conf 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/resources/deploy.conf 2010-11-28 02:27:42 UTC (rev 13349)
@@ -1 +1 @@
-bin/wsconsume.bat bin/wsconsume.sh bin/wsprovide.bat bin/wsprovide.sh bin/wsrunclient.bat bin/wsrunclient.sh bin/wstools.bat bin/wstools.sh client/jbossws-native-jaxws-ext.jar client/cxf-*.jar client/geronimo-*.jar client/jaxws-httpserver-httpspi.jar client/neethi.jar client/saaj-impl.jar client/spring-*.jar client/wss4j.jar client/XmlSchema.jar client/asm.jar client/jetty*.jar client/velocity.jar client/commons-collections.jar client/commons-lang.jar client/jettison.jar client/jaxb-api.jar client/FastInfoset.jar client/commons-beanutils.jar client/jaxb-impl.jar client/jaxb-xjc.jar client/jaxws-rt.jar client/jaxws-tools.jar client/policy.jar client/jbossws-cxf-* client/jbossws-native-jaxrpc.jar client/jaxrpc-api.jar client/jbossws-native-jaxws.jar client/jbossws-native-factories.jar client/jaxws-api.jar client/jsr181-api.jar client/jbossws-native-saaj.jar client/saaj-api.jar client/jbossws-native-client.jar client/jbossws-native-services.jar client/jbossws-common.jar client!
/jbossws-framework.jar client/jbossws-spi.jar client/wscommons-policy.jar client/stax-ex.jar client/streambuffer.jar client/wsdl4j.jar lib/jaxb-api.jar lib/jaxb-impl.jar common/lib/jbossws-native-jaxws-ext.jar common/lib/cxf-*.jar common/lib/jaxws-httpserver-httpspi.jar common/lib/geronimo-*.jar common/lib/neethi.jar common/lib/saaj-impl.jar common/lib/spring-*.jar common/lib/wss4j.jar common/lib/XmlSchema.jar common/lib/asm.jar common/lib/FastInfoset.jar common/lib/jboss-jaxb-intros.jar common/lib/jettison.jar common/lib/wscommons-policy.jar common/lib/wsdl4j.jar common/lib/xmlsec.jar common/lib/jbossws-native-jaxrpc.jar common/lib/jaxrpc-api.jar common/lib/jbossws-native-jaxws.jar common/lib/jaxws-api.jar common/lib/jsr181-api.jar common/lib/jbossws-native-saaj.jar common/lib/saaj-api.jar common/lib/jbossws-common.jar common/lib/jbossws-framework.jar common/lib/jbossws-spi.jar common/lib/commons-beanutils.jar lib/endorsed/*jbossws* lib/endorsed/*jaxb*.jar lib/endorsed/*ja!
xws*.jar
+bin/wsconsume.bat bin/wsconsume.sh bin/wsprovide.bat bin/wsprovide.sh bin/wsrunclient.bat bin/wsrunclient.sh bin/wstools.bat bin/wstools.sh client/jbossws-native-jaxws-ext.jar client/cxf-*.jar client/geronimo-*.jar client/jaxws-httpserver-httpspi.jar client/neethi.jar client/saaj-impl.jar client/spring-*.jar client/wss4j.jar client/XmlSchema.jar client/asm.jar client/jetty*.jar client/velocity.jar client/commons-collections.jar client/commons-lang.jar client/jettison.jar client/jaxb-api.jar client/FastInfoset.jar client/commons-beanutils.jar client/jaxb-impl.jar client/jaxb-xjc.jar client/jaxws-rt.jar client/jaxws-tools.jar client/policy.jar client/jbossws-cxf-* client/jbossws-native-jaxrpc.jar client/jaxrpc-api.jar client/jbossws-native-jaxws.jar client/jbossws-native-factories.jar client/jaxws-api.jar client/jsr181-api.jar client/jbossws-native-saaj.jar client/saaj-api.jar client/jbossws-native-client.jar client/jbossws-native-services.jar client/jbossws-common.jar client!
/jbossws-framework.jar client/jbossws-api.jar client/jbossws-spi.jar client/wscommons-policy.jar client/stax-ex.jar client/streambuffer.jar client/wsdl4j.jar lib/jaxb-api.jar lib/jaxb-impl.jar common/lib/jbossws-native-jaxws-ext.jar common/lib/cxf-*.jar common/lib/jaxws-httpserver-httpspi.jar common/lib/geronimo-*.jar common/lib/neethi.jar common/lib/saaj-impl.jar common/lib/spring-*.jar common/lib/wss4j.jar common/lib/XmlSchema.jar common/lib/asm.jar common/lib/FastInfoset.jar common/lib/jboss-jaxb-intros.jar common/lib/jettison.jar common/lib/wscommons-policy.jar common/lib/wsdl4j.jar common/lib/xmlsec.jar common/lib/jbossws-native-jaxrpc.jar common/lib/jaxrpc-api.jar common/lib/jbossws-native-jaxws.jar common/lib/jaxws-api.jar common/lib/jsr181-api.jar common/lib/jbossws-native-saaj.jar common/lib/saaj-api.jar common/lib/jbossws-common.jar common/lib/jbossws-framework.jar common/lib/jbossws-api.jar common/lib/jbossws-spi.jar common/lib/commons-beanutils.jar lib/endorsed/!
*jbossws* lib/endorsed/*jaxb*.jar lib/endorsed/*jaxws*.jar
Modified: stack/cxf/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml
===================================================================
--- stack/cxf/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/modules/resources/src/main/resources/resources/jbossws-deploy-macros.xml 2010-11-28 02:27:42 UTC (rev 13349)
@@ -36,6 +36,7 @@
<include name="**/jaxws-api.jar"/>
<include name="**/jaxws-httpserver-httpspi.jar"/>
<include name="**/jsr181-api.jar"/>
+ <include name="**/jbossws-api.jar"/>
<include name="**/jbossws-common.jar"/>
<include name="**/jbossws-cxf-client*.jar"/>
<include name="**/jbossws-framework.jar"/>
@@ -75,6 +76,7 @@
<include name="**/jaxws-httpserver-httpspi.jar"/>
<include name="**/jsr181-api.jar"/>
<include name="**/jboss-jaxb-intros.jar"/>
+ <include name="**/jbossws-api.jar"/>
<include name="**/jbossws-common.jar"/>
<include name="**/jbossws-framework.jar"/>
<include name="**/jbossws-spi.jar"/>
Modified: stack/cxf/trunk/src/main/distro/build-project-gen.xml
===================================================================
--- stack/cxf/trunk/src/main/distro/build-project-gen.xml 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/src/main/distro/build-project-gen.xml 2010-11-28 02:27:42 UTC (rev 13349)
@@ -119,6 +119,7 @@
<pathelement location="${jboss.client}/jaxb-impl.jar"/>
<pathelement location="${jboss.client}/jaxb-xjc.jar"/>
<pathelement location="${jboss.client}/jaxws-api.jar"/>
+ <pathelement location="${jboss.client}/jbossws-api.jar"/>
<pathelement location="${jboss.client}/jbossws-common.jar"/>
<pathelement location="${jboss.client}/jbossws-spi.jar"/>
<pathelement location="${jboss.client}/jbossws-cxf-client.jar"/>
Modified: stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml
===================================================================
--- stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2010-11-28 02:24:33 UTC (rev 13348)
+++ stack/cxf/trunk/src/main/scripts/assembly-deploy-artifacts.xml 2010-11-28 02:27:42 UTC (rev 13349)
@@ -29,6 +29,7 @@
<include>org.apache.cxf.xjcplugins:cxf-*</include>
<include>com.sun.xml.bind:jaxb-impl:jar</include>
<include>com.sun.xml.bind:jaxb-xjc:jar</include>
+ <include>org.jboss.ws:jbossws-api:jar</include>
<include>org.jboss.ws:jbossws-common:jar</include>
<include>org.jboss.ws:jbossws-spi:jar</include>
<include>junit:junit:jar</include>
14 years, 1 month
JBossWS SVN: r13348 - in spi/trunk/src: main/java/org/jboss/wsf/spi/metadata/jms and 9 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:24:33 -0500 (Sat, 27 Nov 2010)
New Revision: 13348
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/util/StAXUtils.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/serviceref/
spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlersChainsMDParserTestCase.java
spi/trunk/src/test/resources/metadata/
spi/trunk/src/test/resources/metadata/j2ee/
spi/trunk/src/test/resources/metadata/j2ee/serviceref/
spi/trunk/src/test/resources/metadata/j2ee/serviceref/test-handlers.xml
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/jms/JMSEndpointsFactory.java
Log:
[JBWS-3169] Providing StAX based parser for handler chains descriptor to replace the JBossXB based one; adding unit testcase for UnifiedHandlersChainsMetaData creation
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java 2010-11-28 02:21:57 UTC (rev 13347)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java 2010-11-28 02:24:33 UTC (rev 13348)
@@ -21,12 +21,20 @@
*/
package org.jboss.wsf.spi.metadata.j2ee.serviceref;
+import static javax.xml.stream.XMLStreamConstants.END_ELEMENT;
+import static javax.xml.stream.XMLStreamConstants.START_ELEMENT;
+import static org.jboss.wsf.spi.util.StAXUtils.createXMLStreamReader;
+import static org.jboss.wsf.spi.util.StAXUtils.elementAsQName;
+import static org.jboss.wsf.spi.util.StAXUtils.elementAsString;
+import static org.jboss.wsf.spi.util.StAXUtils.match;
+
import java.io.IOException;
import java.io.InputStream;
-import org.jboss.xb.binding.JBossXBException;
-import org.jboss.xb.binding.Unmarshaller;
-import org.jboss.xb.binding.UnmarshallerFactory;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
/** The interface of the parser for the unified metadata handler chains element
*
@@ -35,17 +43,213 @@
*/
public class UnifiedHandlerChainsMetaDataParser
{
- @SuppressWarnings("deprecation")
+ private static final String JAVAEE_NS = "http://java.sun.com/xml/ns/javaee";
+ private static final QName QNAME_CHAIN_PORT_PATTERN = new QName(JAVAEE_NS, "port-name-pattern");
+ private static final QName QNAME_CHAIN_PROTOCOL_BINDING = new QName(JAVAEE_NS, "protocol-bindings");
+ private static final QName QNAME_CHAIN_SERVICE_PATTERN = new QName(JAVAEE_NS, "service-name-pattern");
+ private static final QName QNAME_HANDLER_CHAIN = new QName(JAVAEE_NS, "handler-chain");
+ private static final QName QNAME_HANDLER_CHAINS = new QName(JAVAEE_NS, "handler-chains");
+ private static final QName QNAME_HANDLER = new QName(JAVAEE_NS, "handler");
+ private static final QName QNAME_HANDLER_NAME = new QName(JAVAEE_NS, "handler-name");
+ private static final QName QNAME_HANDLER_CLASS = new QName(JAVAEE_NS, "handler-class");
+ private static final QName QNAME_HANDLER_PARAM = new QName(JAVAEE_NS, "init-param");
+ private static final QName QNAME_HANDLER_PARAM_NAME = new QName(JAVAEE_NS, "param-name");
+ private static final QName QNAME_HANDLER_PARAM_VALUE = new QName(JAVAEE_NS, "param-value");
+
public static UnifiedHandlerChainsMetaData parse(InputStream is) throws IOException
{
+ // http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd
try
{
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- return (UnifiedHandlerChainsMetaData) unmarshaller.unmarshal(is, new HandlerChainsObjectFactory(), null);
+ XMLStreamReader xmlr = createXMLStreamReader(is);
+ return parse(xmlr);
}
- catch (JBossXBException xbe)
+ catch (XMLStreamException e)
{
- throw new IOException(xbe);
+ throw new IOException(e);
}
}
+
+ public static UnifiedHandlerChainsMetaData parse(XMLStreamReader reader) throws XMLStreamException
+ {
+ int iterate;
+ try
+ {
+ iterate = reader.nextTag();
+ }
+ catch (XMLStreamException e)
+ {
+ // skip non-tag elements
+ iterate = reader.nextTag();
+ }
+ UnifiedHandlerChainsMetaData handlerChains = null;
+ switch (iterate)
+ {
+ case END_ELEMENT : {
+ // we're done
+ break;
+ }
+ case START_ELEMENT : {
+
+ if (match(reader, QNAME_HANDLER_CHAINS))
+ {
+ handlerChains = parseHandlerChains(reader);
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " + reader.getLocalName());
+ }
+ }
+ }
+ return handlerChains;
+ }
+
+ private static UnifiedHandlerChainsMetaData parseHandlerChains(XMLStreamReader reader) throws XMLStreamException
+ {
+ UnifiedHandlerChainsMetaData handlerChains = new UnifiedHandlerChainsMetaData();
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_CHAINS))
+ {
+ return handlerChains;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " + reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_CHAIN)) {
+ handlerChains.addHandlerChain(parseHandlerChain(reader, handlerChains));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " + reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document unexpectedly");
+ }
+
+ private static UnifiedHandlerChainMetaData parseHandlerChain(XMLStreamReader reader, UnifiedHandlerChainsMetaData handlerChains) throws XMLStreamException
+ {
+ UnifiedHandlerChainMetaData handlerChain = new UnifiedHandlerChainMetaData(handlerChains);
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_CHAIN))
+ {
+ return handlerChain;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " + reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, QNAME_CHAIN_PORT_PATTERN))
+ {
+ handlerChain.setPortNamePattern(elementAsQName(reader));
+ }
+ else if (match(reader, QNAME_CHAIN_SERVICE_PATTERN))
+ {
+ handlerChain.setServiceNamePattern(elementAsQName(reader));
+ }
+ else if(match(reader, QNAME_CHAIN_PROTOCOL_BINDING))
+ {
+ handlerChain.setProtocolBindings(elementAsString(reader));
+ }
+ else if (match(reader, QNAME_HANDLER)) {
+ handlerChain.addHandler(parseHandler(reader, handlerChain));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " + reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document unexpectedly");
+ }
+
+ private static UnifiedHandlerMetaData parseHandler(XMLStreamReader reader, UnifiedHandlerChainMetaData handlerChain) throws XMLStreamException
+ {
+ UnifiedHandlerMetaData handler = new UnifiedHandlerMetaData(handlerChain);
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, QNAME_HANDLER))
+ {
+ return handler;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " + reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_NAME))
+ {
+ handler.setHandlerName(elementAsString(reader));
+ }
+ else if (match(reader, QNAME_HANDLER_CLASS))
+ {
+ handler.setHandlerClass(elementAsString(reader));
+ }
+ else if (match(reader, QNAME_HANDLER_PARAM)) {
+ handler.addInitParam(parseInitParam(reader));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " + reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document unexpectedly");
+ }
+
+ private static UnifiedInitParamMetaData parseInitParam(XMLStreamReader reader) throws XMLStreamException
+ {
+ UnifiedInitParamMetaData initParam = new UnifiedInitParamMetaData();
+ while (reader.hasNext())
+ {
+ switch (reader.nextTag())
+ {
+ case XMLStreamConstants.END_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_PARAM))
+ {
+ return initParam;
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected end tag: " + reader.getLocalName());
+ }
+ }
+ case XMLStreamConstants.START_ELEMENT : {
+ if (match(reader, QNAME_HANDLER_PARAM_NAME))
+ {
+ initParam.setParamName(elementAsString(reader));
+ }
+ else if (match(reader, QNAME_HANDLER_PARAM_VALUE))
+ {
+ initParam.setParamValue(elementAsString(reader));
+ }
+ else
+ {
+ throw new IllegalStateException("Unexpected element: " + reader.getLocalName());
+ }
+ }
+ }
+ }
+ throw new IllegalStateException("Reached end of xml document unexpectedly");
+ }
}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/jms/JMSEndpointsFactory.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/jms/JMSEndpointsFactory.java 2010-11-28 02:21:57 UTC (rev 13347)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/jms/JMSEndpointsFactory.java 2010-11-28 02:24:33 UTC (rev 13348)
@@ -23,7 +23,6 @@
import java.net.URL;
-import org.jboss.logging.Logger;
import org.jboss.xb.binding.ObjectModelFactory;
import org.jboss.xb.binding.UnmarshallingContext;
import org.xml.sax.Attributes;
Added: spi/trunk/src/main/java/org/jboss/wsf/spi/util/StAXUtils.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/StAXUtils.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/StAXUtils.java 2010-11-28 02:24:33 UTC (rev 13348)
@@ -0,0 +1,136 @@
+/*
+ * 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.spi.util;
+
+import java.io.InputStream;
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLResolver;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+
+/**
+ * StAX utils
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Nov-2010
+ */
+public class StAXUtils
+{
+ private static final BlockingQueue<XMLInputFactory> INPUT_FACTORY_POOL;
+
+ static
+ {
+ int i = 10;
+ try
+ {
+ String s = System.getProperty("org.jboss.ws.staxutils.pool-size", "10");
+ i = Integer.parseInt(s);
+ }
+ catch (Throwable t)
+ {
+ i = 10;
+ }
+ if (i <= 0)
+ {
+ i = 10;
+ }
+ INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i);
+ }
+
+ /**
+ * Return a new factory so that the caller can set sticky parameters.
+ * @param nsAware
+ * @return
+ */
+ public static XMLInputFactory createXMLInputFactory(boolean nsAware)
+ {
+ XMLInputFactory factory = XMLInputFactory.newInstance();
+ factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, nsAware);
+ factory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE);
+ factory.setProperty(XMLInputFactory.IS_REPLACING_ENTITY_REFERENCES, Boolean.FALSE);
+ factory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, Boolean.FALSE);
+ factory.setXMLResolver(new XMLResolver()
+ {
+ public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace)
+ throws XMLStreamException
+ {
+ throw new XMLStreamException("Reading external entities is disabled");
+ }
+ });
+ return factory;
+ }
+
+ private static XMLInputFactory getXMLInputFactory()
+ {
+ XMLInputFactory f = INPUT_FACTORY_POOL.poll();
+ if (f == null)
+ {
+ f = createXMLInputFactory(true);
+ }
+ return f;
+ }
+
+ private static void returnXMLInputFactory(XMLInputFactory factory)
+ {
+ INPUT_FACTORY_POOL.offer(factory);
+ }
+
+ public static XMLStreamReader createXMLStreamReader(InputStream in)
+ {
+ XMLInputFactory factory = getXMLInputFactory();
+ try
+ {
+ return factory.createXMLStreamReader(in);
+ }
+ catch (XMLStreamException e)
+ {
+ throw new RuntimeException("Couldn't parse stream.", e);
+ }
+ finally
+ {
+ returnXMLInputFactory(factory);
+ }
+ }
+
+ public static boolean match(XMLStreamReader reader, QName name)
+ {
+ return reader.getName().equals(name);
+ }
+
+ public static String elementAsString(XMLStreamReader reader) throws XMLStreamException
+ {
+ String elementtext = reader.getElementText();
+ return elementtext == null ? null : elementtext.trim();
+ }
+
+ public static QName elementAsQName(XMLStreamReader reader) throws XMLStreamException
+ {
+ String namespaceURI = reader.getNamespaceURI(0);
+ String text = reader.getElementText();
+ String localPart = text.substring(text.indexOf(':') + 1, text.length());
+ return new QName(namespaceURI, localPart);
+ }
+}
Added: spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlersChainsMDParserTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlersChainsMDParserTestCase.java (rev 0)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlersChainsMDParserTestCase.java 2010-11-28 02:24:33 UTC (rev 13348)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.test.wsf.spi.metadata.j2ee.serviceref;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerChainsMetaDataParser;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedHandlerMetaData;
+import org.jboss.wsf.spi.metadata.j2ee.serviceref.UnifiedInitParamMetaData;
+
+/**
+ * Test the UnifiedHandlersChainsMetaDataParser
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 27-Nov-2010
+ */
+public class UnifiedHandlersChainsMDParserTestCase extends TestCase
+{
+ public void testParse() throws Exception
+ {
+ InputStream is = new FileInputStream(new File("src/test/resources/metadata/j2ee/serviceref/test-handlers.xml"));
+ UnifiedHandlerChainsMetaData metadata = UnifiedHandlerChainsMetaDataParser.parse(is);
+ List<UnifiedHandlerChainMetaData> chains = metadata.getHandlerChains();
+ assertEquals(2, chains.size());
+ testHandlerChain1(chains.get(0));
+ testHandlerChain2(chains.get(1));
+ }
+
+ private void testHandlerChain1(UnifiedHandlerChainMetaData chain)
+ {
+ assertEquals(new QName("http://ws.jboss.org/jbws2949", "EndpointPort", "foo"), chain.getPortNamePattern());
+ assertEquals(new QName("http://ws.jboss.org/jbws2949", "EndpointService", "foo"), chain.getServiceNamePattern());
+ assertEquals("##SOAP11_HTTP", chain.getProtocolBindings());
+ List<UnifiedHandlerMetaData> handlers = chain.getHandlers();
+ assertEquals(1, handlers.size());
+ UnifiedHandlerMetaData handler = handlers.get(0);
+ assertEquals(chain, handler.getHandlerChain());
+ assertEquals("SOAPServerHandler1", handler.getHandlerName());
+ assertEquals("org.jboss.test.ws.jaxws.jbws2949.SOAPHandler1", handler.getHandlerClass());
+ List<UnifiedInitParamMetaData> params = handler.getInitParams();
+ assertEquals(2, params.size());
+ assertEquals("foo", params.get(0).getParamName());
+ assertEquals("1", params.get(0).getParamValue());
+ assertEquals("bar", params.get(1).getParamName());
+ assertEquals("2", params.get(1).getParamValue());
+ assertEquals(0, handler.getPortNames().size());
+ assertEquals(0, handler.getSoapHeaders().size());
+ assertEquals(0, handler.getSoapRoles().size());
+ }
+
+ private void testHandlerChain2(UnifiedHandlerChainMetaData chain)
+ {
+ assertEquals(new QName("http://ws.jboss.org/jbws2949", "EndpointPort2", "foo"), chain.getPortNamePattern());
+ assertEquals(null, chain.getServiceNamePattern());
+ assertEquals(null, chain.getProtocolBindings());
+ List<UnifiedHandlerMetaData> handlers = chain.getHandlers();
+ assertEquals(2, handlers.size());
+ UnifiedHandlerMetaData handler1 = handlers.get(0);
+ assertEquals(chain, handler1.getHandlerChain());
+ assertEquals("SOAPServerHandler2", handler1.getHandlerName());
+ assertEquals("org.jboss.test.ws.jaxws.jbws2949.SOAPHandler2", handler1.getHandlerClass());
+ assertEquals(0, handler1.getInitParams().size());
+ assertEquals(0, handler1.getPortNames().size());
+ assertEquals(0, handler1.getSoapHeaders().size());
+ assertEquals(0, handler1.getSoapRoles().size());
+
+ UnifiedHandlerMetaData handler2 = handlers.get(1);
+ assertEquals(chain, handler2.getHandlerChain());
+ assertEquals("SOAPServerHandler3", handler2.getHandlerName());
+ assertEquals("org.jboss.test.ws.jaxws.jbws2949.SOAPHandler3", handler2.getHandlerClass());
+ assertEquals(0, handler2.getInitParams().size());
+ assertEquals(0, handler2.getPortNames().size());
+ assertEquals(0, handler2.getSoapHeaders().size());
+ assertEquals(0, handler2.getSoapRoles().size());
+
+ }
+}
\ No newline at end of file
Added: spi/trunk/src/test/resources/metadata/j2ee/serviceref/test-handlers.xml
===================================================================
--- spi/trunk/src/test/resources/metadata/j2ee/serviceref/test-handlers.xml (rev 0)
+++ spi/trunk/src/test/resources/metadata/j2ee/serviceref/test-handlers.xml 2010-11-28 02:24:33 UTC (rev 13348)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<handler-chains xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://org.jboss.ws/jaxws/samples/logicalhandler"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee javaee_web_services_1_2.xsd">
+
+ <handler-chain>
+ <service-name-pattern xmlns:foo="http://ws.jboss.org/jbws2949">foo:EndpointService</service-name-pattern>
+ <port-name-pattern xmlns:foo="http://ws.jboss.org/jbws2949">foo:EndpointPort</port-name-pattern>
+ <protocol-bindings>##SOAP11_HTTP</protocol-bindings>
+ <handler>
+ <handler-name>SOAPServerHandler1</handler-name>
+ <handler-class>org.jboss.test.ws.jaxws.jbws2949.SOAPHandler1</handler-class>
+ <init-param>
+ <param-name>foo</param-name>
+ <param-value>1</param-value>
+ </init-param>
+ <init-param>
+ <param-name>bar</param-name>
+ <param-value>2</param-value>
+ </init-param>
+ </handler>
+ </handler-chain>
+
+ <handler-chain>
+ <port-name-pattern xmlns:ns1="http://ws.jboss.org/jbws2949">ns1:EndpointPort2</port-name-pattern>
+ <handler>
+ <handler-name>SOAPServerHandler2</handler-name>
+ <handler-class>org.jboss.test.ws.jaxws.jbws2949.SOAPHandler2</handler-class>
+ </handler>
+ <handler>
+ <handler-name>SOAPServerHandler3</handler-name>
+ <handler-class>org.jboss.test.ws.jaxws.jbws2949.SOAPHandler3</handler-class>
+ </handler>
+ </handler-chain>
+</handler-chains>
\ No newline at end of file
14 years, 1 month
JBossWS SVN: r13347 - spi/trunk/src/test/resources/smoke/tools.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:21:57 -0500 (Sat, 27 Nov 2010)
New Revision: 13347
Removed:
spi/trunk/src/test/resources/smoke/tools/consume-test.xml
spi/trunk/src/test/resources/smoke/tools/provide-test.xml
Log:
[JBWS-3115] Moving ant/cmd tools to jbossws-common
Deleted: spi/trunk/src/test/resources/smoke/tools/consume-test.xml
===================================================================
--- spi/trunk/src/test/resources/smoke/tools/consume-test.xml 2010-11-28 02:20:30 UTC (rev 13346)
+++ spi/trunk/src/test/resources/smoke/tools/consume-test.xml 2010-11-28 02:21:57 UTC (rev 13347)
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
- <!--
- An example build file that used to test the WSConsume Task
- -->
-
-<project name="consume-test" basedir=".">
-
- <property name="spi.dir" value="@SPI_DIR@"/>
-
- <!-- Define the JAX-WS wsconsume task -->
- <taskdef name="wsconsume" classname="org.jboss.wsf.spi.tools.ant.WSConsumeTask">
- <classpath>
- <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
- </classpath>
- </taskdef>
-
- <target name="plainInvocation">
- <wsconsume wsdl="Service.wsdl" verbose="true"/>
- </target>
-
-</project>
\ No newline at end of file
Deleted: spi/trunk/src/test/resources/smoke/tools/provide-test.xml
===================================================================
--- spi/trunk/src/test/resources/smoke/tools/provide-test.xml 2010-11-28 02:20:30 UTC (rev 13346)
+++ spi/trunk/src/test/resources/smoke/tools/provide-test.xml 2010-11-28 02:21:57 UTC (rev 13347)
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- An example build file that used to test the WSConsume Task
--->
-
-<project name="provide-test" basedir=".">
-
- <property name="spi.dir" value="@SPI_DIR@"/>
-
- <!-- Define the JAX-WS wsconsume task -->
- <taskdef name="wsprovide" classname="org.jboss.wsf.spi.tools.ant.WSProvideTask">
- <classpath>
- <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
- </classpath>
- </taskdef>
-
- <target name="plainInvocation">
- <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
- </target>
-
- <target name="includeWSDL">
- <wsprovide genwsdl="true" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
- </target>
-
- <target name="extraClasspath">
- <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean">
- <classpath>
- <pathelement location="${spi.dir}/output/test/classes"/>
- </classpath>
- </wsprovide>
- </target>
-</project>
\ No newline at end of file
14 years, 1 month
JBossWS SVN: r13346 - in spi/trunk: src/main/java/org/jboss/wsf/spi and 5 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:20:30 -0500 (Sat, 27 Nov 2010)
New Revision: 13346
Removed:
spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java
spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java
spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java
spi/trunk/src/main/java/org/jboss/wsf/spi/binding/
spi/trunk/src/main/java/org/jboss/wsf/spi/deployment/SecurityHandler.java
spi/trunk/src/main/java/org/jboss/wsf/spi/management/recording/
spi/trunk/src/main/java/org/jboss/wsf/spi/tools/
spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
Modified:
spi/trunk/pom.xml
spi/trunk/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java
Log:
[JBWS-3115][JBWS-2709] Moving stuff out of jbossws-spi to jbossws-api and jbossws-common; initial clean up of dependencies
Modified: spi/trunk/pom.xml
===================================================================
--- spi/trunk/pom.xml 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/pom.xml 2010-11-28 02:20:30 UTC (rev 13346)
@@ -25,23 +25,23 @@
<!-- Properties -->
<properties>
- <ant.version>1.7.1</ant.version>
- <dom4j.version>1.6.1</dom4j.version>
- <getopt.version>1.0.13</getopt.version>
- <jaxb.api.version>1.0.0.Final</jaxb.api.version>
- <jaxws.api.version>1.0.0.Final</jaxws.api.version>
<jms.api.version>1.0.0.Final</jms.api.version>
<jboss.microcontainer.version>2.0.8.GA</jboss.microcontainer.version>
<jbossxb.version>2.0.1.GA</jbossxb.version>
<jboss-logging-spi.version>2.0.5.GA</jboss-logging-spi.version>
<servlet.api.version>1.0.0.Final</servlet.api.version>
<junit.version>3.8.2</junit.version>
- <log4j.version>1.2.14</log4j.version>
</properties>
<!-- Dependencies -->
<dependencies>
+ <dependency>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-api</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
<!-- provided apis -->
<dependency>
<groupId>org.jboss.spec.javax.servlet</groupId>
@@ -50,24 +50,12 @@
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.spec.javax.xml.bind</groupId>
- <artifactId>jboss-jaxb-api_2.2_spec</artifactId>
- <version>${jaxb.api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.spec.javax.jms</groupId>
<artifactId>jboss-jms-api_1.1_spec</artifactId>
<version>${jms.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
- <groupId>org.jboss.spec.javax.xml.ws</groupId>
- <artifactId>jboss-jaxws-api_2.2_spec</artifactId>
- <version>${jaxws.api.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-spi</artifactId>
<version>${jboss-logging-spi.version}</version>
@@ -86,29 +74,6 @@
</exclusions>
</dependency>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>${log4j.version}</version>
- </dependency>
-
- <!-- transitive dependencies -->
- <dependency>
- <groupId>org.apache.ant</groupId>
- <artifactId>ant</artifactId>
- <version>${ant.version}</version>
- </dependency>
- <dependency>
- <groupId>dom4j</groupId>
- <artifactId>dom4j</artifactId>
- <version>${dom4j.version}</version>
- </dependency>
- <dependency>
- <groupId>gnu-getopt</groupId>
- <artifactId>getopt</artifactId>
- <version>${getopt.version}</version>
- </dependency>
-
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,83 +0,0 @@
-/*
- * 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.spi.annotation;
-
-import org.jboss.logging.Logger;
-
-/**
- * The authMethod is used to configure the authentication mechanism for the web service.
- * As a prerequisite to gaining access to any web service which are protected by an
- * authorization constraint, a user must have authenticated using the configured mechanism.
- *
- * @author ropalka(a)redhat.com
- */
-public final class AuthMethod
-{
- private static final Logger log = Logger.getLogger(AuthMethod.class);
-
- /**
- * Basic authentication.
- */
- public static final String BASIC = "BASIC";
- /**
- * Client certificate based authentication.
- */
- public static final String CLIENT_CERT = "CLIENT-CERT";
-
- /**
- * Forbidden constructor.
- */
- private AuthMethod()
- {
- super();
- }
-
- /**
- * Returns string representing correct auth method value.
- * @param s string to convert.
- * @return correct auth method value
- * @throws IllegalArgumentException if <b>s</b> is <b>null</b> or it contains unknown value.
- */
- public static String valueOf(final String s)
- {
- if (s != null)
- {
- if (s.equals(""))
- {
- return s;
- }
- if (s.equals(AuthMethod.BASIC))
- {
- return AuthMethod.BASIC;
- }
- if (s.equals(AuthMethod.CLIENT_CERT))
- {
- return AuthMethod.CLIENT_CERT;
- }
- log.warn("Non-standard auth method value: " + s);
- return s;
- }
-
- throw new IllegalArgumentException("Illegal auth method value: " + s);
- }
-
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,95 +0,0 @@
-/*
- * 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.spi.annotation;
-
-/**
- * The transportGuarantee specifies that the communication
- * between client and server should be NONE, INTEGRAL, or
- * CONFIDENTIAL. NONE means that the application does not require any
- * transport guarantees. A value of INTEGRAL means that the application
- * requires that the data sent between the client and server be sent in
- * such a way that it can't be changed in transit. CONFIDENTIAL means
- * that the application requires that the data be transmitted in a
- * fashion that prevents other entities from observing the contents of
- * the transmission. In most cases, the presence of the INTEGRAL or
- * CONFIDENTIAL flag will indicate that the use of SSL is required.
- *
- * @author ropalka(a)redhat.com
- */
-public final class TransportGuarantee
-{
-
- /**
- * Application does not require any transport guarantees.
- */
- public static final String NONE = "NONE";
- /**
- * Application requires that the data sent between the client and
- * server be sent in such a way that it can't be changed in transit.
- */
- public static final String INTEGRAL = "INTEGRAL";
- /**
- * Application requires that the data be transmitted in a fashion that
- * prevents other entities from observing the contents of the transmission.
- */
- public static final String CONFIDENTIAL = "CONFIDENTIAL";
-
- /**
- * Forbidden constructor.
- */
- private TransportGuarantee()
- {
- super();
- }
-
- /**
- * Returns string representing correct transport guarantee value.
- * @param s string to convert.
- * @return correct transport guarantee value
- * @throws IllegalArgumentException if <b>s</b> is <b>null</b> or it contains unknown value.
- */
- public static String valueOf(final String s)
- {
- if (s != null)
- {
- if (s.equals(""))
- {
- return s;
- }
- if (s.equals(TransportGuarantee.NONE))
- {
- return TransportGuarantee.NONE;
- }
- if (s.equals(TransportGuarantee.INTEGRAL))
- {
- return TransportGuarantee.INTEGRAL;
- }
- if (s.equals(TransportGuarantee.CONFIDENTIAL))
- {
- return TransportGuarantee.CONFIDENTIAL;
- }
- }
-
- throw new IllegalArgumentException("Illegal transport guarantee value: " + s);
- }
-
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,98 +0,0 @@
-/*
- * 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.spi.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Provides web context specific meta data to EJB based web service endpoints.
- *
- * @author thomas.diesler(a)jboss.org
- * @since 26-Apr-2005
- */
-@Retention(value = RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.TYPE })
-public @interface WebContext {
-
- /**
- * The contextRoot element specifies the context root that the web service endpoint is deployed to.
- * If it is not specified it will be derived from the deployment short name.
- *
- * Applies to server side port components only.
- */
- String contextRoot() default "";
-
- /**
- * The virtual hosts that the web service endpoint is deployed to.
- *
- * Applies to server side port components only.
- */
- String[] virtualHosts() default {};
-
- /**
- * Relative path that is appended to the contextRoot to form fully qualified
- * endpoint address for the web service endpoint.
- *
- * Applies to server side port components only.
- */
- String urlPattern() default "";
-
- /**
- * The authMethod is used to configure the authentication mechanism for the web service.
- * As a prerequisite to gaining access to any web service which are protected by an authorization
- * constraint, a user must have authenticated using the configured mechanism.
- *
- * Standard values for this element are "BASIC", or "CLIENT-CERT", custom authMethods may also
- * be specified.
- *
- * @see AuthMethod
- */
- String authMethod() default "";
-
- /**
- * The transportGuarantee specifies that the communication
- * between client and server should be NONE, INTEGRAL, or
- * CONFIDENTIAL. NONE means that the application does not require any
- * transport guarantees. A value of INTEGRAL means that the application
- * requires that the data sent between the client and server be sent in
- * such a way that it can't be changed in transit. CONFIDENTIAL means
- * that the application requires that the data be transmitted in a
- * fashion that prevents other entities from observing the contents of
- * the transmission. In most cases, the presence of the INTEGRAL or
- * CONFIDENTIAL flag will indicate that the use of SSL is required.
- *
- * @see TransportGuarantee
- */
- String transportGuarantee() default "";
-
- /**
- * A secure endpoint does not secure wsdl access by default.
- * Explicitly setting secureWSDLAccess overrides this behaviour.
- *
- * Protect access to WSDL. See http://jira.jboss.org/jira/browse/JBWS-723
- */
- boolean secureWSDLAccess() default false;
-
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/deployment/SecurityHandler.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/deployment/SecurityHandler.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/deployment/SecurityHandler.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,33 +0,0 @@
-/*
- * 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.spi.deployment;
-
-import org.dom4j.Element;
-
-public interface SecurityHandler
-{
- /** Add the security domain to jboss-web.xml */
- void addSecurityDomain(Element jbossWeb, Deployment dep);
-
- /** Add the security roles to web.xml */
- void addSecurityRoles(Element webApp, Deployment dep);
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.spi.util;
-
-import java.net.URL;
-
-import org.apache.log4j.helpers.Loader;
-
-/**
- *
- * @author alessio.soldano(a)jboss.com
- * @since 10-Jun-2010
- *
- */
-public class Log4JUtil
-{
- public static final String LOG4J_CONFIGURATION = "log4j.configuration";
- public static final String LOG4J_PROPERTIES = "log4j.properties";
-
- /**
- * Returns true if a log4j configuration can be found given the current environment.
- * See http://logging.apache.org/log4j/1.2/manual.html (Default Initialization Procedure)
- * @return
- */
- public static boolean isLog4jConfigurationAvailable()
- {
- String log4jConfiguration = System.getProperty(LOG4J_CONFIGURATION);
- String resource = log4jConfiguration != null ? log4jConfiguration : LOG4J_PROPERTIES;
- URL url = null;
- try
- {
- url = new URL(resource);
- }
- catch (Exception e1)
- {
- try
- {
- url = Loader.getResource(resource);
- }
- catch (Exception e2)
- {
- //ignore
- }
- }
- return url != null;
- }
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,220 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.spi.util;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import org.apache.log4j.Category;
-import org.apache.log4j.Priority;
-
-/**
- * An OutputStream that flushes out to a Category.<p>
- * A simple port of <a href="mailto://Jim.Moore@rocketmail.com">Jim Moore</a>'s
- * LoggingOutputStream contribution to log4j.
- *
- * Note that no data is written out to the Category until the stream is
- * flushed or closed.<p>
- *
- * Example:<pre>
- * // make sure everything sent to System.err is logged
- * System.setErr(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.WARN), true));
- *
- * // make sure everything sent to System.out is also logged
- * System.setOut(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.INFO), true));
- * </pre>
- *
- */
-public class Log4jOutputStream extends OutputStream
-{
- protected static final String LINE_SEPERATOR = System.getProperty("line.separator");
-
- /**
- * Used to maintain the contract of {@link #close()}.
- */
- protected boolean hasBeenClosed = false;
-
- /**
- * The internal buffer where data is stored.
- */
- protected byte[] buf;
-
- /**
- * The number of valid bytes in the buffer. This value is always
- * in the range <tt>0</tt> through <tt>buf.length</tt>; elements
- * <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid
- * byte data.
- */
- protected int count;
-
- /**
- * Remembers the size of the buffer for speed.
- */
- private int bufLength;
-
- /**
- * The default number of bytes in the buffer. =2048
- */
- public static final int DEFAULT_BUFFER_LENGTH = 2048;
-
- /**
- * The category to write to.
- */
- protected Category category;
-
- /**
- * The priority to use when writing to the Category.
- */
- protected Priority priority;
-
- @SuppressWarnings("unused")
- private Log4jOutputStream()
- {
- // illegal
- }
-
- /**
- * Creates the LoggingOutputStream to flush to the given Category.
- *
- * @param cat the Category to write to
- *
- * @param priority the Priority to use when writing to the Category
- *
- * @exception IllegalArgumentException
- * if cat == null or priority == null
- */
- public Log4jOutputStream(Category cat, Priority priority) throws IllegalArgumentException
- {
- if (cat == null)
- {
- throw new IllegalArgumentException("cat == null");
- }
- if (priority == null)
- {
- throw new IllegalArgumentException("priority == null");
- }
-
- this.priority = priority;
- category = cat;
- bufLength = DEFAULT_BUFFER_LENGTH;
- buf = new byte[DEFAULT_BUFFER_LENGTH];
- count = 0;
- }
-
- /**
- * Closes this output stream and releases any system resources
- * associated with this stream. The general contract of <code>close</code>
- * is that it closes the output stream. A closed stream cannot perform
- * output operations and cannot be reopened.
- */
- public void close()
- {
- flush();
- hasBeenClosed = true;
- }
-
- /**
- * Writes the specified byte to this output stream. The general
- * contract for <code>write</code> is that one byte is written
- * to the output stream. The byte to be written is the eight
- * low-order bits of the argument <code>b</code>. The 24
- * high-order bits of <code>b</code> are ignored.
- *
- * @param b the <code>byte</code> to write
- *
- * @exception IOException
- * if an I/O error occurs. In particular,
- * an <code>IOException</code> may be thrown if the
- * output stream has been closed.
- */
- public void write(final int b) throws IOException
- {
- if (hasBeenClosed)
- {
- throw new IOException("The stream has been closed.");
- }
-
- // don't log nulls
- if (b == 0)
- {
- return;
- }
-
- // would this be writing past the buffer?
- if (count == bufLength)
- {
- // grow the buffer
- final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
- final byte[] newBuf = new byte[newBufLength];
-
- System.arraycopy(buf, 0, newBuf, 0, bufLength);
-
- buf = newBuf;
- bufLength = newBufLength;
- }
-
- buf[count] = (byte)b;
- count++;
- }
-
- /**
- * Flushes this output stream and forces any buffered output bytes
- * to be written out. The general contract of <code>flush</code> is
- * that calling it is an indication that, if any bytes previously
- * written have been buffered by the implementation of the output
- * stream, such bytes should immediately be written to their
- * intended destination.
- */
- public void flush()
- {
- if (count == 0)
- {
- return;
- }
-
- // don't print out blank lines; flushing from PrintStream puts out these
- if (count == LINE_SEPERATOR.length())
- {
- if (((char)buf[0]) == LINE_SEPERATOR.charAt(0) && ((count == 1) || // <- Unix & Mac, -> Windows
- ((count == 2) && ((char)buf[1]) == LINE_SEPERATOR.charAt(1))))
- {
- reset();
- return;
- }
- }
-
- final byte[] theBytes = new byte[count];
-
- System.arraycopy(buf, 0, theBytes, 0, count);
-
- category.log(priority, new String(theBytes));
-
- reset();
- }
-
- private void reset()
- {
- // not resetting the buffer -- assuming that if it grew that it
- // will likely grow similarly again
- count = 0;
- }
-
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,142 +0,0 @@
-/*
- * 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.spi.util;
-
-import java.io.InputStream;
-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.
- *
- */
- static void setContextClassLoader(final ClassLoader cl)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- {
- Thread.currentThread().setContextClassLoader(cl);
- }
- else
- {
- AccessController.doPrivileged(new PrivilegedAction<Object>() {
- public Object run()
- {
- Thread.currentThread().setContextClassLoader(cl);
- return null;
- }
- });
- }
- }
-
- /**
- * Get resource as stream
- *
- * @param cl
- * @param filename
- * @return input stream
- * @throws PrivilegedActionException
- */
- static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- {
- return cl.getResourceAsStream(filename);
- }
- else
- {
- return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
- public InputStream run()
- {
- return cl.getResourceAsStream(filename);
- }
- });
- }
- }
-
- /**
- * Load a class using the provided classloader
- *
- * @param name
- * @return
- * @throws PrivilegedActionException
- */
- static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null)
- {
- return cl.loadClass(name);
- }
- else
- {
- return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
- public Class<?> run() throws PrivilegedActionException
- {
- try
- {
- return cl.loadClass(name);
- }
- catch (Exception e)
- {
- throw new PrivilegedActionException(e);
- }
- }
- });
- }
- }
-}
Deleted: spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,306 +0,0 @@
-/*
- * 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.spi.util;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collections;
-import java.util.Map;
-import java.util.Properties;
-import java.util.WeakHashMap;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Load a service class using this ordered lookup procedure
- *
- * @author Thomas.Diesler(a)jboss.com
- * @author alessio.soldano(a)jboss.com
- * @since 14-Dec-2006
- */
-public abstract class ServiceLoader
-{
- /**
- * A synchronized weak hash map that keeps factory names retrieved using Service API (META-INF/services/*) for each classloader.
- * Weak keys are used to remove entries when classloaders are garbage collected; values are service-property-name -> factory name maps.
- */
- private static Map<ClassLoader, Map<String, String>> serviceMap = Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<String, String>>());
-
- /**
- * This method uses the algorithm below using the JAXWS Provider as an example.
- *
- * 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then
- * its first line, if present, is used as the UTF-8 encoded name of the implementation class.
- *
- * 2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the
- * java.util.Properties.load(InputStream) method and it contains an entry whose key is
- * javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.
- *
- * 3. If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used
- * as the name of the implementation class.
- *
- * 4. Finally, a default implementation class name is used.
- */
- public static Object loadService(String propertyName, String defaultFactory)
- {
- Object factory = loadFromServices(propertyName, null);
- if (factory == null)
- {
- factory = loadFromPropertiesFile(propertyName, null);
- }
- if (factory == null)
- {
- factory = loadFromSystemProperty(propertyName, defaultFactory);
- }
- return factory;
- }
-
- /** Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
- */
- public static Object loadFromServices(String propertyName, String defaultFactory)
- {
- Object factory = null;
- String factoryName = null;
- ClassLoader loader = SecurityActions.getContextClassLoader();
-
- // Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
- String filename = "META-INF/services/" + propertyName;
-
- try
- {
- factoryName = getServiceNameUsingCache(loader, filename);
- if (factoryName != null)
- {
- Class factoryClass = SecurityActions.loadClass(loader, factoryName);
- factory = factoryClass.newInstance();
- }
- }
- catch (Throwable t)
- {
- throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
- }
-
- // Use the default factory implementation class.
- if (factory == null && defaultFactory != null)
- {
- factory = loadDefault(defaultFactory);
- }
-
- return factory;
- }
-
- private static String getServiceNameUsingCache(ClassLoader loader, String filename) throws IOException
- {
- Map<String, String> map = serviceMap.get(loader);
- if (map != null && map.containsKey(filename))
- {
- return map.get(filename);
- }
- else
- {
- if (map == null)
- {
- map = new ConcurrentHashMap<String, String>();
- serviceMap.put(loader, map);
- }
- InputStream inStream = SecurityActions.getResourceAsStream(loader, filename);
- String factoryName = null;
- if (inStream != null)
- {
- BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
- factoryName = br.readLine();
- br.close();
- map.put(filename, factoryName);
- }
- return factoryName;
- }
- }
-
- /** Use the system property
- */
- public static Object loadFromSystemProperty(String propertyName, String defaultFactory)
- {
- Object factory = null;
- ClassLoader loader = SecurityActions.getContextClassLoader();
-
- PrivilegedAction action = new PropertyAccessAction(propertyName);
- String factoryName = (String)AccessController.doPrivileged(action);
- if (factoryName != null)
- {
- try
- {
- //if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
- Class factoryClass = SecurityActions.loadClass(loader, factoryName);
- factory = factoryClass.newInstance();
- }
- catch (Throwable t)
- {
- throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
- }
- }
-
- // Use the default factory implementation class.
- if (factory == null && defaultFactory != null)
- {
- factory = loadDefault(defaultFactory);
- }
-
- return factory;
- }
-
- /**
- * Use the properties file "${java.home}/lib/jaxws.properties" in the JRE directory.
- * This configuration file is in standard java.util.Properties format and contains the
- * fully qualified name of the implementation class with the key being the system property defined above.
- */
- public static Object loadFromPropertiesFile(String propertyName, String defaultFactory)
- {
- Object factory = null;
- String factoryName = null;
- ClassLoader loader = SecurityActions.getContextClassLoader();
-
- // Use the properties file "lib/jaxm.properties" in the JRE directory.
- // This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
- PrivilegedAction action = new PropertyAccessAction("java.home");
- String javaHome = (String)AccessController.doPrivileged(action);
- File jaxmFile = new File(javaHome + "/lib/jaxws.properties");
- if ((Boolean)AccessController.doPrivileged(new PropertyFileExistAction(jaxmFile)))
- {
- try
- {
- action = new PropertyFileAccessAction(jaxmFile.getCanonicalPath());
- Properties jaxmProperties = (Properties)AccessController.doPrivileged(action);
- factoryName = jaxmProperties.getProperty(propertyName);
- if (factoryName != null)
- {
- //if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
- Class<?> factoryClass = SecurityActions.loadClass(loader, factoryName);
- factory = factoryClass.newInstance();
- }
- }
- catch (Throwable t)
- {
- throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
- }
- }
-
- // Use the default factory implementation class.
- if (factory == null && defaultFactory != null)
- {
- factory = loadDefault(defaultFactory);
- }
-
- return factory;
- }
-
- private static Object loadDefault(String defaultFactory)
- {
- Object factory = null;
- ClassLoader loader = SecurityActions.getContextClassLoader();
-
- // Use the default factory implementation class.
- if (defaultFactory != null)
- {
- try
- {
- //if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
- Class factoryClass = SecurityActions.loadClass(loader, defaultFactory);
- factory = factoryClass.newInstance();
- }
- catch (Throwable t)
- {
- throw new IllegalStateException("Failed to load: " + defaultFactory, t);
- }
- }
-
- return factory;
- }
-
- private static class PropertyAccessAction implements PrivilegedAction
- {
- private String name;
-
- PropertyAccessAction(String name)
- {
- this.name = name;
- }
-
- public Object run()
- {
- return System.getProperty(name);
- }
- }
-
- private static class PropertyFileAccessAction implements PrivilegedAction
- {
- private String filename;
-
- PropertyFileAccessAction(String filename)
- {
- this.filename = filename;
- }
-
- public Object run()
- {
- InputStream inStream = null;
- try
- {
- inStream = new FileInputStream(filename);
- Properties props = new Properties();
- props.load(inStream);
- return props;
- }
- catch (IOException ex)
- {
- throw new SecurityException("Cannot load properties: " + filename, ex);
- }
- finally
- {
- try
- {
- inStream.close();
- }
- catch (Exception e) {} //ignore
- }
- }
- }
-
- private static class PropertyFileExistAction implements PrivilegedAction
- {
- private File file;
-
- PropertyFileExistAction(File file)
- {
- this.file = file;
- }
-
- public Object run()
- {
- return file.exists();
- }
- }
-}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/util/URLLoaderAdapter.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.IOException;
-import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -36,7 +35,6 @@
import java.util.jar.JarFile;
import org.jboss.logging.Logger;
-import org.jboss.util.NotImplementedException;
import org.jboss.wsf.spi.deployment.UnifiedVirtualFile;
/**
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-/**
- * Test the WSConsumeTask.
- * This test needs to be executed in 'SPI_HOME/output/tests',
- * because it works with relative paths.
- *
- * @author Heiko.Braun(a)jboss.com
- */
-public class AntConsumeTestCase extends BuildFileTest
-{
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // cleanup events
- CmdConsumeTracker.LAST_EVENT = "";
-
- // enforce loading of the tracker implemenation
- System.setProperty("org.jboss.wsf.spi.tools.ConsumerFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory");
-
- configureProject("src/test/resources/smoke/tools/consume-test.xml");
- }
-
- public void testPlainInvocation()
- {
- executeTarget("plainInvocation");
- assertTrue("consume() not invoked", CmdConsumeTracker.LAST_EVENT.indexOf("consume") != -1);
- }
-
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class AntProvideTestCase extends BuildFileTest
-{
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // cleanup events
- CmdProvideTracker.LAST_EVENT = "";
-
- // enforce loading of the tracker implemenation
- System.setProperty("org.jboss.wsf.spi.tools.ProviderFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory");
-
- configureProject("src/test/resources/smoke/tools/provide-test.xml");
- }
-
- public void testPlainInvocation()
- {
- executeTarget("plainInvocation");
- assertTrue("provide() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("provide") != -1);
- }
-
- public void testIncludeWSDL()
- {
- executeTarget("includeWSDL");
- assertTrue("setGenerateWsdl() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setGenerateWsdl") != -1);
- }
-
- public void testExtraClasspath()
- {
- executeTarget("extraClasspath");
-
- }
-
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,543 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.jboss.test.wsf.spi.tools;
-
-import junit.framework.TestCase;
-import org.apache.tools.ant.BuildEvent;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.BuildListener;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.ProjectHelper;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.net.URL;
-
-/**
- * A BuildFileTest is a TestCase which executes targets from an Ant buildfile
- * for testing.
- *
- * This class provides a number of utility methods for particular build file
- * tests which extend this class.
- *
- * @author Apache Ant contributors
- */
-public abstract class BuildFileTest extends TestCase {
-
- protected Project project;
-
- private StringBuffer logBuffer;
- private StringBuffer fullLogBuffer;
- private StringBuffer outBuffer;
- private StringBuffer errBuffer;
- private BuildException buildException;
-
- /**
- * Default constructor for the BuildFileTest object.
- */
- public BuildFileTest() {
- super();
- }
-
- /**
- * Constructor for the BuildFileTest object.
- *
- * @param name string to pass up to TestCase constructor
- */
- public BuildFileTest(String name) {
- super(name);
- }
-
- /**
- * Automatically calls the target called "tearDown"
- * from the build file tested if it exits.
- *
- * This allows to use Ant tasks directly in the build file
- * to clean up after each test. Note that no "setUp" target
- * is automatically called, since it's trivial to have a
- * test target depend on it.
- */
- protected void tearDown() throws Exception {
- if (project == null) {
- /*
- * Maybe the BuildFileTest was subclassed and there is
- * no initialized project. So we could avoid getting a
- * NPE.
- * If there is an initialized project getTargets() does
- * not return null as it is initialized by an empty
- * HashSet.
- */
- return;
- }
- final String tearDown = "tearDown";
- if (project.getTargets().containsKey(tearDown)) {
- project.executeTarget(tearDown);
- }
- }
-
- /**
- * run a target, expect for any build exception
- *
- * @param target target to run
- * @param cause information string to reader of report
- */
- public void expectBuildException(String target, String cause) {
- expectSpecificBuildException(target, cause, null);
- }
-
- /**
- * Assert that only the given message has been logged with a
- * priority <= INFO when running the given target.
- */
- public void expectLog(String target, String log) {
- executeTarget(target);
- String realLog = getLog();
- assertEquals(log, realLog);
- }
-
- /**
- * Assert that the given substring is in the log messages.
- */
- public void assertLogContaining(String substring) {
- String realLog = getLog();
- assertTrue("expecting log to contain \"" + substring + "\" log was \""
- + realLog + "\"",
- realLog.indexOf(substring) >= 0);
- }
-
- /**
- * Assert that the given substring is in the output messages.
- * @since Ant1.7
- */
- public void assertOutputContaining(String substring) {
- String realOutput = getOutput();
- assertTrue("expecting output to contain \"" + substring
- + "\" output was \"" + realOutput + "\"",
- realOutput.indexOf(substring) >= 0);
- }
-
- /**
- * Assert that the given message has been logged with a priority
- * <= INFO when running the given target.
- */
- public void expectLogContaining(String target, String log) {
- executeTarget(target);
- assertLogContaining(log);
- }
-
- /**
- * Gets the log the BuildFileTest object.
- * Only valid if configureProject() has been called.
- *
- * @pre logBuffer!=null
- * @return The log value
- */
- public String getLog() {
- return logBuffer.toString();
- }
-
- /**
- * Assert that the given message has been logged with a priority
- * >= VERBOSE when running the given target.
- */
- public void expectDebuglog(String target, String log) {
- executeTarget(target);
- String realLog = getFullLog();
- assertEquals(log, realLog);
- }
-
- /**
- * Assert that the given substring is in the log messages.
- */
- public void assertDebuglogContaining(String substring) {
- String realLog = getFullLog();
- assertTrue("expecting debug log to contain \"" + substring
- + "\" log was \""
- + realLog + "\"",
- realLog.indexOf(substring) >= 0);
- }
-
- /**
- * Gets the log the BuildFileTest object.
- *
- * Only valid if configureProject() has been called.
- *
- * @pre fullLogBuffer!=null
- * @return The log value
- */
- public String getFullLog() {
- return fullLogBuffer.toString();
- }
-
- /**
- * execute the target, verify output matches expectations
- *
- * @param target target to execute
- * @param output output to look for
- */
- public void expectOutput(String target, String output) {
- executeTarget(target);
- String realOutput = getOutput();
- assertEquals(output, realOutput.trim());
- }
-
- /**
- * Executes the target, verify output matches expectations
- * and that we got the named error at the end
- *
- * @param target target to execute
- * @param output output to look for
- * @param error Description of Parameter
- */
- public void expectOutputAndError(String target, String output, String error) {
- executeTarget(target);
- String realOutput = getOutput();
- assertEquals(output, realOutput);
- String realError = getError();
- assertEquals(error, realError);
- }
-
- public String getOutput() {
- return cleanBuffer(outBuffer);
- }
-
- public String getError() {
- return cleanBuffer(errBuffer);
- }
-
- public BuildException getBuildException() {
- return buildException;
- }
-
- private String cleanBuffer(StringBuffer buffer) {
- StringBuffer cleanedBuffer = new StringBuffer();
- boolean cr = false;
- for (int i = 0; i < buffer.length(); i++) {
- char ch = buffer.charAt(i);
- if (ch == '\r') {
- cr = true;
- continue;
- }
-
- if (!cr) {
- cleanedBuffer.append(ch);
- } else {
- cleanedBuffer.append(ch);
- }
- }
- return cleanedBuffer.toString();
- }
-
- /**
- * Sets up to run the named project
- *
- * @param filename name of project file to run
- */
- public void configureProject(String filename) throws BuildException {
- configureProject(filename, Project.MSG_DEBUG);
- }
-
- /**
- * Sets up to run the named project
- *
- * @param filename name of project file to run
- */
- public void configureProject(String filename, int logLevel)
- throws BuildException {
- logBuffer = new StringBuffer();
- fullLogBuffer = new StringBuffer();
- project = new Project();
- project.init();
- File antFile = new File(System.getProperty("root"), filename);
- project.setUserProperty("ant.file" , antFile.getAbsolutePath());
- project.addBuildListener(new AntTestListener(logLevel));
- ProjectHelper.configureProject(project, antFile);
- }
-
- /**
- * Executes a target we have set up
- *
- * @pre configureProject has been called
- * @param targetName target to run
- */
- public void executeTarget(String targetName) {
- PrintStream sysOut = System.out;
- PrintStream sysErr = System.err;
- try {
- sysOut.flush();
- sysErr.flush();
- outBuffer = new StringBuffer();
- PrintStream out = new PrintStream(new AntOutputStream(outBuffer));
- System.setOut(out);
- errBuffer = new StringBuffer();
- PrintStream err = new PrintStream(new AntOutputStream(errBuffer));
- System.setErr(err);
- logBuffer = new StringBuffer();
- fullLogBuffer = new StringBuffer();
- buildException = null;
- project.executeTarget(targetName);
- } finally {
- System.setOut(sysOut);
- System.setErr(sysErr);
- }
-
- }
-
- /**
- * Get the project which has been configured for a test.
- *
- * @return the Project instance for this test.
- */
- public Project getProject() {
- return project;
- }
-
- /**
- * Gets the directory of the project.
- *
- * @return the base dir of the project
- */
- public File getProjectDir() {
- return project.getBaseDir();
- }
-
- /**
- * Runs a target, wait for a build exception.
- *
- * @param target target to run
- * @param cause information string to reader of report
- * @param msg the message value of the build exception we are waiting
- * for set to null for any build exception to be valid
- */
- public void expectSpecificBuildException(String target, String cause, String msg) {
- try {
- executeTarget(target);
- } catch (org.apache.tools.ant.BuildException ex) {
- buildException = ex;
- if ((null != msg) && (!ex.getMessage().equals(msg))) {
- fail("Should throw BuildException because '" + cause
- + "' with message '" + msg
- + "' (actual message '" + ex.getMessage() + "' instead)");
- }
- return;
- }
- fail("Should throw BuildException because: " + cause);
- }
-
- /**
- * run a target, expect an exception string
- * containing the substring we look for (case sensitive match)
- *
- * @param target target to run
- * @param cause information string to reader of report
- * @param contains substring of the build exception to look for
- */
- public void expectBuildExceptionContaining(String target, String cause, String contains) {
- try {
- executeTarget(target);
- } catch (org.apache.tools.ant.BuildException ex) {
- buildException = ex;
- if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) {
- fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)");
- }
- return;
- }
- fail("Should throw BuildException because: " + cause);
- }
-
- /**
- * call a target, verify property is as expected
- *
- * @param target build file target
- * @param property property name
- * @param value expected value
- */
- public void expectPropertySet(String target, String property, String value) {
- executeTarget(target);
- assertPropertyEquals(property, value);
- }
-
- /**
- * assert that a property equals a value; comparison is case sensitive.
- *
- * @param property property name
- * @param value expected value
- */
- public void assertPropertyEquals(String property, String value) {
- String result = project.getProperty(property);
- assertEquals("property " + property,value,result);
- }
-
- /**
- * assert that a property equals "true".
- *
- * @param property property name
- */
- public void assertPropertySet(String property) {
- assertPropertyEquals(property, "true");
- }
-
- /**
- * assert that a property is null.
- *
- * @param property property name
- */
- public void assertPropertyUnset(String property) {
- assertPropertyEquals(property, null);
- }
-
- /**
- * call a target, verify named property is "true".
- *
- * @param target build file target
- * @param property property name
- */
- public void expectPropertySet(String target, String property) {
- expectPropertySet(target, property, "true");
- }
-
- /**
- * Call a target, verify property is null.
- *
- * @param target build file target
- * @param property property name
- */
- public void expectPropertyUnset(String target, String property) {
- expectPropertySet(target, property, null);
- }
-
- /**
- * Retrieve a resource from the caller classloader to avoid
- * assuming a vm working directory. The resource path must be
- * relative to the package name or absolute from the root path.
- *
- * @param resource the resource to retrieve its url.
- * @throws junit.framework.AssertionFailedError if the resource is not found.
- */
- public URL getResource(String resource){
- URL url = getClass().getResource(resource);
- assertNotNull("Could not find resource :" + resource, url);
- return url;
- }
-
- /**
- * an output stream which saves stuff to our buffer.
- */
- private static class AntOutputStream extends java.io.OutputStream {
- private StringBuffer buffer;
-
- public AntOutputStream( StringBuffer buffer ) {
- this.buffer = buffer;
- }
-
- public void write(int b) {
- buffer.append((char)b);
- }
- }
-
- /**
- * Our own personal build listener.
- */
- private class AntTestListener implements BuildListener
- {
- private int logLevel;
-
- /**
- * Constructs a test listener which will ignore log events
- * above the given level.
- */
- public AntTestListener(int logLevel) {
- this.logLevel = logLevel;
- }
-
- /**
- * Fired before any targets are started.
- */
- public void buildStarted(BuildEvent event) {
- }
-
- /**
- * Fired after the last target has finished. This event
- * will still be thrown if an error occurred during the build.
- *
- * @see BuildEvent#getException()
- */
- public void buildFinished(BuildEvent event) {
- }
-
- /**
- * Fired when a target is started.
- *
- * @see BuildEvent#getTarget()
- */
- public void targetStarted(BuildEvent event) {
- System.out.println("targetStarted " + event.getTarget().getName());
- }
-
- /**
- * Fired when a target has finished. This event will
- * still be thrown if an error occurred during the build.
- *
- * @see BuildEvent#getException()
- */
- public void targetFinished(BuildEvent event) {
- System.out.println("targetFinished " + event.getTarget().getName());
- }
-
- /**
- * Fired when a task is started.
- *
- * @see BuildEvent#getTask()
- */
- public void taskStarted(BuildEvent event) {
- //System.out.println("taskStarted " + event.getTask().getTaskName());
- }
-
- /**
- * Fired when a task has finished. This event will still
- * be throw if an error occurred during the build.
- *
- * @see BuildEvent#getException()
- */
- public void taskFinished(BuildEvent event) {
- //System.out.println("taskFinished " + event.getTask().getTaskName());
- }
-
- /**
- * Fired whenever a message is logged.
- *
- * @see BuildEvent#getMessage()
- * @see BuildEvent#getPriority()
- */
- public void messageLogged(BuildEvent event) {
- if (event.getPriority() > logLevel) {
- // ignore event
- return;
- }
-
- if (event.getPriority() == Project.MSG_INFO ||
- event.getPriority() == Project.MSG_WARN ||
- event.getPriority() == Project.MSG_ERR) {
- logBuffer.append(event.getMessage());
- }
- fullLogBuffer.append(event.getMessage());
- }
- }
-
-}
-
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-// We just need to load it, therefore we skip the JSR 181 annotations here
-public class CalculatorBean
-{
- public int add(int a, int b)
- {
- return a+b;
- }
-
- public int subtract(int a, int b)
- {
- return a-b;
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,75 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.cmd.WSConsume;
-
-import java.security.Permission;
-
-import junit.framework.TestCase;
-
-/**
- * Test the command line interface to WSConsume.
- *
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdConsumeTestCase extends CommandlineTestBase
-{
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // cleanup events
- CmdConsumeTracker.LAST_EVENT = "";
-
- // enforce loading of the tracker implemenation
- System.setProperty(
- "org.jboss.wsf.spi.tools.ConsumerFactoryImpl",
- "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory"
- );
- }
-
- public void testInvalidBindingOption() throws Exception
- {
- executeCmd("-b", true);
- }
-
- public void testValidBindingOption() throws Exception
- {
- executeCmd("-b binding-file.xml Service.wsdl", false);
- assertTrue("setBindingFiles() not invoked", CmdConsumeTracker.LAST_EVENT.indexOf("setBindingFiles")!=-1);
- }
-
- public void testMissingOptions() throws Exception
- {
- executeCmd(null, true);
- }
-
- // TODO: add arbitrary combinations on a case by case basis
-
-
- void runDelegate(String[] args) throws Exception
- {
- WSConsume.main(args);
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,121 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.WSContractConsumer;
-
-import java.io.File;
-import java.io.PrintStream;
-import java.util.List;
-import java.net.URL;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdConsumeTracker extends WSContractConsumer
-{
- public static String LAST_EVENT = "";
-
- @Override
- public void setBindingFiles(List<File> bindingFiles)
- {
- LAST_EVENT += "setBindingFiles";
- }
-
- @Override
- public void setCatalog(File catalog)
- {
- LAST_EVENT += "setCatalog";
- }
-
- @Override
- public void setOutputDirectory(File directory)
- {
- LAST_EVENT += "setOutputDirectory";
- }
-
- @Override
- public void setSourceDirectory(File directory)
- {
- LAST_EVENT += "setSourceDirectory";
- }
-
- @Override
- public void setGenerateSource(boolean generateSource)
- {
- LAST_EVENT += "setGenerateSource";
- }
-
- @Override
- public void setTargetPackage(String targetPackage)
- {
- LAST_EVENT += "setTargetPackage";
- }
-
- @Override
- public void setWsdlLocation(String wsdlLocation)
- {
- LAST_EVENT += "setWsdlLocation";
- }
-
- @Override
- public void setMessageStream(PrintStream messageStream)
- {
- LAST_EVENT += "setMessageStream";
- }
-
- @Override
- public void setAdditionalCompilerClassPath(List<String> classPath)
- {
- LAST_EVENT += "setAdditionalCompilerClassPath";
- }
-
- @Override
- public void setAdditionalHeaders(boolean additionalHeaders)
- {
- LAST_EVENT += "setAdditionalHeaders";
- }
-
- @Override
- public void setTarget(String target)
- {
- LAST_EVENT += "setTarget";
- }
-
- @Override
- public void consume(URL wsdl)
- {
- LAST_EVENT += "consume";
- }
-
- @Override
- public void setExtension(boolean extension)
- {
- LAST_EVENT += "setExtension";
- }
-
- @Override
- public void setNoCompile(boolean nocompile)
- {
- LAST_EVENT += "setNoCompile";
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
-import org.jboss.wsf.spi.tools.WSContractConsumer;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdConsumeTrackerFactory implements WSContractConsumerFactory
-{
-
- public WSContractConsumer createConsumer()
- {
- return new CmdConsumeTracker();
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.cmd.WSProvide;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdProvideTestCase extends CommandlineTestBase
-{
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- // clear events
- CmdProvideTracker.LAST_EVENT = "";
-
- // enforce loading of the tracker implemenation
- System.setProperty(
- "org.jboss.wsf.spi.tools.ProviderFactoryImpl",
- "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory"
- );
- }
-
- /** <pre>
- * usage: WSProvideTask [options] <endpoint class name>
- * options:
- * -h, --help Show this help message
- * -k, --keep Keep/Generate Java source
- * -w, --wsdl Enable WSDL file generation
- * -c, --classpath=<path< The classpath that contains the endpoint
- * -o, --output=<directory> The directory to put generated artifacts
- * -r, --resource=<directory> The directory to put resource artifacts
- * -s, --source=<directory> The directory to put Java source
- * -q, --quiet Be somewhat more quiet
- * -t, --show-traces Show full exception stack traces
- * -l, --load-provider Load the provider and exit (debug utility)
- * </pre>
- * */
-
- public void testMissingOptions() throws Exception
- {
- executeCmd(null, true);
- }
-
- public void testValidOutputDir() throws Exception
- {
- executeCmd("-o outputDir org.jboss.test.wsf.spi.tools.CalculatorBean", false);
- assertTrue("setOutputDirectory() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setOutputDirectory")!=-1);
- }
-
- void runDelegate(String[] args) throws Exception
- {
- WSProvide.main(args);
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.WSContractProvider;
-
-import java.io.File;
-import java.io.PrintStream;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdProvideTracker extends WSContractProvider
-{
-
- public static String LAST_EVENT = "";
-
- public void setGenerateWsdl(boolean generateWsdl)
- {
- LAST_EVENT += "setGenerateWsdl";
- }
-
- public void setExtension(boolean extension)
- {
- LAST_EVENT += "setExtension";
- }
-
- public void setGenerateSource(boolean generateSource)
- {
- LAST_EVENT += "setGenerateSource";
- }
-
- public void setOutputDirectory(File directory)
- {
- LAST_EVENT += "setOutputDirectory";
- }
-
- public void setResourceDirectory(File directory)
- {
- LAST_EVENT += "setResourceDirectory";
- }
-
- public void setSourceDirectory(File directory)
- {
- LAST_EVENT += "setSourceDirectory";
- }
-
- public void setClassLoader(ClassLoader loader)
- {
- LAST_EVENT += "setClassLoader";
- }
-
- public void provide(String endpointClass)
- {
- LAST_EVENT += "provide";
- }
-
- public void provide(Class<?> endpointClass)
- {
- LAST_EVENT += "provide";
- }
-
- public void setMessageStream(PrintStream messageStream)
- {
- LAST_EVENT += "setMessageStream";
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import org.jboss.wsf.spi.tools.WSContractProviderFactory;
-import org.jboss.wsf.spi.tools.WSContractProvider;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public class CmdProvideTrackerFactory implements WSContractProviderFactory
-{
-
- public WSContractProvider createProvider(ClassLoader loader)
- {
- return new CmdProvideTracker();
- }
-}
Deleted: spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
===================================================================
--- spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java 2010-11-28 02:14:58 UTC (rev 13345)
+++ spi/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java 2010-11-28 02:20:30 UTC (rev 13346)
@@ -1,112 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.test.wsf.spi.tools;
-
-import junit.framework.TestCase;
-
-import java.security.Permission;
-
-/**
- * @author Heiko.Braun(a)jboss.com
- */
-public abstract class CommandlineTestBase extends TestCase
-{
- SecurityManager systemDefault = System.getSecurityManager();
- SecurityManager interceptor = new InterceptedSecurity();
-
- protected void swapSecurityManager()
- {
- if(System.getSecurityManager() instanceof InterceptedSecurity)
- System.setSecurityManager(systemDefault);
- else
- System.setSecurityManager(interceptor);
- }
-
- class InterceptedSecurity extends SecurityManager
- {
- private final SecurityManager parent = systemDefault;
-
- public void checkPermission(Permission perm)
- {
- if (parent != null)
- {
- parent.checkPermission(perm);
- }
- }
-
- public void checkExit(int status)
- {
- String msg = (status == 0) ? "Delegate did exit without errors" : "Delegate did exit with an error";
- throw new InterceptedExit(msg, status);
- }
- }
-
- static protected class InterceptedExit extends SecurityException
- {
- private int exitCode;
-
- public InterceptedExit(String s, int code)
- {
- super(s);
- this.exitCode = code;
- }
-
-
- public int getExitCode()
- {
- return exitCode;
- }
- }
-
- protected void executeCmd(String arguments, boolean expectedException) throws Exception
- {
- swapSecurityManager();
-
- String[] args = arguments!=null ? arguments.split("\\s"): new String[0];
- try
- {
- runDelegate(args);
- if(expectedException)
- fail("Did expect exception on args: " +args);
- }
- catch (CommandlineTestBase.InterceptedExit e)
- {
- boolean positivStatus = (e.getExitCode() == 0);
- if( (expectedException && positivStatus)
- || (!expectedException && !positivStatus) )
- {
- String s = expectedException ? "Did expect an exception, but " : "Did not expect an exception, but ";
- String s2 = positivStatus ? "status was positiv" : "status was negativ";
- throw new Exception(s+s2);
- }
-
- }
- finally
- {
- swapSecurityManager();
- }
- }
-
- // the actual tools execution
- abstract void runDelegate(String[] args) throws Exception;
-
-}
14 years, 1 month
JBossWS SVN: r13345 - in common/trunk: src/main/java/org/jboss/wsf and 14 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:14:58 -0500 (Sat, 27 Nov 2010)
New Revision: 13345
Added:
common/trunk/src/main/java/org/jboss/wsf/spi/
common/trunk/src/main/java/org/jboss/wsf/spi/tools/
common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/
common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/
common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
common/trunk/src/main/java/org/jboss/wsf/spi/util/
common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
common/trunk/src/test/java/org/jboss/test/wsf/
common/trunk/src/test/java/org/jboss/test/wsf/spi/
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
common/trunk/src/test/resources/
common/trunk/src/test/resources/smoke/
common/trunk/src/test/resources/smoke/tools/
common/trunk/src/test/resources/smoke/tools/consume-test.xml
common/trunk/src/test/resources/smoke/tools/provide-test.xml
Modified:
common/trunk/pom.xml
common/trunk/src/test/java/org/jboss/test/ws/common/ResourceLoaderAdapterTestCase.java
common/trunk/src/test/java/org/jboss/test/ws/common/URLLoaderAdapterTestCase.java
Log:
[JBWS-3115] Moving ant/cmd tools to jbossws-common, as they're actually not part of the spi, but "common" tools actually. WIP, package refactoring still pending
Modified: common/trunk/pom.xml
===================================================================
--- common/trunk/pom.xml 2010-11-28 02:10:52 UTC (rev 13344)
+++ common/trunk/pom.xml 2010-11-28 02:14:58 UTC (rev 13345)
@@ -28,11 +28,14 @@
<!-- Properties -->
<properties>
<jbossws.spi.version>2.0.0-SNAPSHOT</jbossws.spi.version>
+ <ant.version>1.7.1</ant.version>
+ <getopt.version>1.0.13</getopt.version>
<jboss.jaxbintros.version>1.0.2.GA</jboss.jaxbintros.version>
<jboss.common.core.version>2.2.14.GA</jboss.common.core.version>
<jboss.ejb.api.version>3.0.0.GA</jboss.ejb.api.version>
<jboss.microcontainer.version>2.0.8.GA</jboss.microcontainer.version>
<junit.version>3.8.2</junit.version>
+ <log4j.version>1.2.14</log4j.version>
<wsdl4j.version>1.6.2</wsdl4j.version>
<jms.api.version>1.0.0.Final</jms.api.version>
<jaxws.api.version>1.0.0.Final</jaxws.api.version>
@@ -62,7 +65,22 @@
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ <version>${ant.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>gnu-getopt</groupId>
+ <artifactId>getopt</artifactId>
+ <version>${getopt.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>${log4j.version}</version>
+ </dependency>
<!-- provided apis -->
<dependency>
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/AntTaskHelper.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.spi.tools.ant;
+
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.apache.tools.ant.types.Environment.Variable;
+
+/**
+ * Helper class for ANT tasks.
+ *
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+final class AntTaskHelper
+{
+ /**
+ * Constructor.
+ */
+ private AntTaskHelper()
+ {
+ // forbidden constructor
+ }
+
+ /**
+ * Converts array of JVM arguments to ANT SysProperties object.
+ *
+ * @param arguments to be converted.
+ * @return ANT SysProperties object.
+ */
+ static SysProperties toSystemProperties(final String[] arguments)
+ {
+ final SysProperties retVal = new SysProperties();
+
+ if (arguments != null && arguments.length != 0)
+ {
+ for (final String argument : arguments)
+ {
+ if (argument.startsWith("-D"))
+ {
+ Variable var = AntTaskHelper.toVariable(argument);
+ retVal.addVariable(var);
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ /**
+ * Converts JVM property of format -Dkey=value to ANT Variable object.
+ *
+ * @param argument to be converted
+ * @return ANT Variable object
+ */
+ private static Variable toVariable(final String argument)
+ {
+ final Variable retVal = new Variable();
+ final int equalSignIndex = argument.indexOf('=');
+
+ if (equalSignIndex == -1)
+ {
+ final String key = argument.substring(2);
+ retVal.setKey(key);
+ }
+ else
+ {
+ final String key = argument.substring(2, equalSignIndex);
+ retVal.setKey(key);
+ final String value = argument.substring(equalSignIndex + 1);
+ retVal.setValue(value);
+ }
+
+ return retVal;
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/SecurityActions.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,137 @@
+/*
+ * 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.spi.tools.ant;
+
+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());
+ }
+ }
+ }
+
+ /**
+ * Get classloader from class.
+ *
+ * @param clazz the class
+ * @return class's classloader
+ */
+ static ClassLoader getClassLoader(final Class<?> clazz)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return clazz.getClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return clazz.getClassLoader();
+ }
+ });
+ }
+ }
+
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSConsumeTask.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,366 @@
+/*
+ * 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.spi.tools.ant;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.ExecuteJava;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.FileSet;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * Ant task which consumes a Web Service contract.
+ *
+ * <table border="1">
+ * <tr align="left" BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><th>Attribute</th><th>Description</th><th>Default</th></tr>
+ * <tr><td>fork</td><td>Whether or not to run the generation task in a separate VM.</td><td>true</td></tr>
+ * <tr><td>keep</td><td>Keep/Enable Java source code generation.</td><td>false</td></tr>
+ * <tr><td>catalog</td><td> Oasis XML Catalog file for entity resolution</td><td>none</td></tr>
+ * <tr><td>package</td><td> The target Java package for generated code.</td><td>generated</td></tr>
+ * <tr><td>binding</td><td>A JAX-WS or JAXB binding file</td><td>none</td></tr>
+ * <tr><td>wsdlLocation</td><td>Value to use for @(a)WebService.wsdlLocation</td><td>generated</td></tr>
+ * <tr><td>destdir</td><td>The output directory for generated artifacts.</td><td>"output"</td></tr>
+ * <tr><td>sourcedestdir</td><td>The output directory for Java source.</td><td>value of destdir</td></tr>
+ * <tr><td>extension</td><td>Enable SOAP 1.2 binding extension.</td><td>false</td></tr>
+ * <tr><td>target</td><td>The JAX-WS specification target. Allowed values are 2.0, 2.1 and 2.2</td><td></td></tr>
+ * <tr><td>verbose</td><td>Enables more informational output about cmd progress.</td><td>false</td><tr>
+ * <tr><td>wsdl*</td><td>The WSDL file or URL</td><td>n/a</td><tr>
+ * </table>
+ * <b>* = required.</b>
+ *
+ * <p>Example:
+ *
+ * <pre>
+ * <WSConsumeTask
+ * fork="true"
+ * verbose="true"
+ * destdir="output"
+ * sourcedestdir="gen-src"
+ * keep="true"
+ * wsdllocation="handEdited.wsdl"
+ * wsdl="foo.wsdl">
+ * <binding dir="binding-files" includes="*.xml" excludes="bad.xml"/>
+ * </wsimport>
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class WSConsumeTask extends Task
+{
+ private CommandlineJava command = new CommandlineJava();
+ private String wsdl;
+ private File destdir;
+ private File sourcedestdir;
+ private List<File> bindingFiles = new ArrayList<File>();
+ private File catalog;
+ private String wsdlLocation;
+ private String targetPackage;
+ private boolean keep;
+ private boolean extension;
+ private boolean verbose;
+ private boolean fork;
+ private boolean debug;
+ private boolean nocompile;
+ private boolean additionalHeaders;
+ private String target;
+
+ // Not actually used right now
+ public void setDebug(boolean debug)
+ {
+ this.debug = debug;
+ }
+
+ public Commandline.Argument createJvmarg()
+ {
+ return command.createVmArgument();
+ }
+
+ public void setBinding(File bindingFile)
+ {
+ bindingFiles.add(bindingFile);
+ }
+
+ public void setCatalog(File catalog)
+ {
+ this.catalog = catalog;
+ }
+
+ public void setDestdir(File destdir)
+ {
+ this.destdir = destdir;
+ }
+
+ public void setFork(boolean fork)
+ {
+ this.fork = fork;
+ }
+
+ public void setKeep(boolean keep)
+ {
+ this.keep = keep;
+ }
+
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+
+ public void setAdditionalHeaders(boolean additionalHeaders)
+ {
+ this.additionalHeaders = additionalHeaders;
+ }
+
+ public void setSourcedestdir(File sourcedestdir)
+ {
+ this.sourcedestdir = sourcedestdir;
+ }
+
+ public void setTarget(String target)
+ {
+ this.target = target;
+ }
+
+ public void setPackage(String targetPackage)
+ {
+ this.targetPackage = targetPackage;
+ }
+
+ public void setVerbose(boolean verbose)
+ {
+ this.verbose = verbose;
+ }
+
+ public void setNoCompile(boolean nocompile)
+ {
+ this.nocompile = nocompile;
+ }
+
+ public void setWsdl(String wsdl)
+ {
+ this.wsdl = wsdl;
+ }
+
+ public void setWsdlLocation(String wsdlLocation)
+ {
+ this.wsdlLocation = wsdlLocation;
+ }
+
+ public void addConfiguredBinding(FileSet fs)
+ {
+ DirectoryScanner ds = fs.getDirectoryScanner(getProject());
+ File baseDir = ds.getBasedir();
+ for (String file : ds.getIncludedFiles())
+ {
+ bindingFiles.add(new File(baseDir, file));
+ }
+ }
+
+ public void executeNonForked()
+ {
+ ClassLoader prevCL = SecurityActions.getContextClassLoader();
+ ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+ SecurityActions.setContextClassLoader(antLoader);
+ try
+ {
+ WSContractConsumer consumer = WSContractConsumer.newInstance();
+ consumer.setGenerateSource(keep);
+ consumer.setExtension(extension);
+ consumer.setAdditionalHeaders(additionalHeaders);
+ consumer.setNoCompile(nocompile);
+ if (destdir != null)
+ consumer.setOutputDirectory(destdir);
+ if (sourcedestdir != null)
+ consumer.setSourceDirectory(sourcedestdir);
+ if (targetPackage != null)
+ consumer.setTargetPackage(targetPackage);
+ if (wsdlLocation != null)
+ consumer.setWsdlLocation(wsdlLocation);
+ if (catalog != null)
+ {
+ if (catalog.exists() && catalog.isFile())
+ {
+ consumer.setCatalog(catalog);
+ }
+ else
+ {
+ log("Catalog file not found: " + catalog, Project.MSG_WARN);
+ }
+ }
+ if (bindingFiles != null && bindingFiles.size() > 0)
+ consumer.setBindingFiles(bindingFiles);
+ if (target != null)
+ consumer.setTarget(target);
+
+ log("Consuming wsdl: " + wsdl, Project.MSG_INFO);
+
+ if (verbose)
+ {
+ consumer.setMessageStream(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
+ }
+
+ try
+ {
+ consumer.setAdditionalCompilerClassPath(getTaskClassPathStrings());
+ consumer.consume(wsdl);
+ }
+ catch (Throwable e)
+ {
+ throw new BuildException(e, getLocation());
+ }
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(prevCL);
+ }
+ }
+
+ public void execute() throws BuildException
+ {
+ if (wsdl == null)
+ throw new BuildException("The wsdl attribute must be specified!", getLocation());
+
+ if (fork)
+ executeForked();
+ else executeNonForked();
+ }
+
+ private Path getTaskClassPath()
+ {
+ // Why is everything in the Ant API a big hack???
+ ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
+ if (cl instanceof AntClassLoader)
+ {
+ return new Path(getProject(), ((AntClassLoader)cl).getClasspath());
+ }
+
+ return new Path(getProject());
+ }
+
+ private List<String> getTaskClassPathStrings()
+ {
+ // Why is everything in the Ant API a big hack???
+ List<String> strings = new ArrayList<String>();
+ ClassLoader cl = SecurityActions.getClassLoader(this.getClass());
+ if (cl instanceof AntClassLoader)
+ {
+ for (String string : ((AntClassLoader)cl).getClasspath().split(File.pathSeparator))
+ strings.add(string);
+ }
+
+ return strings;
+ }
+
+ private void executeForked() throws BuildException
+ {
+ command.setClassname(org.jboss.wsf.spi.tools.cmd.WSConsume.class.getName());
+
+ Path path = command.createClasspath(getProject());
+ path.append(getTaskClassPath());
+
+ if (keep)
+ command.createArgument().setValue("-k");
+
+ if (extension)
+ command.createArgument().setValue("-e");
+
+ if (additionalHeaders)
+ command.createArgument().setValue("-a");
+
+ for (File file : bindingFiles)
+ {
+ command.createArgument().setValue("-b");
+ command.createArgument().setFile(file);
+ }
+
+ if (catalog != null)
+ {
+ command.createArgument().setValue("-c");
+ command.createArgument().setFile(catalog);
+ }
+
+ if (targetPackage != null)
+ {
+ command.createArgument().setValue("-p");
+ command.createArgument().setValue(targetPackage);
+ }
+
+ if (wsdlLocation != null)
+ {
+ command.createArgument().setValue("-w");
+ command.createArgument().setValue(wsdlLocation);
+ }
+
+ if (destdir != null)
+ {
+ command.createArgument().setValue("-o");
+ command.createArgument().setFile(destdir);
+ }
+
+ if (sourcedestdir != null)
+ {
+ command.createArgument().setValue("-s");
+ command.createArgument().setFile(sourcedestdir);
+ }
+
+ if (target != null)
+ {
+ command.createArgument().setValue("-t");
+ command.createArgument().setValue(target);
+ }
+
+ if (verbose)
+ command.createArgument().setValue("-v");
+
+ command.createArgument().setValue(wsdl);
+
+ log("Consuming wsdl: " + wsdl, Project.MSG_INFO);
+
+ if (verbose)
+ log("Command invoked: " + command.getJavaCommand().toString());
+
+ ExecuteJava execute = new ExecuteJava();
+ execute.setClasspath(path);
+ execute.setJavaCommand(command.getJavaCommand());
+
+ // propagate system properties (useful e.g. for endorsing)
+ String[] arguments = command.getVmCommand().getArguments();
+ SysProperties properties = AntTaskHelper.toSystemProperties(arguments);
+ execute.setSystemProperties(properties);
+
+ if (execute.fork(this) != 0)
+ throw new BuildException("Could not invoke WSConsumeTask", getLocation());
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/ant/WSProvideTask.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,331 @@
+/*
+ * 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.spi.tools.ant;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.ExecuteJava;
+import org.apache.tools.ant.taskdefs.LogOutputStream;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+import org.apache.tools.ant.types.CommandlineJava.SysProperties;
+import org.apache.tools.ant.types.Environment.Variable;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.net.MalformedURLException;
+import java.util.StringTokenizer;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * Ant task which invokes provides a Web Service contract and portable JAX-WS wrapper classes.
+ *
+ * <table border="1">
+ * <tr align="left" BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><th>Attribute</th><th>Description</th><th>Default</th></tr>
+ * <tr><td>fork</td><td>Whether or not to run the generation task in a separate VM.</td><td>true</td></tr>
+ * <tr><td>keep</td><td>Keep/Enable Java source code generation.</td><td>false</td></tr>
+ * <tr><td>destdir</td><td>The output directory for generated artifacts.</td><td>"output"</td></tr>
+ * <tr><td>resourcedestdir</td><td>The output directory for resource artifacts (WSDL/XSD).</td><td>value of destdir</td></tr>
+ * <tr><td>sourcedestdir</td><td>The output directory for Java source.</td><td>value of destdir</td></tr>
+ * <tr><td>genwsdl</td><td>Whether or not to generate WSDL.</td><td>false</td><tr>
+ * <tr><td>extension</td><td>Enable SOAP 1.2 binding extension.</td><td>false</td></tr>
+ * <tr><td>verbose</td><td>Enables more informational output about cmd progress.</td><td>false</td><tr>
+ * <tr><td>sei</td><td>Service Endpoint Implementation.</td><td></td><tr>
+ * <tr><td>classpath</td><td>The classpath that contains the service endpoint implementation.</td><td>""</tr>
+ * </table>
+ * <b>* = required.</b>
+ *
+ * <p>Example:
+ *
+ * <pre>
+ * <target name="test-wsproivde" depends="init">
+ * <taskdef name="WSProvideTask" classname="org.jboss.wsf.spi.tools.ant.WSProvideTask">
+ * <classpath refid="core.classpath"/>
+ * </taskdef>
+ * <WSProvideTask
+ * fork="false"
+ * keep="true"
+ * destdir="out"
+ * resourcedestdir="out-resource"
+ * sourcedestdir="out-source"
+ * genwsdl="true"
+ * extension="true"
+ * verbose="true"
+ * sei="org.jboss.test.ws.jaxws.jsr181.soapbinding.DocWrappedServiceImpl">
+ * <classpath>
+ * <pathelement path="${tests.output.dir}/classes"/>
+ * </classpath>
+ * </WSProvideTask>
+ * </target>
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ * @author <a href="mailto:ropalka@redhat.com">Richard Opalka</a>
+ */
+public class WSProvideTask extends Task
+{
+ private Path classpath = new Path(getProject());
+ private CommandlineJava command = new CommandlineJava();
+ private String sei;
+ private File destdir;
+ private File resourcedestdir;
+ private File sourcedestdir;
+ private boolean keep;
+ private boolean extension;
+ private boolean genwsdl;
+ private boolean verbose;
+ private boolean fork;
+ private boolean debug;
+
+ // Not actually used right now
+ public void setDebug(boolean debug)
+ {
+ this.debug = debug;
+ }
+
+ public Commandline.Argument createJvmarg()
+ {
+ return command.createVmArgument();
+ }
+
+ public void setClasspath(Path classpath)
+ {
+ this.classpath = classpath;
+ }
+
+ public void setClasspathRef(Reference ref)
+ {
+ createClasspath().setRefid(ref);
+ }
+
+ public Path createClasspath()
+ {
+ return classpath;
+ }
+
+ public void setDestdir(File destdir)
+ {
+ this.destdir = destdir;
+ }
+
+ public void setExtension(boolean extension)
+ {
+ this.extension = extension;
+ }
+
+ public void setProtocol(String protocol)
+ {
+ if (protocol != null)
+ {
+ this.extension = protocol.toLowerCase().indexOf("Xsoap1.2") != -1;
+ }
+ }
+
+ public void setKeep(boolean keep)
+ {
+ this.keep = keep;
+ }
+
+ public void setSei(String sei)
+ {
+ this.sei = sei;
+ }
+
+ public void setFork(boolean fork)
+ {
+ this.fork = fork;
+ }
+
+ public void setResourcedestdir(File resourcedestdir)
+ {
+ this.resourcedestdir = resourcedestdir;
+ }
+
+ public void setSourcedestdir(File sourcedestdir)
+ {
+ this.sourcedestdir = sourcedestdir;
+ }
+
+ public void setVerbose(boolean verbose)
+ {
+ this.verbose = verbose;
+ }
+
+ public void setGenwsdl(boolean genwsdl)
+ {
+ this.genwsdl = genwsdl;
+ }
+
+ private ClassLoader getClasspathLoader(ClassLoader parent)
+ {
+ AntClassLoader antLoader = new AntClassLoader(parent, getProject(), classpath, false);
+
+ // It's necessary to wrap it into an URLLoader in order to extract that information
+ // within the actual provider impl.
+ // See SunRIProviderImpl for instance
+ List<URL> urls = new ArrayList<URL>();
+ StringTokenizer tok = new StringTokenizer(antLoader.getClasspath(), File.separator);
+ while(tok.hasMoreTokens())
+ {
+ try
+ {
+ String path = tok.nextToken();
+ if(!path.startsWith("file://"))
+ path = "file://"+path;
+
+ urls.add(new URL(path));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Failed to wrap classloader", e);
+ }
+
+ }
+
+ ClassLoader wrapper = new URLClassLoader(urls.toArray(new URL[0]), antLoader);
+ return wrapper;
+ }
+
+ public void executeNonForked()
+ {
+ ClassLoader prevCL = SecurityActions.getContextClassLoader();
+ ClassLoader antLoader = SecurityActions.getClassLoader(this.getClass());
+ SecurityActions.setContextClassLoader(antLoader);
+ try
+ {
+ WSContractProvider gen = WSContractProvider.newInstance(
+ getClasspathLoader(antLoader)
+ );
+ if (verbose)
+ gen.setMessageStream(new PrintStream(new LogOutputStream(this, Project.MSG_INFO)));
+ gen.setGenerateSource(keep);
+ gen.setGenerateWsdl(genwsdl);
+ gen.setExtension(extension);
+
+ if (destdir != null)
+ gen.setOutputDirectory(destdir);
+ if (resourcedestdir != null)
+ gen.setResourceDirectory(resourcedestdir);
+ if (sourcedestdir != null)
+ gen.setSourceDirectory(sourcedestdir);
+
+ log("Generating from endpoint: " + sei, Project.MSG_INFO);
+
+ gen.provide(sei);
+ }
+ catch(Throwable t)
+ {
+ throw new BuildException(t, getLocation());
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(prevCL);
+ }
+ }
+
+ public void execute() throws BuildException
+ {
+ if (sei == null)
+ throw new BuildException("The sei attribute must be specified!", getLocation());
+
+ if (fork)
+ executeForked();
+ else
+ executeNonForked();
+ }
+
+ private Path getTaskClassPath()
+ {
+ // Why is everything in the Ant API a big hack???
+ ClassLoader cl = this.getClass().getClassLoader();
+ if (cl instanceof AntClassLoader)
+ {
+ return new Path(getProject(), ((AntClassLoader)cl).getClasspath());
+ }
+
+ return new Path(getProject());
+ }
+
+ private void executeForked() throws BuildException
+ {
+ command.setClassname(org.jboss.wsf.spi.tools.cmd.WSProvide.class.getName());
+
+ Path path = command.createClasspath(getProject());
+ path.append(getTaskClassPath());
+ path.append(classpath);
+
+ if (keep)
+ command.createArgument().setValue("-k");
+
+ if (genwsdl)
+ command.createArgument().setValue("-w");
+
+ if (extension)
+ command.createArgument().setValue("-e");
+
+ if (destdir != null)
+ {
+ command.createArgument().setValue("-o");
+ command.createArgument().setFile(destdir);
+ }
+ if (resourcedestdir != null)
+ {
+ command.createArgument().setValue("-r");
+ command.createArgument().setFile(resourcedestdir);
+ }
+ if (sourcedestdir != null)
+ {
+ command.createArgument().setValue("-s");
+ command.createArgument().setFile(sourcedestdir);
+ }
+
+ if (!verbose)
+ command.createArgument().setValue("-q");
+
+ // Always dump traces
+ command.createArgument().setValue("-t");
+ command.createArgument().setValue(sei);
+
+ if (verbose)
+ log("Command invoked: " + command.getJavaCommand().toString());
+
+ ExecuteJava execute = new ExecuteJava();
+ execute.setClasspath(path);
+ execute.setJavaCommand(command.getJavaCommand());
+
+ // propagate system properties (useful e.g. for endorsing)
+ String[] arguments = command.getVmCommand().getArguments();
+ SysProperties properties = AntTaskHelper.toSystemProperties(arguments);
+ execute.setSystemProperties(properties);
+
+ if (execute.fork(this) != 0)
+ throw new BuildException("Could not invoke WSProvideTask", getLocation());
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/SecurityActions.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,118 @@
+/*
+ * 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.spi.tools.cmd;
+
+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();
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Get a system property
+ *
+ * @param name
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String name, final String defaultValue)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ else
+ {
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run()
+ {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSConsume.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,313 @@
+/*
+ * 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.spi.tools.cmd;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+import org.jboss.wsf.spi.util.Log4JUtil;
+import org.jboss.wsf.spi.util.Log4jOutputStream;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * WSConsumeTask is a cmd line tool that generates portable JAX-WS artifacts
+ * from a WSDL file.
+ *
+ * <pre>
+ * usage: WSConsumeTask [options] <wsdl-url>
+ * options:
+ * <table>
+ * <tr><td>-h, --help </td><td>Show this help message</td></tr>
+ * <tr><td>-b, --binding=<file> </td><td>One or more JAX-WS or JAXB binding files</td></tr>
+ * <tr><td>-k, --keep </td><td>Keep/Generate Java source</td></tr>
+ * <tr><td>-c, --catalog=<file> </td><td>Oasis XML Catalog file for entity resolution</td></tr>
+ * <tr><td>-p, --package=<name> </td><td>The target package for generated source</td></tr>
+ * <tr><td>-w, --wsdlLocation=<loc> </td><td>Value to use for @(a)WebService.wsdlLocation</td></tr>
+ * <tr><td>-o, --output=<directory> </td><td>The directory to put generated artifacts</td></tr>
+ * <tr><td>-s, --source=<directory> </td><td>The directory to put Java source</td></tr>
+ * <tr><td>-t, --target=<2.0|2.1|2.2></td><td>The target specification target</td></tr>
+ * <tr><td>-n, --nocompile </td><td>Do not compile generated sources</td></tr>
+ * <tr><td>-q, --quiet </td><td>Be somewhat more quiet</td></tr>
+ * <tr><td>-v, --verbose </td><td>Show full exception stack traces</td></tr>
+ * <tr><td>-l, --load-consumer </td><td>Load the consumer and exit (debug utility)</td></tr>
+ * <tr><td>-e, --extension </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ * <tr><td>-a, --additionalHeaders </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ * </table>
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public class WSConsume
+{
+ private List<File> bindingFiles = new ArrayList<File>();
+ private File outputDir = new File("output");
+ private boolean generateSource;
+ private File catalog;
+ private String targetPackage;
+ private String wsdlLocation;
+ private boolean quiet;
+ private boolean verbose;
+ private boolean loadConsumer;
+ private boolean extension;
+ private boolean additionalHeaders;
+ private boolean noCompile;
+ private File sourceDir;
+ private String target;
+
+ public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSConsume.class.getName());
+
+ public static void main(String[] args)
+ {
+ WSConsume importer = new WSConsume();
+ URL wsdl = importer.parseArguments(args);
+ System.exit(importer.importServices(wsdl));
+ }
+
+ private URL parseArguments(String[] args)
+ {
+ String shortOpts = "b:c:p:w:o:s:t:khqvlnea";
+ LongOpt[] longOpts =
+ {
+ new LongOpt("binding", LongOpt.REQUIRED_ARGUMENT, null, 'b'),
+ new LongOpt("catalog", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+ new LongOpt("package", LongOpt.REQUIRED_ARGUMENT, null, 'p'),
+ new LongOpt("wsdlLocation", LongOpt.REQUIRED_ARGUMENT, null, 'w'),
+ new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
+ new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+ new LongOpt("target", LongOpt.REQUIRED_ARGUMENT, null, 't'),
+ new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
+ new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+ new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
+ new LongOpt("verbose", LongOpt.NO_ARGUMENT, null, 'v'),
+ new LongOpt("nocompile", LongOpt.NO_ARGUMENT, null, 'n'),
+ new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
+ new LongOpt("additionalHeaders", LongOpt.NO_ARGUMENT, null, 'a'),
+ new LongOpt("load-consumer", LongOpt.NO_ARGUMENT, null, 'l'),
+ };
+
+ Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
+ int c;
+ while ((c = getopt.getopt()) != -1)
+ {
+ switch (c)
+ {
+ case 'b':
+ bindingFiles.add(new File(getopt.getOptarg()));
+ break;
+ case 'k':
+ generateSource = true;
+ break;
+ case 'c':
+ catalog = new File(getopt.getOptarg());
+ break;
+ case 'p':
+ targetPackage = getopt.getOptarg();
+ break;
+ case 'w':
+ wsdlLocation = getopt.getOptarg();
+ break;
+ case 'o':
+ outputDir = new File(getopt.getOptarg());
+ break;
+ case 's':
+ sourceDir = new File(getopt.getOptarg());
+ break;
+ case 't':
+ target = getopt.getOptarg();
+ break;
+ case 'q':
+ quiet = true;
+ break;
+ case 'v':
+ verbose = true;
+ break;
+ case 'l':
+ loadConsumer = true;
+ break;
+ case 'e':
+ extension = true;
+ break;
+ case 'a':
+ additionalHeaders = true;
+ break;
+ case 'n':
+ noCompile = true;
+ break;
+ case 'h':
+ printHelp();
+ System.exit(0);
+ case '?':
+ System.exit(1);
+ }
+ }
+
+ // debug output
+ if(loadConsumer)
+ {
+ WSContractConsumer importer = WSContractConsumer.newInstance();
+ System.out.println("WSContractConsumer instance: " + importer.getClass().getCanonicalName());
+ System.exit(0);
+ }
+
+ int wsdlPos = getopt.getOptind();
+ if (wsdlPos >= args.length)
+ {
+ System.err.println("Error: WSDL URL was not specified!");
+ printHelp();
+ System.exit(1);
+ }
+
+ URL url = null;
+ try
+ {
+ try
+ {
+ url = new URL(args[wsdlPos]);
+ }
+ catch (MalformedURLException e)
+ {
+ File file = new File(args[wsdlPos]);
+ url = file.toURI().toURL();
+ }
+ }
+ catch (MalformedURLException e)
+ {
+ System.err.println("Error: Invalid URI: " + args[wsdlPos]);
+ System.exit(1);
+ }
+
+ return url;
+ }
+
+
+ private int importServices(URL wsdl)
+ {
+ WSContractConsumer consumer = WSContractConsumer.newInstance();
+
+ consumer.setGenerateSource(generateSource);
+ consumer.setOutputDirectory(outputDir);
+ consumer.setExtension(extension);
+ consumer.setAdditionalHeaders(additionalHeaders);
+ if (sourceDir != null)
+ consumer.setSourceDirectory(sourceDir);
+
+ if (! quiet)
+ {
+ PrintStream ps;
+ if (Log4JUtil.isLog4jConfigurationAvailable())
+ {
+ ps = new PrintStream(new Log4jOutputStream(Logger.getLogger("WSConsume"), Level.INFO));
+ }
+ else
+ {
+ ps = System.out;
+ ps.println("Could not find log4j.xml configuration, logging to console.\n");
+ }
+ consumer.setMessageStream(ps);
+ }
+
+ if (catalog != null)
+ {
+ if (catalog.exists() && catalog.isFile())
+ {
+ consumer.setCatalog(catalog);
+ }
+ else
+ {
+ System.err.println("Warning: catalog file not found: " + catalog);
+ }
+ }
+
+ if (targetPackage != null)
+ consumer.setTargetPackage(targetPackage);
+
+ if (wsdlLocation != null)
+ consumer.setWsdlLocation(wsdlLocation);
+
+ if (bindingFiles != null && bindingFiles.size() > 0)
+ consumer.setBindingFiles(bindingFiles);
+
+ if(target!=null)
+ consumer.setTarget(target);
+
+ if (noCompile)
+ consumer.setNoCompile(noCompile);
+
+ try
+ {
+ consumer.consume(wsdl);
+ return 0;
+ }
+ catch (Throwable t)
+ {
+ System.err.println("Error: Could not import. (use --verbose to see full traces)");
+ if (!verbose)
+ {
+ String message = t.getMessage();
+ if (message == null)
+ message = t.getClass().getSimpleName();
+ System.err.println("Error: " + message);
+ }
+ else
+ {
+ t.printStackTrace(System.err);
+ }
+
+ }
+
+ return 1;
+ }
+
+ private static void printHelp()
+ {
+ PrintStream out = System.out;
+ out.println("WSConsumeTask is a cmd line tool that generates portable JAX-WS artifacts from a WSDL file.\n");
+ out.println("usage: " + PROGRAM_NAME + " [options] <wsdl-url>\n");
+ out.println("options: ");
+ out.println(" -h, --help Show this help message");
+ out.println(" -b, --binding=<file> One or more JAX-WS or JAXB binding files ");
+ out.println(" -k, --keep Keep/Generate Java source");
+ out.println(" -c --catalog=<file> Oasis XML Catalog file for entity resolution");
+ out.println(" -p --package=<name> The target package for generated source");
+ out.println(" -w --wsdlLocation=<loc> Value to use for @WebService.wsdlLocation");
+ out.println(" -o, --output=<directory> The directory to put generated artifacts");
+ out.println(" -s, --source=<directory> The directory to put Java source");
+ out.println(" -t, --target=<2.0|2.1|2.2> The JAX-WS specification target");
+ out.println(" -q, --quiet Be somewhat more quiet");
+ out.println(" -v, --verbose Show full exception stack traces");
+ out.println(" -l, --load-consumer Load the consumer and exit (debug utility)");
+ out.println(" -e, --extension Enable SOAP 1.2 binding extension");
+ out.println(" -a, --additionalHeaders Enable processing of implicit SOAP headers");
+ out.println(" -n, --nocompile Do not compile generated sources");
+ out.flush();
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/tools/cmd/WSProvide.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,268 @@
+/*
+ * 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.spi.tools.cmd;
+
+import gnu.getopt.Getopt;
+import gnu.getopt.LongOpt;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Level;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+import org.jboss.wsf.spi.util.Log4JUtil;
+import org.jboss.wsf.spi.util.Log4jOutputStream;
+
+/**
+ * WSProvideTask is a cmd line tool that generates portable JAX-WS artifacts
+ * for a service endpoint implementation.
+ *
+ * <pre>
+ * usage: WSProvideTask [options] <endpoint class name>
+ * options:
+ * <table>
+ * <tr><td>-h, --help </td><td>Show this help message</td></tr>
+ * <tr><td>-k, --keep </td><td>Keep/Generate Java source</td></tr>
+ * <tr><td>-w, --wsdl </td><td>Enable WSDL file generation</td></tr>
+ * <tr><td>-c, --classpath=<path< </td><td>The classpath that contains the endpoint</td></tr>
+ * <tr><td>-o, --output=<directory> </td><td>The directory to put generated artifacts</td></tr>
+ * <tr><td>-r, --resource=<directory></td><td>The directory to put resource artifacts</td></tr>
+ * <tr><td>-s, --source=<directory> </td><td>The directory to put Java source</td></tr>
+ * <tr><td>-q, --quiet </td><td>Be somewhat more quiet</td></tr>
+ * <tr><td>-t, --show-traces </td><td>Show full exception stack traces</td></tr>
+ * <tr><td>-l, --load-provider </td><td>Load the provider and exit (debug utility)</td></tr>
+ * <tr><td>-e, --extension </td><td>Enable SOAP 1.2 binding extension</td></tr>
+ * </pre>
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public class WSProvide
+{
+ private ClassLoader loader = SecurityActions.getContextClassLoader();
+ private File outputDir = new File("output");
+ private boolean generateSource;
+ private boolean generateWsdl;
+ private boolean extension;
+ private boolean quiet;
+ private boolean showTraces;
+ private boolean loadProvider;
+ private File resourceDir;
+ private File sourceDir;
+
+ public static final String PROGRAM_NAME = SecurityActions.getSystemProperty("program.name", WSProvide.class.getSimpleName());
+
+ public static void main(String[] args)
+ {
+ WSProvide generate = new WSProvide();
+ String endpoint = generate.parseArguments(args);
+ System.exit(generate.generate(endpoint));
+ }
+
+ private String parseArguments(String[] args)
+ {
+ String shortOpts = "hwko:r:s:c:qtle";
+ LongOpt[] longOpts =
+ {
+ new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
+ new LongOpt("wsdl", LongOpt.NO_ARGUMENT, null, 'w'),
+ new LongOpt("keep", LongOpt.NO_ARGUMENT, null, 'k'),
+ new LongOpt("output", LongOpt.REQUIRED_ARGUMENT, null, 'o'),
+ new LongOpt("resource", LongOpt.REQUIRED_ARGUMENT, null, 'r'),
+ new LongOpt("source", LongOpt.REQUIRED_ARGUMENT, null, 's'),
+ new LongOpt("classpath", LongOpt.REQUIRED_ARGUMENT, null, 'c'),
+ new LongOpt("quiet", LongOpt.NO_ARGUMENT, null, 'q'),
+ new LongOpt("show-traces", LongOpt.NO_ARGUMENT, null, 't'),
+ new LongOpt("load-provider", LongOpt.NO_ARGUMENT, null, 'l'),
+ new LongOpt("extension", LongOpt.NO_ARGUMENT, null, 'e'),
+ };
+
+ Getopt getopt = new Getopt(PROGRAM_NAME, args, shortOpts, longOpts);
+ int c;
+ while ((c = getopt.getopt()) != -1)
+ {
+ switch (c)
+ {
+ case 'k':
+ generateSource = true;
+ break;
+ case 's':
+ sourceDir = new File(getopt.getOptarg());
+ break;
+ case 'r':
+ resourceDir = new File(getopt.getOptarg());
+ break;
+ case 'w':
+ generateWsdl = true;
+ break;
+ case 't':
+ showTraces = true;
+ break;
+ case 'o':
+ outputDir = new File(getopt.getOptarg());
+ break;
+ case 'q':
+ quiet = true;
+ break;
+ case 'c':
+ processClassPath(getopt.getOptarg());
+ break;
+ case 'l':
+ loadProvider = true;
+ break;
+ case 'e':
+ extension = true;
+ break;
+ case 'h':
+ printHelp();
+ System.exit(0);
+ case '?':
+ System.exit(1);
+ }
+ }
+
+ // debug output
+ if(loadProvider)
+ {
+ WSContractProvider gen = WSContractProvider.newInstance(loader);
+ System.out.println("WSContractProvider instance: " + gen.getClass().getCanonicalName());
+ System.exit(0);
+ }
+
+ int endpointPos = getopt.getOptind();
+ if (endpointPos >= args.length)
+ {
+ System.err.println("Error: endpoint implementation was not specified!");
+ printHelp();
+ System.exit(1);
+ }
+
+ return args[endpointPos];
+ }
+
+
+ private int generate(String endpoint)
+ {
+ try
+ {
+ SecurityActions.loadClass(loader, endpoint);
+ }
+ catch (Exception e)
+ {
+ System.err.println("Error: Could not load class [" + endpoint + "]. Did you specify a valid --classpath?");
+ return 1;
+ }
+
+ WSContractProvider gen = WSContractProvider.newInstance(loader);
+ gen.setGenerateWsdl(generateWsdl);
+ gen.setGenerateSource(generateSource);
+ gen.setOutputDirectory(outputDir);
+ gen.setExtension(extension);
+ if (resourceDir != null)
+ gen.setResourceDirectory(resourceDir);
+ if (sourceDir != null)
+ gen.setSourceDirectory(sourceDir);
+
+ if (! quiet)
+ {
+ PrintStream ps;
+ if (Log4JUtil.isLog4jConfigurationAvailable())
+ {
+ ps = new PrintStream(new Log4jOutputStream(Logger.getLogger("WSProvide"), Level.INFO));
+ }
+ else
+ {
+ ps = System.out;
+ ps.println("Could not find log4j.xml configuration, logging to console.\n");
+ }
+ gen.setMessageStream(ps);
+ }
+
+ try
+ {
+ gen.provide(endpoint);
+ return 0;
+ }
+ catch (Throwable t)
+ {
+ System.err.println("Error: Could not generate. (use --show-traces to see full traces)");
+ if (!showTraces)
+ {
+ String message = t.getMessage();
+ if (message == null)
+ message = t.getClass().getSimpleName();
+ System.err.println("Error: " + message);
+ }
+ else
+ {
+ t.printStackTrace(System.err);
+ }
+
+ }
+
+ return 1;
+ }
+
+ private void processClassPath(String classPath)
+ {
+ String[] entries = classPath.split(File.pathSeparator);
+ List<URL> urls= new ArrayList<URL>(entries.length);
+ for (String entry : entries)
+ {
+ try
+ {
+ urls.add(new File(entry).toURI().toURL());
+ }
+ catch (MalformedURLException e)
+ {
+ System.err.println("Error: a classpath entry was malformed: " + entry);
+ }
+ }
+ loader = new URLClassLoader(urls.toArray(new URL[0]), loader);
+ }
+
+ private static void printHelp()
+ {
+ PrintStream out = System.out;
+ out.println("WSProvideTask generates portable JAX-WS artifacts for an endpoint implementation.\n");
+ out.println("usage: " + PROGRAM_NAME + " [options] <endpoint class name>\n");
+ out.println("options: ");
+ out.println(" -h, --help Show this help message");
+ out.println(" -k, --keep Keep/Generate Java source");
+ out.println(" -w, --wsdl Enable WSDL file generation");
+ out.println(" -c, --classpath=<path> The classpath that contains the endpoint");
+ out.println(" -o, --output=<directory> The directory to put generated artifacts");
+ out.println(" -r, --resource=<directory> The directory to put resource artifacts");
+ out.println(" -s, --source=<directory> The directory to put Java source");
+ out.println(" -e, --extension Enable SOAP 1.2 binding extension");
+ out.println(" -q, --quiet Be somewhat more quiet");
+ out.println(" -t, --show-traces Show full exception stack traces");
+ out.println(" -l, --load-provider Load the provider and exit (debug utility)");
+ out.flush();
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4JUtil.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.spi.util;
+
+import java.net.URL;
+
+import org.apache.log4j.helpers.Loader;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 10-Jun-2010
+ *
+ */
+public class Log4JUtil
+{
+ public static final String LOG4J_CONFIGURATION = "log4j.configuration";
+ public static final String LOG4J_PROPERTIES = "log4j.properties";
+
+ /**
+ * Returns true if a log4j configuration can be found given the current environment.
+ * See http://logging.apache.org/log4j/1.2/manual.html (Default Initialization Procedure)
+ * @return
+ */
+ public static boolean isLog4jConfigurationAvailable()
+ {
+ String log4jConfiguration = System.getProperty(LOG4J_CONFIGURATION);
+ String resource = log4jConfiguration != null ? log4jConfiguration : LOG4J_PROPERTIES;
+ URL url = null;
+ try
+ {
+ url = new URL(resource);
+ }
+ catch (Exception e1)
+ {
+ try
+ {
+ url = Loader.getResource(resource);
+ }
+ catch (Exception e2)
+ {
+ //ignore
+ }
+ }
+ return url != null;
+ }
+}
Added: common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java
===================================================================
--- common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java (rev 0)
+++ common/trunk/src/main/java/org/jboss/wsf/spi/util/Log4jOutputStream.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,220 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.spi.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import org.apache.log4j.Category;
+import org.apache.log4j.Priority;
+
+/**
+ * An OutputStream that flushes out to a Category.<p>
+ * A simple port of <a href="mailto://Jim.Moore@rocketmail.com">Jim Moore</a>'s
+ * LoggingOutputStream contribution to log4j.
+ *
+ * Note that no data is written out to the Category until the stream is
+ * flushed or closed.<p>
+ *
+ * Example:<pre>
+ * // make sure everything sent to System.err is logged
+ * System.setErr(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.WARN), true));
+ *
+ * // make sure everything sent to System.out is also logged
+ * System.setOut(new PrintStream(new LoggingOutputStream(Category.getRoot(), Priority.INFO), true));
+ * </pre>
+ *
+ */
+public class Log4jOutputStream extends OutputStream
+{
+ protected static final String LINE_SEPERATOR = System.getProperty("line.separator");
+
+ /**
+ * Used to maintain the contract of {@link #close()}.
+ */
+ protected boolean hasBeenClosed = false;
+
+ /**
+ * The internal buffer where data is stored.
+ */
+ protected byte[] buf;
+
+ /**
+ * The number of valid bytes in the buffer. This value is always
+ * in the range <tt>0</tt> through <tt>buf.length</tt>; elements
+ * <tt>buf[0]</tt> through <tt>buf[count-1]</tt> contain valid
+ * byte data.
+ */
+ protected int count;
+
+ /**
+ * Remembers the size of the buffer for speed.
+ */
+ private int bufLength;
+
+ /**
+ * The default number of bytes in the buffer. =2048
+ */
+ public static final int DEFAULT_BUFFER_LENGTH = 2048;
+
+ /**
+ * The category to write to.
+ */
+ protected Category category;
+
+ /**
+ * The priority to use when writing to the Category.
+ */
+ protected Priority priority;
+
+ @SuppressWarnings("unused")
+ private Log4jOutputStream()
+ {
+ // illegal
+ }
+
+ /**
+ * Creates the LoggingOutputStream to flush to the given Category.
+ *
+ * @param cat the Category to write to
+ *
+ * @param priority the Priority to use when writing to the Category
+ *
+ * @exception IllegalArgumentException
+ * if cat == null or priority == null
+ */
+ public Log4jOutputStream(Category cat, Priority priority) throws IllegalArgumentException
+ {
+ if (cat == null)
+ {
+ throw new IllegalArgumentException("cat == null");
+ }
+ if (priority == null)
+ {
+ throw new IllegalArgumentException("priority == null");
+ }
+
+ this.priority = priority;
+ category = cat;
+ bufLength = DEFAULT_BUFFER_LENGTH;
+ buf = new byte[DEFAULT_BUFFER_LENGTH];
+ count = 0;
+ }
+
+ /**
+ * Closes this output stream and releases any system resources
+ * associated with this stream. The general contract of <code>close</code>
+ * is that it closes the output stream. A closed stream cannot perform
+ * output operations and cannot be reopened.
+ */
+ public void close()
+ {
+ flush();
+ hasBeenClosed = true;
+ }
+
+ /**
+ * Writes the specified byte to this output stream. The general
+ * contract for <code>write</code> is that one byte is written
+ * to the output stream. The byte to be written is the eight
+ * low-order bits of the argument <code>b</code>. The 24
+ * high-order bits of <code>b</code> are ignored.
+ *
+ * @param b the <code>byte</code> to write
+ *
+ * @exception IOException
+ * if an I/O error occurs. In particular,
+ * an <code>IOException</code> may be thrown if the
+ * output stream has been closed.
+ */
+ public void write(final int b) throws IOException
+ {
+ if (hasBeenClosed)
+ {
+ throw new IOException("The stream has been closed.");
+ }
+
+ // don't log nulls
+ if (b == 0)
+ {
+ return;
+ }
+
+ // would this be writing past the buffer?
+ if (count == bufLength)
+ {
+ // grow the buffer
+ final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH;
+ final byte[] newBuf = new byte[newBufLength];
+
+ System.arraycopy(buf, 0, newBuf, 0, bufLength);
+
+ buf = newBuf;
+ bufLength = newBufLength;
+ }
+
+ buf[count] = (byte)b;
+ count++;
+ }
+
+ /**
+ * Flushes this output stream and forces any buffered output bytes
+ * to be written out. The general contract of <code>flush</code> is
+ * that calling it is an indication that, if any bytes previously
+ * written have been buffered by the implementation of the output
+ * stream, such bytes should immediately be written to their
+ * intended destination.
+ */
+ public void flush()
+ {
+ if (count == 0)
+ {
+ return;
+ }
+
+ // don't print out blank lines; flushing from PrintStream puts out these
+ if (count == LINE_SEPERATOR.length())
+ {
+ if (((char)buf[0]) == LINE_SEPERATOR.charAt(0) && ((count == 1) || // <- Unix & Mac, -> Windows
+ ((count == 2) && ((char)buf[1]) == LINE_SEPERATOR.charAt(1))))
+ {
+ reset();
+ return;
+ }
+ }
+
+ final byte[] theBytes = new byte[count];
+
+ System.arraycopy(buf, 0, theBytes, 0, count);
+
+ category.log(priority, new String(theBytes));
+
+ reset();
+ }
+
+ private void reset()
+ {
+ // not resetting the buffer -- assuming that if it grew that it
+ // will likely grow similarly again
+ count = 0;
+ }
+
+}
Modified: common/trunk/src/test/java/org/jboss/test/ws/common/ResourceLoaderAdapterTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/ws/common/ResourceLoaderAdapterTestCase.java 2010-11-28 02:10:52 UTC (rev 13344)
+++ common/trunk/src/test/java/org/jboss/test/ws/common/ResourceLoaderAdapterTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws.common;
-import java.io.File;
import java.util.List;
import junit.framework.TestCase;
Modified: common/trunk/src/test/java/org/jboss/test/ws/common/URLLoaderAdapterTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/ws/common/URLLoaderAdapterTestCase.java 2010-11-28 02:10:52 UTC (rev 13344)
+++ common/trunk/src/test/java/org/jboss/test/ws/common/URLLoaderAdapterTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws.common;
-import java.io.File;
import java.net.URL;
import java.util.List;
@@ -42,7 +41,7 @@
{
//Getting the SPI jar url
ClassLoader cl = UnifiedVirtualFile.class.getClassLoader();
- URL rootURL = getJarUrl(cl.getResource("org/jboss/wsf/spi/"));
+ URL rootURL = getJarUrl(cl.getResource("org/jboss/wsf/spi/deployment"));
assertNotNull(rootURL);
URLLoaderAdapter ula = new URLLoaderAdapter(rootURL);
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntConsumeTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+/**
+ * Test the WSConsumeTask.
+ * This test needs to be executed in 'SPI_HOME/output/tests',
+ * because it works with relative paths.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class AntConsumeTestCase extends BuildFileTest
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // cleanup events
+ CmdConsumeTracker.LAST_EVENT = "";
+
+ // enforce loading of the tracker implemenation
+ System.setProperty("org.jboss.wsf.spi.tools.ConsumerFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory");
+
+ configureProject("src/test/resources/smoke/tools/consume-test.xml");
+ }
+
+ public void testPlainInvocation()
+ {
+ executeTarget("plainInvocation");
+ assertTrue("consume() not invoked", CmdConsumeTracker.LAST_EVENT.indexOf("consume") != -1);
+ }
+
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/AntProvideTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class AntProvideTestCase extends BuildFileTest
+{
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // cleanup events
+ CmdProvideTracker.LAST_EVENT = "";
+
+ // enforce loading of the tracker implemenation
+ System.setProperty("org.jboss.wsf.spi.tools.ProviderFactoryImpl", "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory");
+
+ configureProject("src/test/resources/smoke/tools/provide-test.xml");
+ }
+
+ public void testPlainInvocation()
+ {
+ executeTarget("plainInvocation");
+ assertTrue("provide() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("provide") != -1);
+ }
+
+ public void testIncludeWSDL()
+ {
+ executeTarget("includeWSDL");
+ assertTrue("setGenerateWsdl() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setGenerateWsdl") != -1);
+ }
+
+ public void testExtraClasspath()
+ {
+ executeTarget("extraClasspath");
+
+ }
+
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/BuildFileTest.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,543 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import junit.framework.TestCase;
+import org.apache.tools.ant.BuildEvent;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.BuildListener;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.ProjectHelper;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.URL;
+
+/**
+ * A BuildFileTest is a TestCase which executes targets from an Ant buildfile
+ * for testing.
+ *
+ * This class provides a number of utility methods for particular build file
+ * tests which extend this class.
+ *
+ * @author Apache Ant contributors
+ */
+public abstract class BuildFileTest extends TestCase {
+
+ protected Project project;
+
+ private StringBuffer logBuffer;
+ private StringBuffer fullLogBuffer;
+ private StringBuffer outBuffer;
+ private StringBuffer errBuffer;
+ private BuildException buildException;
+
+ /**
+ * Default constructor for the BuildFileTest object.
+ */
+ public BuildFileTest() {
+ super();
+ }
+
+ /**
+ * Constructor for the BuildFileTest object.
+ *
+ * @param name string to pass up to TestCase constructor
+ */
+ public BuildFileTest(String name) {
+ super(name);
+ }
+
+ /**
+ * Automatically calls the target called "tearDown"
+ * from the build file tested if it exits.
+ *
+ * This allows to use Ant tasks directly in the build file
+ * to clean up after each test. Note that no "setUp" target
+ * is automatically called, since it's trivial to have a
+ * test target depend on it.
+ */
+ protected void tearDown() throws Exception {
+ if (project == null) {
+ /*
+ * Maybe the BuildFileTest was subclassed and there is
+ * no initialized project. So we could avoid getting a
+ * NPE.
+ * If there is an initialized project getTargets() does
+ * not return null as it is initialized by an empty
+ * HashSet.
+ */
+ return;
+ }
+ final String tearDown = "tearDown";
+ if (project.getTargets().containsKey(tearDown)) {
+ project.executeTarget(tearDown);
+ }
+ }
+
+ /**
+ * run a target, expect for any build exception
+ *
+ * @param target target to run
+ * @param cause information string to reader of report
+ */
+ public void expectBuildException(String target, String cause) {
+ expectSpecificBuildException(target, cause, null);
+ }
+
+ /**
+ * Assert that only the given message has been logged with a
+ * priority <= INFO when running the given target.
+ */
+ public void expectLog(String target, String log) {
+ executeTarget(target);
+ String realLog = getLog();
+ assertEquals(log, realLog);
+ }
+
+ /**
+ * Assert that the given substring is in the log messages.
+ */
+ public void assertLogContaining(String substring) {
+ String realLog = getLog();
+ assertTrue("expecting log to contain \"" + substring + "\" log was \""
+ + realLog + "\"",
+ realLog.indexOf(substring) >= 0);
+ }
+
+ /**
+ * Assert that the given substring is in the output messages.
+ * @since Ant1.7
+ */
+ public void assertOutputContaining(String substring) {
+ String realOutput = getOutput();
+ assertTrue("expecting output to contain \"" + substring
+ + "\" output was \"" + realOutput + "\"",
+ realOutput.indexOf(substring) >= 0);
+ }
+
+ /**
+ * Assert that the given message has been logged with a priority
+ * <= INFO when running the given target.
+ */
+ public void expectLogContaining(String target, String log) {
+ executeTarget(target);
+ assertLogContaining(log);
+ }
+
+ /**
+ * Gets the log the BuildFileTest object.
+ * Only valid if configureProject() has been called.
+ *
+ * @pre logBuffer!=null
+ * @return The log value
+ */
+ public String getLog() {
+ return logBuffer.toString();
+ }
+
+ /**
+ * Assert that the given message has been logged with a priority
+ * >= VERBOSE when running the given target.
+ */
+ public void expectDebuglog(String target, String log) {
+ executeTarget(target);
+ String realLog = getFullLog();
+ assertEquals(log, realLog);
+ }
+
+ /**
+ * Assert that the given substring is in the log messages.
+ */
+ public void assertDebuglogContaining(String substring) {
+ String realLog = getFullLog();
+ assertTrue("expecting debug log to contain \"" + substring
+ + "\" log was \""
+ + realLog + "\"",
+ realLog.indexOf(substring) >= 0);
+ }
+
+ /**
+ * Gets the log the BuildFileTest object.
+ *
+ * Only valid if configureProject() has been called.
+ *
+ * @pre fullLogBuffer!=null
+ * @return The log value
+ */
+ public String getFullLog() {
+ return fullLogBuffer.toString();
+ }
+
+ /**
+ * execute the target, verify output matches expectations
+ *
+ * @param target target to execute
+ * @param output output to look for
+ */
+ public void expectOutput(String target, String output) {
+ executeTarget(target);
+ String realOutput = getOutput();
+ assertEquals(output, realOutput.trim());
+ }
+
+ /**
+ * Executes the target, verify output matches expectations
+ * and that we got the named error at the end
+ *
+ * @param target target to execute
+ * @param output output to look for
+ * @param error Description of Parameter
+ */
+ public void expectOutputAndError(String target, String output, String error) {
+ executeTarget(target);
+ String realOutput = getOutput();
+ assertEquals(output, realOutput);
+ String realError = getError();
+ assertEquals(error, realError);
+ }
+
+ public String getOutput() {
+ return cleanBuffer(outBuffer);
+ }
+
+ public String getError() {
+ return cleanBuffer(errBuffer);
+ }
+
+ public BuildException getBuildException() {
+ return buildException;
+ }
+
+ private String cleanBuffer(StringBuffer buffer) {
+ StringBuffer cleanedBuffer = new StringBuffer();
+ boolean cr = false;
+ for (int i = 0; i < buffer.length(); i++) {
+ char ch = buffer.charAt(i);
+ if (ch == '\r') {
+ cr = true;
+ continue;
+ }
+
+ if (!cr) {
+ cleanedBuffer.append(ch);
+ } else {
+ cleanedBuffer.append(ch);
+ }
+ }
+ return cleanedBuffer.toString();
+ }
+
+ /**
+ * Sets up to run the named project
+ *
+ * @param filename name of project file to run
+ */
+ public void configureProject(String filename) throws BuildException {
+ configureProject(filename, Project.MSG_DEBUG);
+ }
+
+ /**
+ * Sets up to run the named project
+ *
+ * @param filename name of project file to run
+ */
+ public void configureProject(String filename, int logLevel)
+ throws BuildException {
+ logBuffer = new StringBuffer();
+ fullLogBuffer = new StringBuffer();
+ project = new Project();
+ project.init();
+ File antFile = new File(System.getProperty("root"), filename);
+ project.setUserProperty("ant.file" , antFile.getAbsolutePath());
+ project.addBuildListener(new AntTestListener(logLevel));
+ ProjectHelper.configureProject(project, antFile);
+ }
+
+ /**
+ * Executes a target we have set up
+ *
+ * @pre configureProject has been called
+ * @param targetName target to run
+ */
+ public void executeTarget(String targetName) {
+ PrintStream sysOut = System.out;
+ PrintStream sysErr = System.err;
+ try {
+ sysOut.flush();
+ sysErr.flush();
+ outBuffer = new StringBuffer();
+ PrintStream out = new PrintStream(new AntOutputStream(outBuffer));
+ System.setOut(out);
+ errBuffer = new StringBuffer();
+ PrintStream err = new PrintStream(new AntOutputStream(errBuffer));
+ System.setErr(err);
+ logBuffer = new StringBuffer();
+ fullLogBuffer = new StringBuffer();
+ buildException = null;
+ project.executeTarget(targetName);
+ } finally {
+ System.setOut(sysOut);
+ System.setErr(sysErr);
+ }
+
+ }
+
+ /**
+ * Get the project which has been configured for a test.
+ *
+ * @return the Project instance for this test.
+ */
+ public Project getProject() {
+ return project;
+ }
+
+ /**
+ * Gets the directory of the project.
+ *
+ * @return the base dir of the project
+ */
+ public File getProjectDir() {
+ return project.getBaseDir();
+ }
+
+ /**
+ * Runs a target, wait for a build exception.
+ *
+ * @param target target to run
+ * @param cause information string to reader of report
+ * @param msg the message value of the build exception we are waiting
+ * for set to null for any build exception to be valid
+ */
+ public void expectSpecificBuildException(String target, String cause, String msg) {
+ try {
+ executeTarget(target);
+ } catch (org.apache.tools.ant.BuildException ex) {
+ buildException = ex;
+ if ((null != msg) && (!ex.getMessage().equals(msg))) {
+ fail("Should throw BuildException because '" + cause
+ + "' with message '" + msg
+ + "' (actual message '" + ex.getMessage() + "' instead)");
+ }
+ return;
+ }
+ fail("Should throw BuildException because: " + cause);
+ }
+
+ /**
+ * run a target, expect an exception string
+ * containing the substring we look for (case sensitive match)
+ *
+ * @param target target to run
+ * @param cause information string to reader of report
+ * @param contains substring of the build exception to look for
+ */
+ public void expectBuildExceptionContaining(String target, String cause, String contains) {
+ try {
+ executeTarget(target);
+ } catch (org.apache.tools.ant.BuildException ex) {
+ buildException = ex;
+ if ((null != contains) && (ex.getMessage().indexOf(contains) == -1)) {
+ fail("Should throw BuildException because '" + cause + "' with message containing '" + contains + "' (actual message '" + ex.getMessage() + "' instead)");
+ }
+ return;
+ }
+ fail("Should throw BuildException because: " + cause);
+ }
+
+ /**
+ * call a target, verify property is as expected
+ *
+ * @param target build file target
+ * @param property property name
+ * @param value expected value
+ */
+ public void expectPropertySet(String target, String property, String value) {
+ executeTarget(target);
+ assertPropertyEquals(property, value);
+ }
+
+ /**
+ * assert that a property equals a value; comparison is case sensitive.
+ *
+ * @param property property name
+ * @param value expected value
+ */
+ public void assertPropertyEquals(String property, String value) {
+ String result = project.getProperty(property);
+ assertEquals("property " + property,value,result);
+ }
+
+ /**
+ * assert that a property equals "true".
+ *
+ * @param property property name
+ */
+ public void assertPropertySet(String property) {
+ assertPropertyEquals(property, "true");
+ }
+
+ /**
+ * assert that a property is null.
+ *
+ * @param property property name
+ */
+ public void assertPropertyUnset(String property) {
+ assertPropertyEquals(property, null);
+ }
+
+ /**
+ * call a target, verify named property is "true".
+ *
+ * @param target build file target
+ * @param property property name
+ */
+ public void expectPropertySet(String target, String property) {
+ expectPropertySet(target, property, "true");
+ }
+
+ /**
+ * Call a target, verify property is null.
+ *
+ * @param target build file target
+ * @param property property name
+ */
+ public void expectPropertyUnset(String target, String property) {
+ expectPropertySet(target, property, null);
+ }
+
+ /**
+ * Retrieve a resource from the caller classloader to avoid
+ * assuming a vm working directory. The resource path must be
+ * relative to the package name or absolute from the root path.
+ *
+ * @param resource the resource to retrieve its url.
+ * @throws junit.framework.AssertionFailedError if the resource is not found.
+ */
+ public URL getResource(String resource){
+ URL url = getClass().getResource(resource);
+ assertNotNull("Could not find resource :" + resource, url);
+ return url;
+ }
+
+ /**
+ * an output stream which saves stuff to our buffer.
+ */
+ private static class AntOutputStream extends java.io.OutputStream {
+ private StringBuffer buffer;
+
+ public AntOutputStream( StringBuffer buffer ) {
+ this.buffer = buffer;
+ }
+
+ public void write(int b) {
+ buffer.append((char)b);
+ }
+ }
+
+ /**
+ * Our own personal build listener.
+ */
+ private class AntTestListener implements BuildListener
+ {
+ private int logLevel;
+
+ /**
+ * Constructs a test listener which will ignore log events
+ * above the given level.
+ */
+ public AntTestListener(int logLevel) {
+ this.logLevel = logLevel;
+ }
+
+ /**
+ * Fired before any targets are started.
+ */
+ public void buildStarted(BuildEvent event) {
+ }
+
+ /**
+ * Fired after the last target has finished. This event
+ * will still be thrown if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void buildFinished(BuildEvent event) {
+ }
+
+ /**
+ * Fired when a target is started.
+ *
+ * @see BuildEvent#getTarget()
+ */
+ public void targetStarted(BuildEvent event) {
+ System.out.println("targetStarted " + event.getTarget().getName());
+ }
+
+ /**
+ * Fired when a target has finished. This event will
+ * still be thrown if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void targetFinished(BuildEvent event) {
+ System.out.println("targetFinished " + event.getTarget().getName());
+ }
+
+ /**
+ * Fired when a task is started.
+ *
+ * @see BuildEvent#getTask()
+ */
+ public void taskStarted(BuildEvent event) {
+ //System.out.println("taskStarted " + event.getTask().getTaskName());
+ }
+
+ /**
+ * Fired when a task has finished. This event will still
+ * be throw if an error occurred during the build.
+ *
+ * @see BuildEvent#getException()
+ */
+ public void taskFinished(BuildEvent event) {
+ //System.out.println("taskFinished " + event.getTask().getTaskName());
+ }
+
+ /**
+ * Fired whenever a message is logged.
+ *
+ * @see BuildEvent#getMessage()
+ * @see BuildEvent#getPriority()
+ */
+ public void messageLogged(BuildEvent event) {
+ if (event.getPriority() > logLevel) {
+ // ignore event
+ return;
+ }
+
+ if (event.getPriority() == Project.MSG_INFO ||
+ event.getPriority() == Project.MSG_WARN ||
+ event.getPriority() == Project.MSG_ERR) {
+ logBuffer.append(event.getMessage());
+ }
+ fullLogBuffer.append(event.getMessage());
+ }
+ }
+
+}
+
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CalculatorBean.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,36 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+// We just need to load it, therefore we skip the JSR 181 annotations here
+public class CalculatorBean
+{
+ public int add(int a, int b)
+ {
+ return a+b;
+ }
+
+ public int subtract(int a, int b)
+ {
+ return a-b;
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSConsume;
+
+/**
+ * Test the command line interface to WSConsume.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdConsumeTestCase extends CommandlineTestBase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // cleanup events
+ CmdConsumeTracker.LAST_EVENT = "";
+
+ // enforce loading of the tracker implemenation
+ System.setProperty(
+ "org.jboss.wsf.spi.tools.ConsumerFactoryImpl",
+ "org.jboss.test.wsf.spi.tools.CmdConsumeTrackerFactory"
+ );
+ }
+
+ public void testInvalidBindingOption() throws Exception
+ {
+ executeCmd("-b", true);
+ }
+
+ public void testValidBindingOption() throws Exception
+ {
+ executeCmd("-b binding-file.xml Service.wsdl", false);
+ assertTrue("setBindingFiles() not invoked", CmdConsumeTracker.LAST_EVENT.indexOf("setBindingFiles")!=-1);
+ }
+
+ public void testMissingOptions() throws Exception
+ {
+ executeCmd(null, true);
+ }
+
+ // TODO: add arbitrary combinations on a case by case basis
+
+
+ void runDelegate(String[] args) throws Exception
+ {
+ WSConsume.main(args);
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTracker.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.List;
+import java.net.URL;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdConsumeTracker extends WSContractConsumer
+{
+ public static String LAST_EVENT = "";
+
+ @Override
+ public void setBindingFiles(List<File> bindingFiles)
+ {
+ LAST_EVENT += "setBindingFiles";
+ }
+
+ @Override
+ public void setCatalog(File catalog)
+ {
+ LAST_EVENT += "setCatalog";
+ }
+
+ @Override
+ public void setOutputDirectory(File directory)
+ {
+ LAST_EVENT += "setOutputDirectory";
+ }
+
+ @Override
+ public void setSourceDirectory(File directory)
+ {
+ LAST_EVENT += "setSourceDirectory";
+ }
+
+ @Override
+ public void setGenerateSource(boolean generateSource)
+ {
+ LAST_EVENT += "setGenerateSource";
+ }
+
+ @Override
+ public void setTargetPackage(String targetPackage)
+ {
+ LAST_EVENT += "setTargetPackage";
+ }
+
+ @Override
+ public void setWsdlLocation(String wsdlLocation)
+ {
+ LAST_EVENT += "setWsdlLocation";
+ }
+
+ @Override
+ public void setMessageStream(PrintStream messageStream)
+ {
+ LAST_EVENT += "setMessageStream";
+ }
+
+ @Override
+ public void setAdditionalCompilerClassPath(List<String> classPath)
+ {
+ LAST_EVENT += "setAdditionalCompilerClassPath";
+ }
+
+ @Override
+ public void setAdditionalHeaders(boolean additionalHeaders)
+ {
+ LAST_EVENT += "setAdditionalHeaders";
+ }
+
+ @Override
+ public void setTarget(String target)
+ {
+ LAST_EVENT += "setTarget";
+ }
+
+ @Override
+ public void consume(URL wsdl)
+ {
+ LAST_EVENT += "consume";
+ }
+
+ @Override
+ public void setExtension(boolean extension)
+ {
+ LAST_EVENT += "setExtension";
+ }
+
+ @Override
+ public void setNoCompile(boolean nocompile)
+ {
+ LAST_EVENT += "setNoCompile";
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdConsumeTrackerFactory.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumerFactory;
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdConsumeTrackerFactory implements WSContractConsumerFactory
+{
+
+ public WSContractConsumer createConsumer()
+ {
+ return new CmdConsumeTracker();
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTestCase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.cmd.WSProvide;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdProvideTestCase extends CommandlineTestBase
+{
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // clear events
+ CmdProvideTracker.LAST_EVENT = "";
+
+ // enforce loading of the tracker implemenation
+ System.setProperty(
+ "org.jboss.wsf.spi.tools.ProviderFactoryImpl",
+ "org.jboss.test.wsf.spi.tools.CmdProvideTrackerFactory"
+ );
+ }
+
+ /** <pre>
+ * usage: WSProvideTask [options] <endpoint class name>
+ * options:
+ * -h, --help Show this help message
+ * -k, --keep Keep/Generate Java source
+ * -w, --wsdl Enable WSDL file generation
+ * -c, --classpath=<path< The classpath that contains the endpoint
+ * -o, --output=<directory> The directory to put generated artifacts
+ * -r, --resource=<directory> The directory to put resource artifacts
+ * -s, --source=<directory> The directory to put Java source
+ * -q, --quiet Be somewhat more quiet
+ * -t, --show-traces Show full exception stack traces
+ * -l, --load-provider Load the provider and exit (debug utility)
+ * </pre>
+ * */
+
+ public void testMissingOptions() throws Exception
+ {
+ executeCmd(null, true);
+ }
+
+ public void testValidOutputDir() throws Exception
+ {
+ executeCmd("-o outputDir org.jboss.test.wsf.spi.tools.CalculatorBean", false);
+ assertTrue("setOutputDirectory() not invoked", CmdProvideTracker.LAST_EVENT.indexOf("setOutputDirectory")!=-1);
+ }
+
+ void runDelegate(String[] args) throws Exception
+ {
+ WSProvide.main(args);
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTracker.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+import java.io.File;
+import java.io.PrintStream;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdProvideTracker extends WSContractProvider
+{
+
+ public static String LAST_EVENT = "";
+
+ public void setGenerateWsdl(boolean generateWsdl)
+ {
+ LAST_EVENT += "setGenerateWsdl";
+ }
+
+ public void setExtension(boolean extension)
+ {
+ LAST_EVENT += "setExtension";
+ }
+
+ public void setGenerateSource(boolean generateSource)
+ {
+ LAST_EVENT += "setGenerateSource";
+ }
+
+ public void setOutputDirectory(File directory)
+ {
+ LAST_EVENT += "setOutputDirectory";
+ }
+
+ public void setResourceDirectory(File directory)
+ {
+ LAST_EVENT += "setResourceDirectory";
+ }
+
+ public void setSourceDirectory(File directory)
+ {
+ LAST_EVENT += "setSourceDirectory";
+ }
+
+ public void setClassLoader(ClassLoader loader)
+ {
+ LAST_EVENT += "setClassLoader";
+ }
+
+ public void provide(String endpointClass)
+ {
+ LAST_EVENT += "provide";
+ }
+
+ public void provide(Class<?> endpointClass)
+ {
+ LAST_EVENT += "provide";
+ }
+
+ public void setMessageStream(PrintStream messageStream)
+ {
+ LAST_EVENT += "setMessageStream";
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CmdProvideTrackerFactory.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProviderFactory;
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public class CmdProvideTrackerFactory implements WSContractProviderFactory
+{
+
+ public WSContractProvider createProvider(ClassLoader loader)
+ {
+ return new CmdProvideTracker();
+ }
+}
Added: common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java
===================================================================
--- common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java (rev 0)
+++ common/trunk/src/test/java/org/jboss/test/wsf/spi/tools/CommandlineTestBase.java 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.wsf.spi.tools;
+
+import junit.framework.TestCase;
+
+import java.security.Permission;
+
+/**
+ * @author Heiko.Braun(a)jboss.com
+ */
+public abstract class CommandlineTestBase extends TestCase
+{
+ SecurityManager systemDefault = System.getSecurityManager();
+ SecurityManager interceptor = new InterceptedSecurity();
+
+ protected void swapSecurityManager()
+ {
+ if(System.getSecurityManager() instanceof InterceptedSecurity)
+ System.setSecurityManager(systemDefault);
+ else
+ System.setSecurityManager(interceptor);
+ }
+
+ class InterceptedSecurity extends SecurityManager
+ {
+ private final SecurityManager parent = systemDefault;
+
+ public void checkPermission(Permission perm)
+ {
+ if (parent != null)
+ {
+ parent.checkPermission(perm);
+ }
+ }
+
+ public void checkExit(int status)
+ {
+ String msg = (status == 0) ? "Delegate did exit without errors" : "Delegate did exit with an error";
+ throw new InterceptedExit(msg, status);
+ }
+ }
+
+ static protected class InterceptedExit extends SecurityException
+ {
+ private static final long serialVersionUID = 1L;
+ private int exitCode;
+
+ public InterceptedExit(String s, int code)
+ {
+ super(s);
+ this.exitCode = code;
+ }
+
+
+ public int getExitCode()
+ {
+ return exitCode;
+ }
+ }
+
+ protected void executeCmd(String arguments, boolean expectedException) throws Exception
+ {
+ swapSecurityManager();
+
+ String[] args = arguments!=null ? arguments.split("\\s"): new String[0];
+ try
+ {
+ runDelegate(args);
+ if(expectedException)
+ fail("Did expect exception on args: " +args);
+ }
+ catch (CommandlineTestBase.InterceptedExit e)
+ {
+ boolean positivStatus = (e.getExitCode() == 0);
+ if( (expectedException && positivStatus)
+ || (!expectedException && !positivStatus) )
+ {
+ String s = expectedException ? "Did expect an exception, but " : "Did not expect an exception, but ";
+ String s2 = positivStatus ? "status was positiv" : "status was negativ";
+ throw new Exception(s+s2);
+ }
+
+ }
+ finally
+ {
+ swapSecurityManager();
+ }
+ }
+
+ // the actual tools execution
+ abstract void runDelegate(String[] args) throws Exception;
+
+}
Added: common/trunk/src/test/resources/smoke/tools/consume-test.xml
===================================================================
--- common/trunk/src/test/resources/smoke/tools/consume-test.xml (rev 0)
+++ common/trunk/src/test/resources/smoke/tools/consume-test.xml 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+ <!--
+ An example build file that used to test the WSConsume Task
+ -->
+
+<project name="consume-test" basedir=".">
+
+ <property name="spi.dir" value="@SPI_DIR@"/>
+
+ <!-- Define the JAX-WS wsconsume task -->
+ <taskdef name="wsconsume" classname="org.jboss.wsf.spi.tools.ant.WSConsumeTask">
+ <classpath>
+ <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
+ </classpath>
+ </taskdef>
+
+ <target name="plainInvocation">
+ <wsconsume wsdl="Service.wsdl" verbose="true"/>
+ </target>
+
+</project>
\ No newline at end of file
Added: common/trunk/src/test/resources/smoke/tools/provide-test.xml
===================================================================
--- common/trunk/src/test/resources/smoke/tools/provide-test.xml (rev 0)
+++ common/trunk/src/test/resources/smoke/tools/provide-test.xml 2010-11-28 02:14:58 UTC (rev 13345)
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ An example build file that used to test the WSConsume Task
+-->
+
+<project name="provide-test" basedir=".">
+
+ <property name="spi.dir" value="@SPI_DIR@"/>
+
+ <!-- Define the JAX-WS wsconsume task -->
+ <taskdef name="wsprovide" classname="org.jboss.wsf.spi.tools.ant.WSProvideTask">
+ <classpath>
+ <pathelement location="${spi.dir}/output/lib/jbossws-spi.jar"/>
+ </classpath>
+ </taskdef>
+
+ <target name="plainInvocation">
+ <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
+ </target>
+
+ <target name="includeWSDL">
+ <wsprovide genwsdl="true" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean"/>
+ </target>
+
+ <target name="extraClasspath">
+ <wsprovide genwsdl="false" sei="org.jboss.test.wsf.spi.smoke.tools.CalculatorBean">
+ <classpath>
+ <pathelement location="${spi.dir}/output/test/classes"/>
+ </classpath>
+ </wsprovide>
+ </target>
+</project>
\ No newline at end of file
14 years, 1 month
JBossWS SVN: r13344 - api and 15 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 21:10:52 -0500 (Sat, 27 Nov 2010)
New Revision: 13344
Added:
api/
api/branches/
api/tags/
api/trunk/
api/trunk/pom.xml
api/trunk/src/
api/trunk/src/main/
api/trunk/src/main/java/
api/trunk/src/main/java/org/
api/trunk/src/main/java/org/jboss/
api/trunk/src/main/java/org/jboss/wsf/
api/trunk/src/main/java/org/jboss/wsf/spi/
api/trunk/src/main/java/org/jboss/wsf/spi/annotation/
api/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java
api/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java
api/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java
api/trunk/src/main/java/org/jboss/wsf/spi/binding/
api/trunk/src/main/java/org/jboss/wsf/spi/binding/BindingCustomization.java
api/trunk/src/main/java/org/jboss/wsf/spi/binding/JAXBBindingCustomization.java
api/trunk/src/main/java/org/jboss/wsf/spi/management/
api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/
api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/Record.java
api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordFilter.java
api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordGroupAssociation.java
api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordProcessor.java
api/trunk/src/main/java/org/jboss/wsf/spi/tools/
api/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java
api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java
api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumerFactory.java
api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProviderFactory.java
api/trunk/src/main/java/org/jboss/wsf/spi/util/
api/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
api/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
api/trunk/src/test/
api/trunk/src/test/java/
api/trunk/src/test/resources/
Log:
[JBWS-2709] Starting factoring public api out of jbossws-spi
Added: api/trunk/pom.xml
===================================================================
--- api/trunk/pom.xml (rev 0)
+++ api/trunk/pom.xml 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,57 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <name>JBoss Web Services - API</name>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-api</artifactId>
+ <packaging>jar</packaging>
+ <description>JBossWS API</description>
+
+ <version>1.0.0-SNAPSHOT</version>
+
+ <!-- Parent -->
+ <parent>
+ <groupId>org.jboss.ws</groupId>
+ <artifactId>jbossws-parent</artifactId>
+ <version>1.0.9.GA</version>
+ </parent>
+
+ <!-- Source Control Management -->
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossws/api/trunk</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossws/api/trunk</developerConnection>
+ <url>http://fisheye.jboss.com/viewrep/JBossWS/api/trunk</url>
+ </scm>
+
+ <properties>
+ <jboss-logging-spi.version>2.0.5.GA</jboss-logging-spi.version>
+ </properties>
+
+ <!-- Dependencies -->
+ <dependencies>
+
+ <!-- provided apis -->
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ <version>${jboss-logging-spi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <!-- Plugins -->
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-8</version>
+ <configuration>
+ <scmCommentPrefix>[${jira.issue}] :</scmCommentPrefix>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: api/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/annotation/AuthMethod.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,83 @@
+/*
+ * 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.spi.annotation;
+
+import org.jboss.logging.Logger;
+
+/**
+ * The authMethod is used to configure the authentication mechanism for the web service.
+ * As a prerequisite to gaining access to any web service which are protected by an
+ * authorization constraint, a user must have authenticated using the configured mechanism.
+ *
+ * @author ropalka(a)redhat.com
+ */
+public final class AuthMethod
+{
+ private static final Logger log = Logger.getLogger(AuthMethod.class);
+
+ /**
+ * Basic authentication.
+ */
+ public static final String BASIC = "BASIC";
+ /**
+ * Client certificate based authentication.
+ */
+ public static final String CLIENT_CERT = "CLIENT-CERT";
+
+ /**
+ * Forbidden constructor.
+ */
+ private AuthMethod()
+ {
+ super();
+ }
+
+ /**
+ * Returns string representing correct auth method value.
+ * @param s string to convert.
+ * @return correct auth method value
+ * @throws IllegalArgumentException if <b>s</b> is <b>null</b> or it contains unknown value.
+ */
+ public static String valueOf(final String s)
+ {
+ if (s != null)
+ {
+ if (s.equals(""))
+ {
+ return s;
+ }
+ if (s.equals(AuthMethod.BASIC))
+ {
+ return AuthMethod.BASIC;
+ }
+ if (s.equals(AuthMethod.CLIENT_CERT))
+ {
+ return AuthMethod.CLIENT_CERT;
+ }
+ log.warn("Non-standard auth method value: " + s);
+ return s;
+ }
+
+ throw new IllegalArgumentException("Illegal auth method value: " + s);
+ }
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/annotation/TransportGuarantee.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,95 @@
+/*
+ * 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.spi.annotation;
+
+/**
+ * The transportGuarantee specifies that the communication
+ * between client and server should be NONE, INTEGRAL, or
+ * CONFIDENTIAL. NONE means that the application does not require any
+ * transport guarantees. A value of INTEGRAL means that the application
+ * requires that the data sent between the client and server be sent in
+ * such a way that it can't be changed in transit. CONFIDENTIAL means
+ * that the application requires that the data be transmitted in a
+ * fashion that prevents other entities from observing the contents of
+ * the transmission. In most cases, the presence of the INTEGRAL or
+ * CONFIDENTIAL flag will indicate that the use of SSL is required.
+ *
+ * @author ropalka(a)redhat.com
+ */
+public final class TransportGuarantee
+{
+
+ /**
+ * Application does not require any transport guarantees.
+ */
+ public static final String NONE = "NONE";
+ /**
+ * Application requires that the data sent between the client and
+ * server be sent in such a way that it can't be changed in transit.
+ */
+ public static final String INTEGRAL = "INTEGRAL";
+ /**
+ * Application requires that the data be transmitted in a fashion that
+ * prevents other entities from observing the contents of the transmission.
+ */
+ public static final String CONFIDENTIAL = "CONFIDENTIAL";
+
+ /**
+ * Forbidden constructor.
+ */
+ private TransportGuarantee()
+ {
+ super();
+ }
+
+ /**
+ * Returns string representing correct transport guarantee value.
+ * @param s string to convert.
+ * @return correct transport guarantee value
+ * @throws IllegalArgumentException if <b>s</b> is <b>null</b> or it contains unknown value.
+ */
+ public static String valueOf(final String s)
+ {
+ if (s != null)
+ {
+ if (s.equals(""))
+ {
+ return s;
+ }
+ if (s.equals(TransportGuarantee.NONE))
+ {
+ return TransportGuarantee.NONE;
+ }
+ if (s.equals(TransportGuarantee.INTEGRAL))
+ {
+ return TransportGuarantee.INTEGRAL;
+ }
+ if (s.equals(TransportGuarantee.CONFIDENTIAL))
+ {
+ return TransportGuarantee.CONFIDENTIAL;
+ }
+ }
+
+ throw new IllegalArgumentException("Illegal transport guarantee value: " + s);
+ }
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/annotation/WebContext.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,98 @@
+/*
+ * 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.spi.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Provides web context specific meta data to EJB based web service endpoints.
+ *
+ * @author thomas.diesler(a)jboss.org
+ * @since 26-Apr-2005
+ */
+@Retention(value = RetentionPolicy.RUNTIME)
+@Target(value = { ElementType.TYPE })
+public @interface WebContext {
+
+ /**
+ * The contextRoot element specifies the context root that the web service endpoint is deployed to.
+ * If it is not specified it will be derived from the deployment short name.
+ *
+ * Applies to server side port components only.
+ */
+ String contextRoot() default "";
+
+ /**
+ * The virtual hosts that the web service endpoint is deployed to.
+ *
+ * Applies to server side port components only.
+ */
+ String[] virtualHosts() default {};
+
+ /**
+ * Relative path that is appended to the contextRoot to form fully qualified
+ * endpoint address for the web service endpoint.
+ *
+ * Applies to server side port components only.
+ */
+ String urlPattern() default "";
+
+ /**
+ * The authMethod is used to configure the authentication mechanism for the web service.
+ * As a prerequisite to gaining access to any web service which are protected by an authorization
+ * constraint, a user must have authenticated using the configured mechanism.
+ *
+ * Standard values for this element are "BASIC", or "CLIENT-CERT", custom authMethods may also
+ * be specified.
+ *
+ * @see AuthMethod
+ */
+ String authMethod() default "";
+
+ /**
+ * The transportGuarantee specifies that the communication
+ * between client and server should be NONE, INTEGRAL, or
+ * CONFIDENTIAL. NONE means that the application does not require any
+ * transport guarantees. A value of INTEGRAL means that the application
+ * requires that the data sent between the client and server be sent in
+ * such a way that it can't be changed in transit. CONFIDENTIAL means
+ * that the application requires that the data be transmitted in a
+ * fashion that prevents other entities from observing the contents of
+ * the transmission. In most cases, the presence of the INTEGRAL or
+ * CONFIDENTIAL flag will indicate that the use of SSL is required.
+ *
+ * @see TransportGuarantee
+ */
+ String transportGuarantee() default "";
+
+ /**
+ * A secure endpoint does not secure wsdl access by default.
+ * Explicitly setting secureWSDLAccess overrides this behaviour.
+ *
+ * Protect access to WSDL. See http://jira.jboss.org/jira/browse/JBWS-723
+ */
+ boolean secureWSDLAccess() default false;
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/binding/BindingCustomization.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/binding/BindingCustomization.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/binding/BindingCustomization.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,39 @@
+/*
+ * 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.spi.binding;
+
+import java.util.HashMap;
+
+/**
+ * Allows introduction of arbitrary binding customization properties.<p>
+ * This may be different between stacks and addresses meta data binding
+ * (i.e JSR-181 to UnifiedMetaData) as well as JAVA to XML binding operations.
+ * <p>
+ * Supported properties need to be documented in subclasses.
+ *
+ * @author Heiko.Braun(a)jboss.com
+ * Created: Jun 28, 2007
+ */
+public abstract class BindingCustomization extends HashMap
+{
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/binding/JAXBBindingCustomization.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/binding/JAXBBindingCustomization.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/binding/JAXBBindingCustomization.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,36 @@
+/*
+ * 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.spi.binding;
+
+import org.jboss.wsf.spi.binding.BindingCustomization;
+
+/**
+ * JAXB customizations.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 05-Oct-2009
+ */
+public class JAXBBindingCustomization extends BindingCustomization
+{
+ private static final long serialVersionUID = 5547146387872057974L;
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/Record.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/Record.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/Record.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,114 @@
+/*
+ * 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.spi.management.recording;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+/**
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public interface Record extends Serializable
+{
+ public enum MessageType {INBOUND, OUTBOUND};
+
+ /**
+ * Gets the group ID corresponding to the current message exchange flow
+ *
+ * @return
+ */
+ public String getGroupID();
+
+ public void setGroupID(String groupID);
+
+ /**
+ * Gets the date of this record
+ *
+ * @return
+ */
+ public Date getDate();
+
+ public void setDate(Date date);
+
+ /**
+ * Gets the source (message sender) host. The result format conforms to RFC2732
+ *
+ * @return source host
+ */
+ public String getSourceHost();
+
+ public void setSourceHost(String host);
+
+ /**
+ * Gets the source (message sender) host. The result format conforms to RFC2732
+ *
+ * @return the source host
+ */
+ public String getDestinationHost();
+
+ public void setDestinationHost(String host);
+
+ /**
+ * Gets the message type, i.e. MessageType.INBOUND or MessageType.OUTBOUND
+ *
+ * @return the message type
+ */
+ public MessageType getMessageType();
+
+ public void setMessageType(MessageType type);
+
+
+ /**
+ * Gets the SOAP message envelope
+ *
+ * @return
+ */
+ public String getEnvelope();
+
+ public void setEnvelope(String envelope);
+
+ /**
+ * Gets the HTTP headers
+ *
+ * @return the headers
+ */
+ public Map<String, List<String>> getHeaders();
+
+ public void addHeaders(String key, List<String> value);
+
+ public void setHeaders(Map<String, List<String>> headers);
+
+ /**
+ * Gets the invoked operation
+ *
+ * @return the operation
+ */
+ public QName getOperation();
+
+ public void setOperation(QName operation);
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordFilter.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordFilter.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordFilter.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,43 @@
+/*
+ * 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.spi.management.recording;
+
+import java.io.Serializable;
+
+/**
+ * A record filter
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public interface RecordFilter extends Cloneable, Serializable
+{
+ /**
+ * Returns true if the filter matches the given record.
+ */
+ boolean match(Record record);
+
+ /**
+ * RecordFilters must override Object.clone()
+ */
+ Object clone() throws CloneNotSupportedException;
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordGroupAssociation.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordGroupAssociation.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordGroupAssociation.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,78 @@
+/*
+ * 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.spi.management.recording;
+
+import java.util.Stack;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Associates the record group ID with the current thread.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public class RecordGroupAssociation
+{
+ private static ThreadLocal<Stack<String>> groupIDAssoc = new ThreadLocal<Stack<String>>();
+
+ // provide logging
+ private static Logger log = Logger.getLogger(RecordGroupAssociation.class);
+
+
+ public static void pushGroupID(String groupID)
+ {
+ if(log.isTraceEnabled()) log.trace("pushGroupID: " + groupID + " (Thread " +Thread.currentThread().getName()+ ")");
+ Stack<String> stack = groupIDAssoc.get();
+ if (stack == null)
+ {
+ stack = new Stack<String>();
+ groupIDAssoc.set(stack);
+ }
+ stack.push(groupID);
+ }
+
+ public static String peekGroupID()
+ {
+ String groupID = null;
+ Stack<String> stack = groupIDAssoc.get();
+ if (stack != null && stack.isEmpty() == false)
+ {
+ groupID = stack.peek();
+ }
+ if(log.isTraceEnabled()) log.trace("peekGroupID: " + groupID + " (Thread " +Thread.currentThread().getName()+ ")");
+ return groupID;
+ }
+
+ public static String popGroupID()
+ {
+ String groupID = null;
+ Stack<String> stack = groupIDAssoc.get();
+ if (stack != null && stack.isEmpty() == false)
+ {
+ groupID = stack.pop();
+ }
+ if(log.isTraceEnabled()) log.trace("popGroupID: " + groupID +" (Thread " +Thread.currentThread().getName()+ ")");
+ return groupID;
+ }
+
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordProcessor.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordProcessor.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/management/recording/RecordProcessor.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,85 @@
+/*
+ * 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.spi.management.recording;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * Processes a record. A RecordProcessor may have filters to allow processing
+ * of records matching given criteria. It also gives users fine management of
+ * record's attributes to processed.
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 8-Dec-2007
+ */
+public interface RecordProcessor extends Cloneable, Serializable
+{
+ String getName();
+
+ void setName(String name);
+
+ boolean isRecording();
+
+ void setRecording(boolean value);
+
+ void processRecord(Record record);
+
+ List<RecordFilter> getFilters();
+
+ void addFilter(RecordFilter filter);
+
+ void setFilters(List<RecordFilter> filters);
+
+ boolean isProcessSourceHost();
+
+ void setProcessSourceHost(boolean value);
+
+ boolean isProcessDestinationHost();
+
+ void setProcessDestinationHost(boolean value);
+
+ boolean isProcessMessageType();
+
+ void setProcessMessageType(boolean value);
+
+ boolean isProcessEnvelope();
+
+ void setProcessEnvelope(boolean value);
+
+ boolean isProcessHeaders();
+
+ void setProcessHeaders(boolean value);
+
+ boolean isProcessOperation();
+
+ void setProcessOperation(boolean value);
+
+ boolean isProcessDate();
+
+ void setProcessDate(boolean value);
+
+ /**
+ * RecordFilters must override Object.clone()
+ */
+ Object clone() throws CloneNotSupportedException;
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/tools/SecurityActions.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,112 @@
+/*
+ * 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.spi.tools;
+
+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());
+ }
+ }
+ }
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumer.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,212 @@
+/*
+ * 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.spi.tools;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+/**
+ * WSContractConsumer is responsible for generating JAX-WS client and server
+ * artifacts from the specified WSDL file. To implement a client, one would use
+ * the generated ___Service.java file. For a server, one only needs to provide
+ * an implementation class that implements the generated service endpoint
+ * interface.
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public abstract class WSContractConsumer
+{
+ private static String DEFAULT_PROVIDER = "org.jboss.ws.tools.jaxws.impl.SunRIConsumerFactoryImpl";
+ public static final String PROVIDER_PROPERTY = "org.jboss.wsf.spi.tools.ConsumerFactoryImpl";
+
+ /**
+ * Obtain a new instance of a WSContractConsumer. This will use the current
+ * thread's context class loader to locate the WSContractConsumerFactory
+ * implementation.
+ *
+ * @return a new WSContractConsumer
+ */
+ public static WSContractConsumer newInstance()
+ {
+ return newInstance(SecurityActions.getContextClassLoader());
+ }
+
+ /**
+ * Obtain a new instance of a WSContractConsumer. The specified ClassLoader will be used to
+ * locate the WebServiceImporterProvide implementation
+ *
+ * @param loader the ClassLoader to use
+ * @return a new WSContractConsumer
+ */
+ public static WSContractConsumer newInstance(ClassLoader loader)
+ {
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
+ try
+ {
+ SecurityActions.setContextClassLoader(loader);
+ WSContractConsumerFactory factory = (WSContractConsumerFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
+ return factory.createConsumer();
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(oldLoader);
+ }
+ }
+
+ /**
+ * Specifies the JAX-WS and JAXB binding files to use on import operations.
+ *
+ * @param bindingFiles list of JAX-WS or JAXB binding files
+ */
+ public abstract void setBindingFiles(List<File> bindingFiles);
+
+ /**
+ * Sets the OASIS XML Catalog file to use for entity resolution.
+ *
+ * @param catalog the OASIS XML Catalog file
+ */
+ public abstract void setCatalog(File catalog);
+
+ /**
+ * Sets the main output directory. If the directory does not exist, it will be created.
+ *
+ * @param directory the root directory for generated files
+ */
+ public abstract void setOutputDirectory(File directory);
+
+ /**
+ * Sets the source directory. This directory will contain any generated Java source.
+ * If the directory does not exist, it will be created. If not specified,
+ * the output directory will be used instead.
+ *
+ * @param directory the root directory for generated source code
+ */
+ public abstract void setSourceDirectory(File directory);
+
+ /**
+ * Enables/Disables SOAP 1.2 binding extension
+ *
+ * @param extension whether or not to enable SOAP 1.2 binding extension
+ */
+ public abstract void setExtension(boolean extension);
+
+ /**
+ * Enables/Disables Java source generation.
+ *
+ * @param generateSource whether or not to generate Java source.
+ */
+ public abstract void setGenerateSource(boolean generateSource);
+
+ /**
+ * Enables/Disables Java source compilation.
+ *
+ * @param nocompile whether or not to compile Java source.
+ */
+ public abstract void setNoCompile(boolean nocompile);
+
+ /**
+ * Sets the target package for generated source. If not specified the default
+ * is based off of the XML namespace.
+ *
+ * @param targetPackage the target package for generated source
+ */
+ public abstract void setTargetPackage(String targetPackage);
+
+ /**
+ * Sets the @(a)WebService.wsdlLocation and @(a)WebServiceClient.wsdlLocation attributes to a custom value.
+ *
+ * @param wsdlLocation the custom WSDL location to use in generated source
+ */
+ public abstract void setWsdlLocation(String wsdlLocation);
+
+ /**
+ * Sets the PrintStream to use for status feedback. The simplest example
+ * would be to use System.out.
+ *
+ * @param messageStream the stream to use for status messages:
+ */
+ public abstract void setMessageStream(PrintStream messageStream);
+
+ /**
+ * Sets the additional classpath to use if/when invoking the Java compiler.
+ * Typically an implementation will use the system <code>java.class.path</code>
+ * property. So for most normal applications this method is not needed. However,
+ * if this API is being used from an isolated classloader, then it needs to
+ * be called in order to reference all jars that are required by the
+ * implementation.
+ *
+ * @param classPath a list of strings where each entry references a
+ * single jar or directory
+ */
+ public abstract void setAdditionalCompilerClassPath(List<String> classPath);
+
+ /**
+ * Enables or disables processing of implicit SOAP headers (i.e. SOAP headers
+ * defined in the wsdl:binding but not wsdl:portType section.) Default is false.
+ *
+ * @param additionalHeaders a boolean enabling processing of implicit SOAP headers
+ */
+ public abstract void setAdditionalHeaders(boolean additionalHeaders);
+
+ /**
+ * Set the target JAX-WS specification target. Allowed values are 2.0, 2.1 and 2.2
+ * @param target the JAX-WS specification version.
+ */
+ public abstract void setTarget(String target);
+
+ /**
+ * Generate the required artifacts using the specified WSDL URL. This method
+ * may be called more than once, although this is probably not desireable
+ *
+ * @param wsdl the URL of the WSDL
+ */
+ public abstract void consume(URL wsdl);
+
+ /**
+ * Generate the required artifacts using the specified WSDL. This method
+ * may be called more than once, although this is probably not desireable.
+ * The passed string is expect to either be a valid URL, or a local file path.
+ *
+ * @param wsdl a URL or local file path
+ * @throws MalformedURLException if wsdl is not a legal URL or local file
+ */
+ public void consume(String wsdl) throws MalformedURLException
+ {
+ URL url = null;
+ try
+ {
+ url = new URL(wsdl);
+ }
+ catch (MalformedURLException e)
+ {
+ File file = new File(wsdl);
+ url = file.toURI().toURL();
+ }
+
+ consume(url);
+ }
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumerFactory.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumerFactory.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractConsumerFactory.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,40 @@
+/*
+ * 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.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractConsumer;
+
+/**
+ * Creates WSContractConsumer implementations.
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public interface WSContractConsumerFactory
+{
+ /**
+ * Create a new WSContractConsumer. There are no restrictions on how this
+ * should be performed.
+ *
+ * @return a new WSContractConsumer
+ */
+ public WSContractConsumer createConsumer();
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProvider.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,185 @@
+/*
+ * 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.spi.tools;
+
+import java.io.File;
+import java.io.PrintStream;
+
+import org.jboss.wsf.spi.util.ServiceLoader;
+
+/**
+ * WSContractProvider is responsible for generating the required portable
+ * JAX-WS artifacts for a service endpoint implementation. This includes class
+ * files for wrapper types and fault beans. WSDL may be optionally generated as
+ * well using this API.
+ *
+ * <p>The following example generates class files, source files and WSDL for an
+ * endpoint:</p>
+ * <pre>
+ * WSContractProvider provider = WSContractProvider.newInstance();
+ * provider.setGenerateSource(true);
+ * provider.setGenerateWsdl(true);
+ * provider.setOutputDirectory(new File("output"));
+ * provider.setMessageStream(System.out);
+ * provider.provide(TestMe.class);
+ * </pre>
+ *
+ * <p>Thread-Safety:</p>
+ * This class expects to be thread-confined, so it can not be shared between threads.
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public abstract class WSContractProvider
+{
+ private static String DEFAULT_PROVIDER = "org.jboss.ws.tools.jaxws.impl.JBossWSProviderFactoryImpl";
+ public static final String PROVIDER_PROPERTY = "org.jboss.wsf.spi.tools.ProviderFactoryImpl";
+
+ protected WSContractProvider()
+ {
+
+ }
+
+ /**
+ * Obtain a new instance of a WSContractProvider. This will use the current
+ * thread's context class loader to locate the WSContractProviderFactory
+ * implementation.
+ *
+ * @return a new WSContractProvider
+ */
+ public static WSContractProvider newInstance()
+ {
+ return newInstance(SecurityActions.getContextClassLoader());
+ }
+
+ /**
+ * Obtain a new instance of a WSContractProvider. The specified ClassLoader will be used to
+ * locate the WSContractProviderFactory implementation
+ *
+ * @param loader the ClassLoader to use
+ * @return a new WSContractProvider
+ */
+ public static WSContractProvider newInstance(ClassLoader loader)
+ {
+ ClassLoader oldLoader = SecurityActions.getContextClassLoader();
+ try
+ {
+ SecurityActions.setContextClassLoader(loader);
+ WSContractProviderFactory factory = (WSContractProviderFactory) ServiceLoader.loadService(PROVIDER_PROPERTY, DEFAULT_PROVIDER);
+ return factory.createProvider(loader);
+ }
+ finally
+ {
+ SecurityActions.setContextClassLoader(oldLoader);
+ }
+ }
+
+ /**
+ * Enables/Disables WSDL generation.
+ *
+ * @param generateWsdl whether or not to generate WSDL
+ */
+ public abstract void setGenerateWsdl(boolean generateWsdl);
+
+ /**
+ * Enables/Disables SOAP 1.2 binding extension
+ *
+ * @param extension whether or not to enable SOAP 1.2 binding extension
+ */
+ public abstract void setExtension(boolean extension);
+
+ /**
+ * Enables/Disables Java source generation.
+ *
+ * @param generateSource whether or not to generate Java source.
+ */
+ public abstract void setGenerateSource(boolean generateSource);
+
+ /**
+ * Sets the main output directory. If the directory does not exist, it will be created.
+ *
+ * @param directory the root directory for generated files
+ */
+ public abstract void setOutputDirectory(File directory);
+
+ /**
+ * Sets the resource directory. This directory will contain any generated
+ * WSDL and XSD files. If the directory does not exist, it will be created.
+ * If not specified, the output directory will be used instead.
+ *
+ * @param directory the root directory for generated resource files
+ */
+ public abstract void setResourceDirectory(File directory);
+
+ /**
+ * Sets the source directory. This directory will contain any generated Java source.
+ * If the directory does not exist, it will be created. If not specified,
+ * the output directory will be used instead.
+ *
+ * @param directory the root directory for generated source code
+ */
+ public abstract void setSourceDirectory(File directory);
+
+ /**
+ * Sets the ClassLoader used to discover types. This defaults to the one used
+ * in instantiation.
+ *
+ * @param loader the ClassLoader to use
+ */
+ public abstract void setClassLoader(ClassLoader loader);
+
+ /**
+ * Generates artifacts using the current settings. This method may be invoked
+ * more than once (e.g. multiple endpoints).
+ *
+ * @param endpointClass the name of the endpoint implementation bean
+ * @throws RuntimeException if any error occurs during processing, or the class is not found
+ */
+ public abstract void provide(String endpointClass);
+
+ /**
+ * Generates artifacts using the current settings. This method may be invoked
+ * more than once (e.g. multiple endpoints).
+ *
+ * @param endpointClass the endpoint implementation bean
+ * @throws RuntimeException if any error occurs during processing
+ */
+ public abstract void provide(Class<?> endpointClass);
+
+ /**
+ * Sets the PrintStream to use for status feedback. The simplest example
+ * would be to use System.out.
+ *
+ * <p>Example output:</p>
+ * <pre>
+ * Generating WSDL:
+ * TestMeService.wsdl
+ * Writing Source:
+ * org/jboss/ws/tools/jaxws/TestMe.java
+ * org/jboss/ws/tools/jaxws/TestMeResponse.java
+ * Writing Classes:
+ * org/jboss/ws/tools/jaxws/TestMe.class
+ * org/jboss/ws/tools/jaxws/TestMeResponse.class
+ * </pre>
+ * @param messageStream the stream to use for status messages:
+ */
+ public abstract void setMessageStream(PrintStream messageStream);
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProviderFactory.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProviderFactory.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/tools/WSContractProviderFactory.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,43 @@
+/*
+ * 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.spi.tools;
+
+import org.jboss.wsf.spi.tools.WSContractProvider;
+
+/**
+ * Creates WSContractProvider implementations.
+ *
+ * @author <a href="mailto:jason.greene@jboss.com">Jason T. Greene</a>
+ */
+public interface WSContractProviderFactory
+{
+ /**
+ * Create a new WSContractProvider. There are no restrictions on how this
+ * should be performed. The passed ClassLoader is the one used in
+ * {@link WSContractProvider#newInstance(ClassLoader)}. This loader
+ * should be made available to the generated WSContractProvider.
+ *
+ * @param loader the ClassLoader for type discovery
+ * @return a new WSContractProvider
+ */
+ public WSContractProvider createProvider(ClassLoader loader);
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/util/SecurityActions.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,142 @@
+/*
+ * 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.spi.util;
+
+import java.io.InputStream;
+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.
+ *
+ */
+ static void setContextClassLoader(final ClassLoader cl)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ }
+ else
+ {
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ public Object run()
+ {
+ Thread.currentThread().setContextClassLoader(cl);
+ return null;
+ }
+ });
+ }
+ }
+
+ /**
+ * Get resource as stream
+ *
+ * @param cl
+ * @param filename
+ * @return input stream
+ * @throws PrivilegedActionException
+ */
+ static InputStream getResourceAsStream(final ClassLoader cl, final String filename)
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
+ public InputStream run()
+ {
+ return cl.getResourceAsStream(filename);
+ }
+ });
+ }
+ }
+
+ /**
+ * Load a class using the provided classloader
+ *
+ * @param name
+ * @return
+ * @throws PrivilegedActionException
+ */
+ static Class<?> loadClass(final ClassLoader cl, final String name) throws PrivilegedActionException, ClassNotFoundException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return cl.loadClass(name);
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
+ public Class<?> run() throws PrivilegedActionException
+ {
+ try
+ {
+ return cl.loadClass(name);
+ }
+ catch (Exception e)
+ {
+ throw new PrivilegedActionException(e);
+ }
+ }
+ });
+ }
+ }
+}
Added: api/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java
===================================================================
--- api/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java (rev 0)
+++ api/trunk/src/main/java/org/jboss/wsf/spi/util/ServiceLoader.java 2010-11-28 02:10:52 UTC (rev 13344)
@@ -0,0 +1,306 @@
+/*
+ * 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.spi.util;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+import java.util.WeakHashMap;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Load a service class using this ordered lookup procedure
+ *
+ * @author Thomas.Diesler(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
+ * @since 14-Dec-2006
+ */
+public abstract class ServiceLoader
+{
+ /**
+ * A synchronized weak hash map that keeps factory names retrieved using Service API (META-INF/services/*) for each classloader.
+ * Weak keys are used to remove entries when classloaders are garbage collected; values are service-property-name -> factory name maps.
+ */
+ private static Map<ClassLoader, Map<String, String>> serviceMap = Collections.synchronizedMap(new WeakHashMap<ClassLoader, Map<String, String>>());
+
+ /**
+ * This method uses the algorithm below using the JAXWS Provider as an example.
+ *
+ * 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then
+ * its first line, if present, is used as the UTF-8 encoded name of the implementation class.
+ *
+ * 2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the
+ * java.util.Properties.load(InputStream) method and it contains an entry whose key is
+ * javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.
+ *
+ * 3. If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used
+ * as the name of the implementation class.
+ *
+ * 4. Finally, a default implementation class name is used.
+ */
+ public static Object loadService(String propertyName, String defaultFactory)
+ {
+ Object factory = loadFromServices(propertyName, null);
+ if (factory == null)
+ {
+ factory = loadFromPropertiesFile(propertyName, null);
+ }
+ if (factory == null)
+ {
+ factory = loadFromSystemProperty(propertyName, defaultFactory);
+ }
+ return factory;
+ }
+
+ /** Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
+ */
+ public static Object loadFromServices(String propertyName, String defaultFactory)
+ {
+ Object factory = null;
+ String factoryName = null;
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+
+ // Use the Services API (as detailed in the JAR specification), if available, to determine the classname.
+ String filename = "META-INF/services/" + propertyName;
+
+ try
+ {
+ factoryName = getServiceNameUsingCache(loader, filename);
+ if (factoryName != null)
+ {
+ Class factoryClass = SecurityActions.loadClass(loader, factoryName);
+ factory = factoryClass.newInstance();
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+ }
+
+ // Use the default factory implementation class.
+ if (factory == null && defaultFactory != null)
+ {
+ factory = loadDefault(defaultFactory);
+ }
+
+ return factory;
+ }
+
+ private static String getServiceNameUsingCache(ClassLoader loader, String filename) throws IOException
+ {
+ Map<String, String> map = serviceMap.get(loader);
+ if (map != null && map.containsKey(filename))
+ {
+ return map.get(filename);
+ }
+ else
+ {
+ if (map == null)
+ {
+ map = new ConcurrentHashMap<String, String>();
+ serviceMap.put(loader, map);
+ }
+ InputStream inStream = SecurityActions.getResourceAsStream(loader, filename);
+ String factoryName = null;
+ if (inStream != null)
+ {
+ BufferedReader br = new BufferedReader(new InputStreamReader(inStream, "UTF-8"));
+ factoryName = br.readLine();
+ br.close();
+ map.put(filename, factoryName);
+ }
+ return factoryName;
+ }
+ }
+
+ /** Use the system property
+ */
+ public static Object loadFromSystemProperty(String propertyName, String defaultFactory)
+ {
+ Object factory = null;
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+
+ PrivilegedAction action = new PropertyAccessAction(propertyName);
+ String factoryName = (String)AccessController.doPrivileged(action);
+ if (factoryName != null)
+ {
+ try
+ {
+ //if(log.isDebugEnabled()) log.debug("Load from system property: " + factoryName);
+ Class factoryClass = SecurityActions.loadClass(loader, factoryName);
+ factory = factoryClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+ }
+ }
+
+ // Use the default factory implementation class.
+ if (factory == null && defaultFactory != null)
+ {
+ factory = loadDefault(defaultFactory);
+ }
+
+ return factory;
+ }
+
+ /**
+ * Use the properties file "${java.home}/lib/jaxws.properties" in the JRE directory.
+ * This configuration file is in standard java.util.Properties format and contains the
+ * fully qualified name of the implementation class with the key being the system property defined above.
+ */
+ public static Object loadFromPropertiesFile(String propertyName, String defaultFactory)
+ {
+ Object factory = null;
+ String factoryName = null;
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+
+ // Use the properties file "lib/jaxm.properties" in the JRE directory.
+ // This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above.
+ PrivilegedAction action = new PropertyAccessAction("java.home");
+ String javaHome = (String)AccessController.doPrivileged(action);
+ File jaxmFile = new File(javaHome + "/lib/jaxws.properties");
+ if ((Boolean)AccessController.doPrivileged(new PropertyFileExistAction(jaxmFile)))
+ {
+ try
+ {
+ action = new PropertyFileAccessAction(jaxmFile.getCanonicalPath());
+ Properties jaxmProperties = (Properties)AccessController.doPrivileged(action);
+ factoryName = jaxmProperties.getProperty(propertyName);
+ if (factoryName != null)
+ {
+ //if(log.isDebugEnabled()) log.debug("Load from " + jaxmFile + ": " + factoryName);
+ Class<?> factoryClass = SecurityActions.loadClass(loader, factoryName);
+ factory = factoryClass.newInstance();
+ }
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Failed to load " + propertyName + ": " + factoryName, t);
+ }
+ }
+
+ // Use the default factory implementation class.
+ if (factory == null && defaultFactory != null)
+ {
+ factory = loadDefault(defaultFactory);
+ }
+
+ return factory;
+ }
+
+ private static Object loadDefault(String defaultFactory)
+ {
+ Object factory = null;
+ ClassLoader loader = SecurityActions.getContextClassLoader();
+
+ // Use the default factory implementation class.
+ if (defaultFactory != null)
+ {
+ try
+ {
+ //if(log.isDebugEnabled()) log.debug("Load from default: " + factoryName);
+ Class factoryClass = SecurityActions.loadClass(loader, defaultFactory);
+ factory = factoryClass.newInstance();
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalStateException("Failed to load: " + defaultFactory, t);
+ }
+ }
+
+ return factory;
+ }
+
+ private static class PropertyAccessAction implements PrivilegedAction
+ {
+ private String name;
+
+ PropertyAccessAction(String name)
+ {
+ this.name = name;
+ }
+
+ public Object run()
+ {
+ return System.getProperty(name);
+ }
+ }
+
+ private static class PropertyFileAccessAction implements PrivilegedAction
+ {
+ private String filename;
+
+ PropertyFileAccessAction(String filename)
+ {
+ this.filename = filename;
+ }
+
+ public Object run()
+ {
+ InputStream inStream = null;
+ try
+ {
+ inStream = new FileInputStream(filename);
+ Properties props = new Properties();
+ props.load(inStream);
+ return props;
+ }
+ catch (IOException ex)
+ {
+ throw new SecurityException("Cannot load properties: " + filename, ex);
+ }
+ finally
+ {
+ try
+ {
+ inStream.close();
+ }
+ catch (Exception e) {} //ignore
+ }
+ }
+ }
+
+ private static class PropertyFileExistAction implements PrivilegedAction
+ {
+ private File file;
+
+ PropertyFileExistAction(File file)
+ {
+ this.file = file;
+ }
+
+ public Object run()
+ {
+ return file.exists();
+ }
+ }
+}
14 years, 1 month
JBossWS SVN: r13343 - in spi/trunk/src/main/java/org/jboss/wsf/spi/metadata: webservices and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 09:53:01 -0500 (Sat, 27 Nov 2010)
New Revision: 13343
Added:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
Modified:
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
Log:
[JBWS-3169] svn merge -r 13339:13340 https://svn.jboss.org/repos/jbossws/spi/branches/jbossws-spi-1.4.1 .
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java 2010-11-27 14:31:39 UTC (rev 13342)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java 2010-11-27 14:53:01 UTC (rev 13343)
@@ -33,6 +33,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 15-Oct-2005
*/
+@Deprecated
public class HandlerChainsObjectFactory implements ObjectModelFactory
{
// provide logging
Copied: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java (from rev 13340, spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java)
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java (rev 0)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java 2010-11-27 14:53:01 UTC (rev 13343)
@@ -0,0 +1,51 @@
+/*
+ * 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.spi.metadata.j2ee.serviceref;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/** The interface of the parser for the unified metadata handler chains element
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-Nov-2010
+ */
+public class UnifiedHandlerChainsMetaDataParser
+{
+ @SuppressWarnings("deprecation")
+ public static UnifiedHandlerChainsMetaData parse(InputStream is) throws IOException
+ {
+ try
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ return (UnifiedHandlerChainsMetaData) unmarshaller.unmarshal(is, new HandlerChainsObjectFactory(), null);
+ }
+ catch (JBossXBException xbe)
+ {
+ throw new IOException(xbe);
+ }
+ }
+}
Modified: spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
--- spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-11-27 14:31:39 UTC (rev 13342)
+++ spi/trunk/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-11-27 14:53:01 UTC (rev 13343)
@@ -45,7 +45,6 @@
* @author Thomas.Diesler(a)jboss.org
* @since 16-Apr-2004
*/
-// TODO: move to jbossws-framework or jbossws-common
public class WebservicesFactory implements ObjectModelFactory
{
// provide logging
@@ -103,13 +102,9 @@
URL wsddUrl = wsdd.toURL();
try
{
- InputStream is = wsddUrl.openStream();
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
- webservices = (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
- is.close();
+ webservices = load(wsddUrl);
}
- catch (Exception e)
+ catch (IOException e)
{
throw new WebServiceException("Failed to unmarshall webservices.xml:" + e.getMessage());
}
@@ -117,6 +112,34 @@
return webservices;
}
+
+ /**
+ * Load webservices.xml from <code>META-INF/webservices.xml</code>
+ * or <code>WEB-INF/webservices.xml</code>.
+ *
+ * @param root virtual file root
+ * @return WebservicesMetaData or <code>null</code> if it cannot be found
+ */
+ public static WebservicesMetaData load(URL wsddUrl) throws IOException
+ {
+ InputStream is = null;
+ try
+ {
+ is = wsddUrl.openStream();
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
+ return (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException("Failed to unmarshall " + wsddUrl + ":" + e.getMessage());
+ }
+ finally
+ {
+ if (is != null)
+ is.close();
+ }
+ }
/**
* This method is called on the factory by the object model builder when the parsing starts.
14 years, 1 month
JBossWS SVN: r13341 - spi/tags.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 09:29:20 -0500 (Sat, 27 Nov 2010)
New Revision: 13341
Added:
spi/tags/jbossws-spi-1.4.1.CR2/
Log:
Tagging jbossws-spi-1.4.1.CR2
Copied: spi/tags/jbossws-spi-1.4.1.CR2 (from rev 13340, spi/branches/jbossws-spi-1.4.1)
14 years, 1 month
JBossWS SVN: r13340 - in spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata: webservices and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2010-11-27 09:25:14 -0500 (Sat, 27 Nov 2010)
New Revision: 13340
Added:
spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
Modified:
spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
Log:
[JBWS-3169] Adding means for building UnifiedHandlersChainsMetaData and WebservicesMetaData from jbossws-spi without directly relying on JBossXB internals
Modified: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java 2010-11-26 15:13:02 UTC (rev 13339)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/HandlerChainsObjectFactory.java 2010-11-27 14:25:14 UTC (rev 13340)
@@ -33,6 +33,7 @@
* @author Thomas.Diesler(a)jboss.org
* @since 15-Oct-2005
*/
+@Deprecated
public class HandlerChainsObjectFactory implements ObjectModelFactory
{
// provide logging
Added: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java (rev 0)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/j2ee/serviceref/UnifiedHandlerChainsMetaDataParser.java 2010-11-27 14:25:14 UTC (rev 13340)
@@ -0,0 +1,51 @@
+/*
+ * 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.spi.metadata.j2ee.serviceref;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.jboss.xb.binding.JBossXBException;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/** The interface of the parser for the unified metadata handler chains element
+ *
+ * @author alessio.soldano(a)jboss.com
+ * @since 26-Nov-2010
+ */
+public class UnifiedHandlerChainsMetaDataParser
+{
+ @SuppressWarnings("deprecation")
+ public static UnifiedHandlerChainsMetaData parse(InputStream is) throws IOException
+ {
+ try
+ {
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ return (UnifiedHandlerChainsMetaData) unmarshaller.unmarshal(is, new HandlerChainsObjectFactory(), null);
+ }
+ catch (JBossXBException xbe)
+ {
+ throw new IOException(xbe);
+ }
+ }
+}
Modified: spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java
===================================================================
--- spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-11-26 15:13:02 UTC (rev 13339)
+++ spi/branches/jbossws-spi-1.4.1/src/main/java/org/jboss/wsf/spi/metadata/webservices/WebservicesFactory.java 2010-11-27 14:25:14 UTC (rev 13340)
@@ -45,7 +45,6 @@
* @author Thomas.Diesler(a)jboss.org
* @since 16-Apr-2004
*/
-// TODO: move to jbossws-framework or jbossws-common
public class WebservicesFactory implements ObjectModelFactory
{
// provide logging
@@ -103,13 +102,9 @@
URL wsddUrl = wsdd.toURL();
try
{
- InputStream is = wsddUrl.openStream();
- Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
- ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
- webservices = (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
- is.close();
+ webservices = load(wsddUrl);
}
- catch (Exception e)
+ catch (IOException e)
{
throw new WebServiceException("Failed to unmarshall webservices.xml:" + e.getMessage());
}
@@ -117,6 +112,34 @@
return webservices;
}
+
+ /**
+ * Load webservices.xml from <code>META-INF/webservices.xml</code>
+ * or <code>WEB-INF/webservices.xml</code>.
+ *
+ * @param root virtual file root
+ * @return WebservicesMetaData or <code>null</code> if it cannot be found
+ */
+ public static WebservicesMetaData load(URL wsddUrl) throws IOException
+ {
+ InputStream is = null;
+ try
+ {
+ is = wsddUrl.openStream();
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ ObjectModelFactory factory = new WebservicesFactory(wsddUrl);
+ return (WebservicesMetaData)unmarshaller.unmarshal(is, factory, null);
+ }
+ catch (Exception e)
+ {
+ throw new WebServiceException("Failed to unmarshall " + wsddUrl + ":" + e.getMessage());
+ }
+ finally
+ {
+ if (is != null)
+ is.close();
+ }
+ }
/**
* This method is called on the factory by the object model builder when the parsing starts.
14 years, 1 month