Skip to content

Commit 090d286

Browse files
committed
1 parent 999e9d9 commit 090d286

30 files changed

+1490
-222
lines changed

sandbox/pom.xml

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
34
<parent>
45
<artifactId>spring-ws</artifactId>
@@ -21,6 +22,16 @@
2122
</plugin>
2223
</plugins>
2324
</build>
25+
<reporting>
26+
<plugins>
27+
<plugin>
28+
<artifactId>maven-javadoc-plugin</artifactId>
29+
<configuration>
30+
<stylesheetfile>${basedir}/../src/main/javadoc/javadoc.css</stylesheetfile>
31+
</configuration>
32+
</plugin>
33+
</plugins>
34+
</reporting>
2435
<dependencies>
2536
<!-- Spring-WS dependencies -->
2637
<dependency>
@@ -56,6 +67,11 @@
5667
<groupId>org.springframework</groupId>
5768
<artifactId>spring-jms</artifactId>
5869
</dependency>
70+
<dependency>
71+
<groupId>org.springframework</groupId>
72+
<artifactId>spring-remoting</artifactId>
73+
<version>${spring.version}</version>
74+
</dependency>
5975
<dependency>
6076
<groupId>org.springframework</groupId>
6177
<artifactId>spring-jmx</artifactId>
@@ -84,10 +100,10 @@
84100
<scope>provided</scope>
85101
</dependency>
86102
<dependency>
87-
<groupId>javax.jbi</groupId>
88-
<artifactId>jbi</artifactId>
89-
<version>1.0</version>
90-
<scope>provided</scope>
103+
<groupId>javax.ejb</groupId>
104+
<artifactId>ejb</artifactId>
105+
<version>2.1</version>
106+
<optional>true</optional>
91107
</dependency>
92108
<dependency>
93109
<groupId>javax.xml.ws</groupId>
@@ -127,5 +143,12 @@
127143
<version>6.0.1</version>
128144
<scope>test</scope>
129145
</dependency>
146+
<!-- Test dependencies -->
147+
<dependency>
148+
<groupId>easymock</groupId>
149+
<artifactId>easymock</artifactId>
150+
<version>1.2_Java1.3</version>
151+
<scope>test</scope>
152+
</dependency>
130153
</dependencies>
131154
</project>

sandbox/src/main/java/org/springframework/ws/transport/jms/JmsReceiverConnection.java

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@
3232
import org.apache.commons.logging.Log;
3333
import org.springframework.jms.support.JmsUtils;
3434
import org.springframework.util.Assert;
35+
import org.springframework.ws.FaultAwareWebServiceMessage;
3536
import org.springframework.ws.WebServiceMessage;
3637
import org.springframework.ws.transport.AbstractReceiverConnection;
38+
import org.springframework.ws.transport.FaultAwareWebServiceConnection;
39+
import org.springframework.ws.transport.jms.support.JmsTransportUtils;
3740

