JBossWS SVN: r14165 - stack/native/branches.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2011-04-19 12:15:06 -0400 (Tue, 19 Apr 2011)
New Revision: 14165
Added:
stack/native/branches/jbossws-native-3.1.2.SP3-patch-02_JBPAPP-6365/
Log:
[JBPAPP-6365] Creating isolated branch for merging other fixes from other jiras
13 years, 8 months
JBossWS SVN: r14164 - stack/cxf/branches.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-04-19 04:46:05 -0400 (Tue, 19 Apr 2011)
New Revision: 14164
Added:
stack/cxf/branches/cxf24/
Log:
Branching for working on Apache CXF 2.4 migration
13 years, 8 months
JBossWS SVN: r14163 - thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2011-04-18 22:53:07 -0400 (Mon, 18 Apr 2011)
New Revision: 14163
Modified:
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
Log:
[CXF-3458]:Fix AddressingFeature required Client should throw exception when the wsa header is missing in the inbound message
Modified: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java 2011-04-19 02:51:22 UTC (rev 14162)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java 2011-04-19 02:53:07 UTC (rev 14163)
@@ -607,8 +607,10 @@
MetadataConstants.USING_ADDRESSING_2006_QNAME
};
for (QName type : types) {
- if (aim.containsKey(type) && aim.get(type).size() > 0) {
- missingWsaHeader = false;
+ for (AssertionInfo assertInfo : aim.getAssertionInfo(type)) {
+ if (assertInfo.isAsserted()) {
+ missingWsaHeader = false;
+ }
}
}
}
@@ -1236,10 +1238,9 @@
ContextUtils.storeMAPFaultName(Names.DUPLICATE_MESSAGE_ID_NAME,
message);
ContextUtils.storeMAPFaultReason(l7dReason, message);
- }
-
+ }
valid = false;
- }
+ }
} else if (usingAddressingAdvisory) {
String reason =
BUNDLE.getString("MISSING_ACTION_MESSAGE");
@@ -1250,6 +1251,10 @@
valid = false;
}
+ if (Names.INVALID_CARDINALITY_NAME.equals(ContextUtils.retrieveMAPFaultName(message))) {
+ valid = false;
+ }
+
return valid;
}
}
13 years, 8 months
JBossWS SVN: r14162 - in thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck: rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: jim.ma
Date: 2011-04-18 22:51:22 -0400 (Mon, 18 Apr 2011)
New Revision: 14162
Added:
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/duplicate-wsa-header-msg.xml
Modified:
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/Messages.properties
thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
Log:
[CXF-3456]:Fix WSA implementation does not throw wsa:InvalidCardinality exception when there is a greater than expected number of the specified header
Modified: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java 2011-04-18 22:36:47 UTC (rev 14161)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/Names.java 2011-04-19 02:51:22 UTC (rev 14162)
@@ -171,6 +171,11 @@
public static final QName ONLY_NONANONYMOUS_ADDRESS_SUPPORTED_QNAME =
new QName(WSA_NAMESPACE_NAME, ONLY_NONANONYMOUS_ADDRESS_SUPPORTED_NAME);
+ public static final String INVALID_CARDINALITY_NAME =
+ "InvalidCardinality";
+ public static final QName INVALID_CARDINALITY_QNAME =
+ new QName(WSA_NAMESPACE_NAME, INVALID_CARDINALITY_NAME);
+
public static final String SOAP11HTTP_ADDRESSING_BINDING =
"http://schemas.xmlsoap.org/soap/envelope/?addressing=ms";
public static final String SOAP12HTTP_ADDRESSING_BINDING =
Modified: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java 2011-04-18 22:36:47 UTC (rev 14161)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java 2011-04-19 02:51:22 UTC (rev 14162)
@@ -23,6 +23,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.ResourceBundle;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
@@ -76,6 +77,7 @@
private static final Logger LOG = LogUtils.getL7dLogger(MAPCodec.class);
private static final String IS_REFERENCE_PARAM_ATTR_NAME = "IsReferenceParameter";
+ private static final ResourceBundle BUNDLE = LOG.getResourceBundle();
private static final String ONE_WAY_DECOUPLED_FAULT_SUPPORT =
"org.apache.cxf.ws.addressing.oneway.decoupled_fault_support";
@@ -495,7 +497,7 @@
LOG.log(Level.FINE, "Inbound WS-Addressing headers");
Unmarshaller unmarshaller = null;
Set<Element> referenceParameterHeaders = null;
-
+ QName invalidCardinalityQName = null;
Iterator<Header> iter = header.iterator();
while (iter.hasNext()) {
Header hdr = iter.next();
@@ -518,12 +520,15 @@
}
String localName = headerElement.getLocalName();
if (Names.WSA_MESSAGEID_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getMessageID() != null
+ ? Names.WSA_MESSAGEID_QNAME : null;
maps.setMessageID(decodeAsNative(
headerURI,
AttributedURIType.class,
headerElement,
unmarshaller));
} else if (Names.WSA_TO_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getTo() != null ? Names.WSA_TO_QNAME : null;
AttributedURIType addr = decodeAsNative(
headerURI,
AttributedURIType.class,
@@ -531,18 +536,24 @@
unmarshaller);
maps.setTo(EndpointReferenceUtils.getEndpointReference(addr));
} else if (Names.WSA_FROM_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getFrom() != null
+ ? Names.WSA_FROM_QNAME : null;
maps.setFrom(decodeAsNative(
headerURI,
EndpointReferenceType.class,
headerElement,
unmarshaller));
} else if (Names.WSA_REPLYTO_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getReplyTo() != null
+ ? Names.WSA_REPLYTO_QNAME : null;
maps.setReplyTo(decodeAsNative(
headerURI,
EndpointReferenceType.class,
headerElement,
unmarshaller));
} else if (Names.WSA_FAULTTO_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getFaultTo() != null
+ ? Names.WSA_FAULTTO_QNAME : null;
maps.setFaultTo(decodeAsNative(
headerURI,
EndpointReferenceType.class,
@@ -555,6 +566,8 @@
headerElement,
unmarshaller));
} else if (Names.WSA_ACTION_NAME.equals(localName)) {
+ invalidCardinalityQName = maps.getAction() != null
+ ? Names.WSA_ACTION_QNAME : null;
maps.setAction(decodeAsNative(
headerURI,
AttributedURIType.class,
@@ -576,6 +589,9 @@
if (null != referenceParameterHeaders && null != maps) {
decodeReferenceParameters(referenceParameterHeaders, maps, unmarshaller);
}
+ if (invalidCardinalityQName != null) {
+ storeInvalidCardinalityFault(message, invalidCardinalityQName);
+ }
}
} catch (JAXBException je) {
LOG.log(Level.WARNING, "SOAP_HEADER_DECODE_FAILURE_MSG", je);
@@ -583,6 +599,13 @@
return maps;
}
+ private void storeInvalidCardinalityFault(SoapMessage message, QName wsaHeaderName) {
+ LOG.log(Level.WARNING, "INVALID_CARDINALITY_MESSAGE", wsaHeaderName);
+ String reason = BUNDLE.getString("INVALID_ADDRESSING_PROPERTY_MESSAGE");
+ ContextUtils.storeMAPFaultName(Names.INVALID_CARDINALITY_NAME, message);
+ ContextUtils.storeMAPFaultReason(reason, message);
+ }
+
private void decodeReferenceParameters(Set<Element> referenceParameterHeaders,
AddressingPropertiesImpl maps,
Unmarshaller unmarshaller)
Modified: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/Messages.properties
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/Messages.properties 2011-04-18 22:36:47 UTC (rev 14161)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/Messages.properties 2011-04-19 02:51:22 UTC (rev 14162)
@@ -24,3 +24,5 @@
IGNORE_NON_ELEMENT_REF_PARAM_MSG = Ignoring reference parameter {0} because it is not a JAXBElement
CORRELATION_FAILURE_MSG = Failed to correlate message, aborting dispatch.
RESPONSE_NOT_USING_WSADDRESSING = Response message does not contain WS-Addressing properties. Not correlating response.
+INVALID_CARDINALITY_MESSAGE = Duplicate WS-Addressing header {0}
+INVALID_ADDRESSING_PROPERTY_MESSAGE = A header representing a Message Addressing Property is not valid and the message cannot be processed
Modified: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java 2011-04-18 22:36:47 UTC (rev 14161)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/WSAClientServerTest.java 2011-04-19 02:51:22 UTC (rev 14162)
@@ -19,11 +19,20 @@
package org.apache.cxf.systest.ws.addr_feature;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
import java.net.URL;
import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.SOAPFaultException;
+import org.apache.cxf.helpers.IOUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.systest.ws.AbstractWSATestBase;
import org.apache.cxf.ws.addressing.WSAddressingFeature;
@@ -101,7 +110,40 @@
assertTrue(output.toString().indexOf(expectedOut) != -1);
assertTrue(input.toString().indexOf(expectedIn) != -1);
}
+
+ //CXF-3456
+ @Test
+ public void testDuplicateHeaders() throws Exception {
+ URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
+ assertNotNull("WSDL is null", wsdl);
+ AddNumbersService service = new AddNumbersService(wsdl, serviceName);
+ QName portName = new QName("http://apache.org/cxf/systest/ws/addr_feature/", "AddNumbersPort");
+ Dispatch<SOAPMessage> disp = service.createDispatch(portName, SOAPMessage.class,
+ Service.Mode.MESSAGE,
+ new AddressingFeature(false, false));
+ disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
+ "http://localhost:" + PORT + "/jaxws/add");
+
+ InputStream msgIns = getClass().getResourceAsStream("./duplicate-wsa-header-msg.xml");
+ String msg = new String(IOUtils.readBytesFromStream(msgIns));
+ msg = msg.replaceAll("$PORT", PORT);
+
+ ByteArrayInputStream bout = new ByteArrayInputStream(msg.getBytes());
+
+ SOAPMessage soapReqMsg = MessageFactory.newInstance().createMessage(null, bout);
+ assertNotNull(soapReqMsg);
+
+ try {
+ disp.invoke(soapReqMsg);
+ fail("SOAPFaultFxception is expected");
+ } catch (SOAPFaultException ex) {
+ assertTrue("WSA header exception is expected",
+ ex.getMessage().indexOf("A header representing a Message Addressing") > -1);
+ }
+ }
+
+
private AddNumbersPortType getPort() throws Exception {
URL wsdl = getClass().getResource("/wsdl_systest_wsspec/add_numbers.wsdl");
assertNotNull("WSDL is null", wsdl);
Added: thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/duplicate-wsa-header-msg.xml
===================================================================
--- thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/duplicate-wsa-header-msg.xml (rev 0)
+++ thirdparty/cxf/branches/cxf-2.3.3-patch-01-jaxwstck/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/addr_feature/duplicate-wsa-header-msg.xml 2011-04-19 02:51:22 UTC (rev 14162)
@@ -0,0 +1,21 @@
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
+ <soap:Header>
+ <Action xmlns="http://www.w3.org/2005/08/addressing">http://apache.org/cxf/systest/ws/addr_feature/AddNumbersPortType/addNumbers
+ </Action>
+ <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:19cbc77a-a910-4f41-8bc4-ecb0e7af34ab
+ </MessageID>
+ <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:$PORT$/jaxws/add</To>
+ <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
+ <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
+ </ReplyTo>
+ <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
+ <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
+ </ReplyTo>
+ </soap:Header>
+ <soap:Body>
+ <addNumbers xmlns="http://apache.org/cxf/systest/ws/addr_feature/">
+ <number1>1</number1>
+ <number2>2</number2>
+ </addNumbers>
+ </soap:Body>
+</soap:Envelope>
\ No newline at end of file
13 years, 8 months
JBossWS SVN: r14161 - in stack/cxf/trunk/modules/testsuite: cxf-tests and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-04-18 18:36:47 -0400 (Mon, 18 Apr 2011)
New Revision: 14161
Modified:
stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml
stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml
stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
Log:
[JBWS-3231] Copy jbossws-cxf-factories.jar to testsuite endorsed dirs in cxf-tests and cxf-spring-tests modules; this fix failures with Maven3 in org.jboss.test.ws.jaxws.samples.mtom.MtomTestCase
Modified: stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml 2011-04-18 21:12:55 UTC (rev 14160)
+++ stack/cxf/trunk/modules/testsuite/cxf-spring-tests/pom.xml 2011-04-18 22:36:47 UTC (rev 14161)
@@ -106,6 +106,29 @@
</execution>
</executions>
</plugin>
+ <plugin> <!-- This copies jbossws-cxf-factories jar to endorsed dir before the integration-tests are run -->
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-factories-jar</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/../../endorsed/target/</directory>
+ <includes>
+ <include>jbossws-cxf-factories-${project.version}.jar</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml 2011-04-18 21:12:55 UTC (rev 14160)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/pom.xml 2011-04-18 22:36:47 UTC (rev 14161)
@@ -74,6 +74,29 @@
</execution>
</executions>
</plugin>
+ <plugin> <!-- This copies jbossws-cxf-factories jar to endorsed dir before the integration-tests are run -->
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-factories-jar</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/../../endorsed/target/</directory>
+ <includes>
+ <include>jbossws-cxf-factories-${project.version}.jar</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2011-04-18 21:12:55 UTC (rev 14160)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2011-04-18 22:36:47 UTC (rev 14161)
@@ -152,6 +152,29 @@
</execution>
</executions>
</plugin>
+ <plugin> <!-- This copies jbossws-cxf-factories jar to endorsed dir before the integration-tests are run -->
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-factories-jar</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}/../../endorsed/target/</directory>
+ <includes>
+ <include>jbossws-cxf-factories-${project.version}.jar</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>
</profile>
13 years, 8 months
JBossWS SVN: r14160 - stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1172.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2011-04-18 17:12:55 -0400 (Mon, 18 Apr 2011)
New Revision: 14160
Modified:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1172/JBWS1172TestCase.java
Log:
[JBWS-2235] Adding fixed test case due to method signature changes
Modified: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1172/JBWS1172TestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1172/JBWS1172TestCase.java 2011-04-18 20:44:53 UTC (rev 14159)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/jaxws/jbws1172/JBWS1172TestCase.java 2011-04-18 21:12:55 UTC (rev 14160)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.ws.jaxws.jbws1172;
+import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.URL;
@@ -60,19 +61,19 @@
public void testSchemaValidationPositive() throws Exception
{
URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
- URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
+ InputStream[] xsdStreams = new SchemaExtractor().getSchemas(wsdlURL);
String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>1000</Code></performTest>";
- new SchemaValidationHelper(xsdURL).validateDocument(inxml);
+ new SchemaValidationHelper(xsdStreams).validateDocument(inxml);
}
public void testSchemaValidationNegative() throws Exception
{
URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
- URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
+ InputStream[] xsdStreams = new SchemaExtractor().getSchemas(wsdlURL);
String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>2000</Code></performTest>";
try
{
- new SchemaValidationHelper(xsdURL).validateDocument(inxml);
+ new SchemaValidationHelper(xsdStreams).validateDocument(inxml);
}
catch (SAXException ex)
{
@@ -84,18 +85,19 @@
public void testEndpointWsdlValidation() throws Exception
{
URL wsdlURL = new URL("http://" + getServerHost() + ":8080/jaxws-jbws1172/noval?wsdl");
- URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
+ InputStream[] xsdStreams = new SchemaExtractor().getSchemas(wsdlURL);
String inxml = "<performTest xmlns='http://www.my-company.it/ws/my-test'><Code>1000</Code></performTest>";
- new SchemaValidationHelper(xsdURL).validateDocument(inxml);
+ new SchemaValidationHelper(xsdStreams).validateDocument(inxml);
}
public void testValidatingClientWithExplicitSchema() throws Exception
{
URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
- URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
+ //URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
Service service = Service.create(wsdlURL, SERVICE_NAME);
- SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
+ //SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
+ SchemaValidationFeature feature = new SchemaValidationFeature();
MyTest port = service.getPort(MyTest.class, feature);
try
{
@@ -113,10 +115,11 @@
public void testValidatingClientWithErrorHandler() throws Exception
{
URL wsdlURL = getResourceURL("jaxws/jbws1172/WEB-INF/wsdl/TestService.wsdl");
- URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
+ //URL xsdURL = new SchemaExtractor().getSchemaUrl(wsdlURL);
Service service = Service.create(wsdlURL, SERVICE_NAME);
- SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
+ //SchemaValidationFeature feature = new SchemaValidationFeature(xsdURL.toString());
+ SchemaValidationFeature feature = new SchemaValidationFeature();
TestErrorHandler errorHandler = new TestErrorHandler();
feature.setErrorHandler(errorHandler);
13 years, 8 months
JBossWS SVN: r14159 - in stack/cxf/trunk/modules/testsuite: shared-tests and 1 other directories.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-04-18 16:44:53 -0400 (Mon, 18 Apr 2011)
New Revision: 14159
Modified:
stack/cxf/trunk/modules/testsuite/pom.xml
stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsconsume.xml
stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsprovide.xml
Log:
[JBWS-3229] Fixing wsprovide task invocation during testsuite build to use proper endorsed dirs
Modified: stack/cxf/trunk/modules/testsuite/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/pom.xml 2011-04-18 16:48:31 UTC (rev 14158)
+++ stack/cxf/trunk/modules/testsuite/pom.xml 2011-04-18 20:44:53 UTC (rev 14159)
@@ -999,9 +999,6 @@
<!-- # [JBWS-3227] handles config file not found on classpath -->
<exclude>org/jboss/test/ws/jaxws/jbws3034/**</exclude>
- <!-- # [JBWS-3229] DOMUtils issue on test classpath - probably missing xercesImpl on CP? -->
- <exclude>org/jboss/test/ws/jaxws/jbws2960/**</exclude>
-
<!-- # [JBWS-3232] javax.naming.NameNotFoundException: Name 'service' not found in context 'env' -->
<exclude>org/jboss/test/ws/jaxws/jbws3140/**</exclude>
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2011-04-18 16:48:31 UTC (rev 14158)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/pom.xml 2011-04-18 20:44:53 UTC (rev 14159)
@@ -124,7 +124,7 @@
<property name="project.version" value="${project.version}"/>
<property name="log4j.conf" value="${basedir}/src/test/etc/log4j.xml" />
<property name="log4j.output.dir" value="${log4j.output.dir}"/>
- <property name="jboss.home" value="${jboss.home}"/>
+ <property name="endorsed.dir" value="${project.build.directory}/endorsed"/>
<ant antfile="scripts/antrun-wsconsume.xml" target="wsconsume"/>
</tasks>
</configuration>
@@ -142,7 +142,7 @@
<property name="project.version" value="${project.version}"/>
<property name="log4j.conf" value="${basedir}/src/test/etc/log4j.xml"/>
<property name="log4j.output.dir" value="${log4j.output.dir}"/>
- <property name="jboss.home" value="${jboss.home}"/>
+ <property name="endorsed.dir" value="${project.build.directory}/endorsed"/>
<ant antfile="scripts/antrun-wsprovide.xml" target="wsprovide"/>
<ant antfile="src/test/ant-import/build-jars-jaxws.xml" target="build-jars-jaxws"/>
<ant antfile="src/test/ant-import/build-samples-jaxws.xml" target="build-samples-jaxws"/>
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsconsume.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsconsume.xml 2011-04-18 16:48:31 UTC (rev 14158)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsconsume.xml 2011-04-18 20:44:53 UTC (rev 14159)
@@ -20,7 +20,7 @@
wsdl="${tests.resources.dir}/jaxws/complex/META-INF/wsdl/RegistrationService.wsdl"
package="org.jboss.test.ws.jaxws.complex"
outputDir="${tests.output.dir}"
- jbossHome="${jboss.home}"
+ endorsedDir="${endorsed.dir}"
log4jConf="${log4j.conf}"
loggingDir="${log4j.output.dir}"
/>
@@ -29,7 +29,7 @@
wsdl="${tests.resources.dir}/jaxws/holder/META-INF/wsdl/HolderService.wsdl"
package="org.jboss.test.ws.jaxws.holder"
outputDir="${tests.output.dir}"
- jbossHome="${jboss.home}"
+ endorsedDir="${endorsed.dir}"
log4jConf="${log4j.conf}"
loggingDir="${log4j.output.dir}"
/>
@@ -41,7 +41,7 @@
<attribute name="wsdl"/>
<attribute name="package"/>
<attribute name="outputDir"/>
- <attribute name="jbossHome"/>
+ <attribute name="endorsedDir"/>
<attribute name="log4jConf"/>
<attribute name="loggingDir"/>
@@ -57,7 +57,7 @@
target="2.2"
fork="true"
>
- <jvmarg line="-Djava.endorsed.dirs=@{jbossHome}/lib/endorsed"/>
+ <jvmarg line="-Djava.endorsed.dirs=@{endorsedDir}"/>
<jvmarg line="-Dlog4j.configuration=file://@{log4jConf}"/>
<jvmarg line="-Dlog4j.output.dir=@{loggingDir}"/>
</wsconsume>
Modified: stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsprovide.xml
===================================================================
--- stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsprovide.xml 2011-04-18 16:48:31 UTC (rev 14158)
+++ stack/cxf/trunk/modules/testsuite/shared-tests/scripts/antrun-wsprovide.xml 2011-04-18 20:44:53 UTC (rev 14159)
@@ -19,7 +19,7 @@
<wsprovide-macro
sei="org.jboss.test.ws.jaxws.jbws2960.AddNumbersImpl"
destdir="jaxws/jbws2960"
- jbossHome="${jboss.home}"
+ endorsedDir="${endorsed.dir}"
outputDir="${tests.output.dir}"
log4jConf="${log4j.conf}"
loggingDir="${log4j.output.dir}"
@@ -32,7 +32,7 @@
<attribute name="sei"/>
<attribute name="destDir"/>
- <attribute name="jbossHome"/>
+ <attribute name="endorsedDir"/>
<attribute name="outputDir"/>
<attribute name="log4jConf"/>
<attribute name="loggingDir"/>
@@ -48,7 +48,7 @@
destdir="@{outputDir}/test-classes/@{destDir}"
resourcedestdir="@{outputDir}/test-resources/@{resourcesDir}"
>
- <jvmarg line="-Djava.endorsed.dirs=@{jbossHome}/lib/endorsed"/>
+ <jvmarg line="-Djava.endorsed.dirs=@{endorsedDir}"/>
<jvmarg line="-Dlog4j.configuration=file://@{log4jConf}"/>
<jvmarg line="-Dlog4j.output.dir=@{loggingDir}"/>
</wsprovide>
13 years, 8 months
JBossWS SVN: r14158 - stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros.
by jbossws-commits@lists.jboss.org
Author: alessio.soldano(a)jboss.com
Date: 2011-04-18 12:48:31 -0400 (Mon, 18 Apr 2011)
New Revision: 14158
Modified:
stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/Helper.java
Log:
[JBWS-3274] Fix testcase to properly use bus
Modified: stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/Helper.java
===================================================================
--- stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/Helper.java 2011-04-18 15:50:03 UTC (rev 14157)
+++ stack/cxf/trunk/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jaxbintros/Helper.java 2011-04-18 16:48:31 UTC (rev 14158)
@@ -123,7 +123,8 @@
}
BindingCustomizationFactory.populateBindingCustomization(jaxbIntroUrl.openStream(), jaxbCustomizations);
- Bus bus = BusFactory.getThreadDefaultBus();
+ Bus bus = BusFactory.newInstance().createBus();
+ BusFactory.setThreadDefaultBus(bus);
JBossWSConfigurer configurer = (JBossWSConfigurer)bus.getExtension(Configurer.class);
configurer.getCustomizer().setBindingCustomization(jaxbCustomizations);
return bus;
13 years, 8 months
JBossWS SVN: r14157 - in stack/native/trunk/modules/core/src/main/java/org/jboss/ws: extensions/validation and 1 other directory.
by jbossws-commits@lists.jboss.org
Author: klape
Date: 2011-04-18 11:50:03 -0400 (Mon, 18 Apr 2011)
New Revision: 14157
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyElementDoc.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaExtractor.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaValidationHelper.java
Log:
[JBWS-2235] initial code change for this jira
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyElementDoc.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyElementDoc.java 2011-04-18 15:02:02 UTC (rev 14156)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyElementDoc.java 2011-04-18 15:50:03 UTC (rev 14157)
@@ -21,6 +21,7 @@
*/
package org.jboss.ws.core.soap;
+import java.io.InputStream;
import java.net.URL;
import javax.xml.namespace.QName;
@@ -102,6 +103,7 @@
EndpointMetaData epMetaData = msgContext.getEndpointMetaData();
feature = epMetaData.getFeature(SchemaValidationFeature.class);
URL xsdURL = feature.getSchemaLocation() != null ? new URL(feature.getSchemaLocation()) : null;
+ InputStream[] xsdStreams = null;
if (xsdURL == null)
{
URL wsdlURL = epMetaData.getServiceMetaData().getWsdlFileOrLocation();
@@ -111,7 +113,7 @@
}
else
{
- xsdURL = schemaExtractor.getSchemaUrl(wsdlURL);
+ xsdStreams = schemaExtractor.getSchemas(wsdlURL);
}
}
if (xsdURL != null)
@@ -120,6 +122,12 @@
Element xmlDOM = DOMUtils.sourceToElement(source);
new SchemaValidationHelper(xsdURL).setErrorHandler(errorHandler).validateDocument(xmlDOM);
}
+ else //xsdStreams != null
+ {
+ ErrorHandler errorHandler = feature.getErrorHandler();
+ Element xmlDOM = DOMUtils.sourceToElement(source);
+ new SchemaValidationHelper(xsdStreams).setErrorHandler(errorHandler).validateDocument(xmlDOM);
+ }
}
catch (RuntimeException rte)
{
@@ -129,10 +137,6 @@
{
WSException.rethrow(ex);
}
- finally
- {
- schemaExtractor.close();
- }
}
private boolean isValidationEnabled()
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaExtractor.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaExtractor.java 2011-04-18 15:02:02 UTC (rev 14156)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaExtractor.java 2011-04-18 15:50:03 UTC (rev 14157)
@@ -25,8 +25,15 @@
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.FileInputStream;
import java.net.URL;
import java.util.List;
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
import javax.xml.namespace.QName;
@@ -48,9 +55,15 @@
private static Logger log = Logger.getLogger(SchemaExtractor.class);
private File xsdFile;
+ private String path;
- public URL getSchemaUrl(URL wsdlURL) throws IOException
+ public InputStream[] getSchemas(URL wsdlURL) throws IOException
{
+ //Get the path to the WSDL
+ Pattern p = Pattern.compile("[a-zA-Z]+\\.[a-zA-Z]+$");
+ Matcher m = p.matcher(wsdlURL.getFile());
+ path = m.replaceFirst("");
+
// parse the wsdl
Element root = DOMUtils.parse(wsdlURL.openStream());
@@ -77,25 +90,64 @@
}
Element schemaElement = schemaElements.get(0);
- File tmpdir = IOUtils.createTempDirectory();
- xsdFile = File.createTempFile("jbossws_schema", ".xsd", tmpdir);
- xsdFile.deleteOnExit();
+ List<InputStream> streams = new ArrayList<InputStream>();
- OutputStreamWriter outwr = new OutputStreamWriter(new FileOutputStream(xsdFile));
+ pullImportedSchemas(schemaElement, streams);
+
+ //Add the WSDL schema to the schema array
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ OutputStreamWriter outwr = new OutputStreamWriter( outStream );
DOMWriter domWriter = new DOMWriter(outwr);
domWriter.setPrettyprint(true);
domWriter.print(schemaElement);
- outwr.close();
- return xsdFile.toURL();
+ streams.add(new ByteArrayInputStream(outStream.toByteArray()));
+
+ return streams.toArray(new InputStream[streams.size()]);
}
-
- public void close()
+
+ private void pullImportedSchemas(Element schemaElement, List<InputStream> streams)
{
- if (xsdFile != null)
+ QName importQName = new QName( "http://www.w3.org/2001/XMLSchema", "import" );
+ List<Element> importElements = DOMUtils.getChildElementsAsList( schemaElement, importQName );
+
+ ArrayList<String> schemaLocations = new ArrayList<String>();
+ for( Element importElement : importElements )
{
- xsdFile.delete();
- xsdFile = null;
+ String schemaLocation = importElement.getAttribute( "schemaLocation" );
+ schemaLocations.add( schemaLocation );
}
+
+ ByteArrayOutputStream outStream = null;
+
+ for( int i=0; i < schemaLocations.size(); i++ )
+ {
+ String schemaLocation = schemaLocations.get( i );
+
+ try
+ {
+ FileInputStream in = new FileInputStream( path + schemaLocation );
+ outStream = new ByteArrayOutputStream();
+
+ int bt = 0;
+ while(( bt = in.read() ) != -1 )
+ {
+ outStream.write( (byte)bt );
+ }
+
+ InputStream inputStream = new ByteArrayInputStream(outStream.toByteArray());
+ inputStream.mark(0);
+
+ Element root = DOMUtils.parse(inputStream);
+ pullImportedSchemas(root, streams);
+
+ inputStream.reset();
+ streams.add(inputStream);
+ }
+ catch(IOException ioe)
+ {
+ log.warn("Error obtaining schema: " + path + schemaLocation);
+ }
+ }
}
}
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaValidationHelper.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaValidationHelper.java 2011-04-18 15:02:02 UTC (rev 14156)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/extensions/validation/SchemaValidationHelper.java 2011-04-18 15:50:03 UTC (rev 14157)
@@ -30,6 +30,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.jboss.logging.Logger;
import org.jboss.wsf.common.DOMWriter;
import org.w3c.dom.Element;
import org.xml.sax.ErrorHandler;
@@ -44,13 +45,21 @@
public class SchemaValidationHelper
{
private URL xsdURL;
+ private InputStream[] xsdStreams;
private ErrorHandler errorHandler = new StrictlyValidErrorHandler();
+
+ private static Logger log = Logger.getLogger(SchemaValidationHelper.class);
public SchemaValidationHelper(URL xsdURL)
{
this.xsdURL = xsdURL;
}
+ public SchemaValidationHelper(InputStream[] xsdStreams)
+ {
+ this.xsdStreams = xsdStreams;
+ }
+
public SchemaValidationHelper setErrorHandler(ErrorHandler errorHandler)
{
this.errorHandler = errorHandler;
@@ -79,14 +88,23 @@
DocumentBuilder builder = getDocumentBuilder();
builder.parse(inxml);
}
-
+
private DocumentBuilder getDocumentBuilder() throws ParserConfigurationException
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
- factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdURL.toExternalForm());
+
+ if(xsdStreams != null)
+ {
+ factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdStreams);
+ }
+ else //use xsdURL
+ {
+ factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", xsdURL.toExternalForm());
+ }
+
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(errorHandler);
13 years, 8 months
JBossWS SVN: r14156 - stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant.
by jbossws-commits@lists.jboss.org
Author: richard.opalka(a)jboss.com
Date: 2011-04-18 11:02:02 -0400 (Mon, 18 Apr 2011)
New Revision: 14156
Removed:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java
Log:
[JBWS-3273] fixing class collision with new jbossws-tools-common.jar module
Deleted: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java 2011-04-18 14:27:59 UTC (rev 14155)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/SecurityActions.java 2011-04-18 15:02:02 UTC (rev 14156)
@@ -1,112 +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.ws.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());
- }
- }
- }
-}
\ No newline at end of file
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java 2011-04-18 14:27:59 UTC (rev 14155)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/ant/wstools.java 2011-04-18 15:02:02 UTC (rev 14156)
@@ -21,6 +21,11 @@
*/
package org.jboss.ws.tools.ant;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.MatchingTask;
import org.apache.tools.ant.types.Path;
@@ -95,8 +100,8 @@
public void execute() throws BuildException
{
- ClassLoader prevCL = SecurityActions.getContextClassLoader();
- SecurityActions.setContextClassLoader(this.getClass().getClassLoader());
+ ClassLoader prevCL = getContextClassLoader();
+ setContextClassLoader(this.getClass().getClassLoader());
try
{
String[] args = new String[] { "-dest", dest, "-config", config };
@@ -116,7 +121,77 @@
}
finally
{
- SecurityActions.setContextClassLoader(prevCL);
+ setContextClassLoader(prevCL);
}
}
+
+ private static ClassLoader getContextClassLoader()
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm == null)
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ else
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+ }
+
+ /**
+ * Set context classloader.
+ *
+ * @param cl the classloader
+ * @return previous context classloader
+ * @throws Throwable for any error
+ */
+ private 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());
+ }
+ }
+ }
}
13 years, 8 months