3841
/** @author Arjen Poutsma */
39-
public class JmsReceiverConnection extends AbstractReceiverConnection implements JmsTransportConstants {
42+
public class JmsReceiverConnection extends AbstractReceiverConnection
43+
implements JmsTransportConstants, FaultAwareWebServiceConnection {
4044

4145
private final Log logger;
4246

@@ -63,9 +67,6 @@ public boolean hasError() throws IOException {
6367
return false;
6468
}
6569

66-
public void close() throws IOException {
67-
}
68-
6970
/*
7071
* Receiving
7172
*/
@@ -102,15 +103,18 @@ protected InputStream getRequestInputStream() throws IOException {
102103
}
103104

104105
/*
105-
* Sending
106-
*/
106+
* Sending
107+
*/
107108

108109
protected void onSendBeforeWrite(WebServiceMessage message) throws IOException {
109110
try {
110111
responseMessage = session.createBytesMessage();
111112
responseMessage.setJMSCorrelationID(requestMessage.getJMSMessageID());
112113
responseMessage.setStringProperty(PROPERTY_BINDING_VERSION, "1.0");
113-
responseMessage.setBooleanProperty(PROPERTY_IS_FAULT, message.hasFault());
114+
if (message instanceof FaultAwareWebServiceMessage) {
115+
FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) message;
116+
responseMessage.setBooleanProperty(PROPERTY_IS_FAULT, faultMessage.hasFault());
117+
}
114118
}
115119
catch (JMSException ex) {
116120
throw new JmsTransportException("Could not create response message", ex);
@@ -152,4 +156,32 @@ protected void onSendAfterWrite(WebServiceMessage message) throws IOException {
152156
}
153157
}
154158

159+
public void close() throws IOException {
160+
}
161+
162+
/*
163+
* Faults
164+
*/
165+
166+
public boolean hasFault() throws IOException {
167+
try {
168+
return requestMessage.getBooleanProperty(JmsTransportConstants.PROPERTY_IS_FAULT);
169+
}
170+
catch (JMSException ex) {
171+
throw new JmsTransportException(ex);
172+
}
173+
}
174+
175+
public void setFault(boolean fault) throws IOException {
176+
if (responseMessage != null) {
177+
try {
178+
responseMessage.setBooleanProperty(JmsTransportConstants.PROPERTY_IS_FAULT, true);
179+
}
180+
catch (JMSException ex) {
181+
throw new JmsTransportException(ex);
182+
}
183+
}
184+
}
185+
186+
155187
}

sandbox/src/main/java/org/springframework/ws/transport/jms/JmsSenderConnection.java

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@
3737
import org.springframework.jms.connection.ConnectionFactoryUtils;
3838
import org.springframework.jms.support.JmsUtils;
3939
import org.springframework.util.Assert;
40+
import org.springframework.ws.FaultAwareWebServiceMessage;
4041
import org.springframework.ws.WebServiceMessage;
4142
import org.springframework.ws.transport.AbstractSenderConnection;
4243
import org.springframework.ws.transport.FaultAwareWebServiceConnection;
44+
import org.springframework.ws.transport.jms.support.JmsTransportUtils;
4345

4446
/** @author Arjen Poutsma */
4547
public class JmsSenderConnection extends AbstractSenderConnection
@@ -88,6 +90,14 @@ public BytesMessage getResponseMessage() {
8890
return responseMessage;
8991
}
9092

93+
public boolean hasError() throws IOException {
94+
return false;
95+
}
96+
97+
public String getErrorMessage() throws IOException {
98+
return null;
99+
}
100+
91101
/*
92102
* Sending
93103
*/
@@ -96,8 +106,11 @@ protected void onSendBeforeWrite(WebServiceMessage message) throws IOException {
96106
try {
97107
requestMessage = session.createBytesMessage();
98108
requestMessage.setStringProperty(PROPERTY_BINDING_VERSION, "1.0");
99-
requestMessage.setBooleanProperty(PROPERTY_IS_FAULT, message.hasFault());
100-
requestMessage.setStringProperty(PROPERTY_REQUEST_IRI, uri.getUri());
109+
if (message instanceof FaultAwareWebServiceMessage) {
110+
FaultAwareWebServiceMessage faultMessage = (FaultAwareWebServiceMessage) message;
111+
requestMessage.setBooleanProperty(PROPERTY_IS_FAULT, faultMessage.hasFault());
112+
}
113+
requestMessage.setStringProperty(PROPERTY_REQUEST_IRI, uri.toString());
101114
}
102115
catch (JMSException ex) {
103116
throw new JmsTransportException(ex);
@@ -176,6 +189,10 @@ protected void onReceiveBeforeRead() throws IOException {
176189
}
177190
}
178191

192+
protected boolean hasResponse() throws IOException {
193+
return responseMessage != null;
194+
}
195+
179196
protected Iterator getResponseHeaderNames() throws IOException {
180197
try {
181198
List headerNames = new ArrayList();
@@ -216,9 +233,9 @@ public void close() throws IOException {
216233
ConnectionFactoryUtils.releaseConnection(connection, connectionFactory, true);
217234
}
218235

219-
protected boolean hasResponse() throws IOException {
220-
return responseMessage != null;
221-
}
236+
/*
237+
* Faults
238+
*/
222239

223240
public boolean hasFault() throws IOException {
224241
if (responseMessage != null) {
@@ -234,11 +251,13 @@ public boolean hasFault() throws IOException {
234251
}
235252
}
236253

237-
public boolean hasError() throws IOException {
238-
return false;
254+
public void setFault(boolean fault) throws IOException {
255+
try {
256+
requestMessage.setBooleanProperty(JmsTransportConstants.PROPERTY_IS_FAULT, true);
257+
}
258+
catch (JMSException ex) {
259+
throw new JmsTransportException(ex);
260+
}
239261
}
240262

241-
public String getErrorMessage() throws IOException {
242-
return null;
243-
}
244263
}

sandbox/src/main/java/org/springframework/ws/transport/jms/JmsUri.java

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,17 @@
2828

2929
import org.springframework.util.Assert;
3030
import org.springframework.util.StringUtils;
31+
import org.springframework.ws.transport.support.ParameterizedUri;
3132

3233
/**
3334
* @author Arjen Poutsma
3435
* @see <a href="http://mail-archives.apache.org/mod_mbox/ws-axis-dev/200701.mbox/raw/%3C80A43FC052CE3949A327527DCD5D6B27020FB65C@MAIL01.bedford.progress.com%3E/2">RI
3536
* Scheme for Java Message Service 1.0 RC1</a>
3637
*/
37-
public class JmsUri implements JmsTransportConstants {
38-
39-
private final String uri;
40-
41-
private final String destination;
42-
43-
// keys are string parameter names; values are string parameter values
44-
private final Map parameters = new HashMap();
38+
public class JmsUri extends ParameterizedUri implements JmsTransportConstants {
4539

4640
public JmsUri(String uri) {
47-
Assert.hasLength(uri, "'uri' must not be empty");
48-
String scheme = URI_SCHEME + ":";
49-
Assert.isTrue(uri.startsWith(scheme), uri + " does not start with " + scheme);
50-
Assert.isTrue(uri.length() > scheme.length(), uri + " does not have a destination");
51-
int paramStart = uri.indexOf('?');
52-
if (paramStart == -1) {
53-
destination = uri.substring(scheme.length());
54-
}
55-
else {
56-
destination = uri.substring(scheme.length(), paramStart);
57-
parseParameters(uri.substring(paramStart + 1));
58-
}
59-
this.uri = uri;
60-
}
61-
62-
private void parseParameters(String parametersString) {
63-
StringTokenizer params = new StringTokenizer(parametersString, "&");
64-
while (params.hasMoreTokens()) {
65-
String param = params.nextToken();
66-
int paramSep = param.indexOf('=');
67-
if (paramSep == -1) {
68-
throw new IllegalArgumentException(param + " is not a valid parameter: it has no '='");
69-
}
70-
String paramName = param.substring(0, paramSep);
71-
String paramValue = param.substring(paramSep + 1);
72-
parameters.put(paramName, paramValue);
73-
}
41+
super(uri);
7442
validateParameters();
7543
}
7644

@@ -85,7 +53,7 @@ private void validateParameters() {
8553
}
8654

8755
private void validateIntegerParameter(String paramName) {
88-
String paramValue = (String) parameters.get(paramName);
56+
String paramValue = (String) getParameter(paramName);
8957
if (StringUtils.hasLength(paramValue)) {
9058
try {
9159
Integer.parseInt(paramValue);
@@ -106,17 +74,16 @@ public int getDeliveryMode() {
10674
return getIntegerParameter(PARAM_DELIVERY_MODE, Message.DEFAULT_DELIVERY_MODE);
10775
}
10876

109-
/** Returns thethe JNDI name of the destination queue or topic. */
11077
public String getDestination() {
111-
return destination;
78+
return super.getDestination();
11279
}
11380

11481
/**
11582
* Specifies whether the destination is a {@link Queue} or a {@link Topic}, with the value "<code>queue</code>" or
11683
* "<code>topic</code>", respectively.
11784
*/
11885
public String getDestinationType() {
119-
return (String) parameters.get(PARAM_DESTINATION_TYPE);
86+
return getParameter(PARAM_DESTINATION_TYPE);
12087
}
12188

12289
/**
@@ -134,23 +101,18 @@ public int getTimeToLive() {
134101
}
135102

136103
private int getIntegerParameter(String paramName, int defaultValue) {
137-
String paramValue = (String) parameters.get(paramName);
104+
String paramValue = getParameter(paramName);
138105
return paramValue != null ? Integer.parseInt(paramValue) : defaultValue;
139106
}
140107

141-
/** Returns the full JMS URI. */
142-
public String getUri() {
143-
return uri;
144-
}
145-
146108
/** Indicates whether this URI has a connection factory name. */
147109
public boolean hasConnectionFactoryName() {
148110
return StringUtils.hasLength(getConnectionFactoryName());
149111
}
150112

151113
/** Returns the JNDI name of the Java class providing the connection factory. */
152114
public String getConnectionFactoryName() {
153-
return (String) parameters.get(PARAM_CONNECTION_FACTORY_NAME);
115+
return getParameter(PARAM_CONNECTION_FACTORY_NAME);
154116
}
155117

156118
/** Indicates whether this URI has a "InitialContextFactory". */
@@ -164,7 +126,7 @@ public boolean hasInitialContextFactory() {
164126
* @see Context#INITIAL_CONTEXT_FACTORY
165127
*/
166128
public String getInitialContextFactory() {
167-
return (String) parameters.get(PARAM_INITIAL_CONTEXT_FACTORY);
129+
return getParameter(PARAM_INITIAL_CONTEXT_FACTORY);
168130
}
169131

170132
/** Indicates whether this URI has a JNDI provider URL. */
@@ -178,7 +140,7 @@ public boolean hasJndiUrl() {
178140
* @see Context#PROVIDER_URL
179141
*/
180142
public String getJndiUrl() {
181-
return (String) parameters.get(PARAM_JNDI_URL);
143+
return getParameter(PARAM_JNDI_URL);
182144
}
183145

184146
/** Indicates whether this URI has a reply-to name. */
@@ -192,7 +154,7 @@ public boolean hasReplyTo() {
192154
* @see Message#setJMSReplyTo(Destination)
193155
*/
194156
public String getReplyTo() {
195-
return (String) parameters.get(PARAM_REPLY_TO_NAME);
157+
return getParameter(PARAM_REPLY_TO_NAME);
196158
}
197159

198160
/**
@@ -203,8 +165,4 @@ public boolean isPubSubDomain() {
203165
return DESTINATION_TYPE_TOPIC.equals(getDestinationType());
204166
}
205167

206-
/** Returns the value of a custom parameter with the given name. */
207-
public String getCustomParameter(String paramName) {
208-
return (String) parameters.get(paramName);
209-
}
210168
}

sandbox/src/main/java/org/springframework/ws/transport/jms/JmsTransportUtils.java renamed to sandbox/src/main/java/org/springframework/ws/transport/jms/support/JmsTransportUtils.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.ws.transport.jms;
17+
package org.springframework.ws.transport.jms.support;
18+
19+
import org.springframework.ws.transport.jms.JmsTransportConstants;
1820

1921
/** @author Arjen Poutsma */
2022
public class JmsTransportUtils {

0 commit comments

Comments
 (0)