Author: richard.opalka(a)jboss.com
Date: 2008-02-28 11:32:23 -0500 (Thu, 28 Feb 2008)
New Revision: 5851
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMConstant.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerAbstractBase.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerHelper.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
Log:
preparation steps for RM faults serialization
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMConstant.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMConstant.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMConstant.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -23,6 +23,7 @@
public static final String REQUEST_CONTEXT = PREFIX + ".requestContext";
public static final String RESPONSE_CONTEXT = PREFIX + ".responseContext";
public static final String SEQUENCE_REFERENCE = PREFIX +
".sequenceReference";
+ public static final String FAULT_REFERENCE = PREFIX + ".faultReference";
public static final String PROTOCOL_MESSAGES = PREFIX +
".protocolMessages";
public static final String PROTOCOL_MESSAGES_MAPPING = PREFIX +
".protocolMessagesMapping";
public static final String WSA_MESSAGE_ID = PREFIX + ".wsaMessageId";
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java 2008-02-28
15:17:44 UTC (rev 5850)
+++ stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFault.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -79,4 +79,10 @@
return this.details;
}
+ @Override
+ public String getMessage()
+ {
+ return faultCode.getSubcode() + ": " + faultCode.getReason();
+ }
+
}
Modified: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMFaultCode.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -21,6 +21,8 @@
*/
package org.jboss.ws.extensions.wsrm;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceFaultCode;
+
/**
* RM fault constants
*
@@ -32,7 +34,7 @@
public final class RMFaultCode
{
- private final String subcode;
+ private final RMSequenceFaultCode subcode;
private final String reason;
/**
@@ -47,8 +49,8 @@
* </p>
*/
public static final RMFaultCode SEQUENCE_TERMINATED = new RMFaultCode(
- "SequenceTerminated",
- "The Sequence has been terminated due to an unrecoverable error."
+ RMSequenceFaultCode.SEQUENCE_TERMINATED,
+ "The Sequence has been terminated due to an unrecoverable error."
);
/**
@@ -64,8 +66,8 @@
* </p>
*/
public static final RMFaultCode UNKNOWN_SEQUENCE = new RMFaultCode(
- "UnknownSequence",
- "The value of wsrm:Identifier is not a known Sequence identifier."
+ RMSequenceFaultCode.UNKNOWN_SEQUENCE,
+ "The value of wsrm:Identifier is not a known Sequence identifier."
);
/**
@@ -82,13 +84,14 @@
* </p>
*/
public static final RMFaultCode INVALID_ACKNOWLEDGEMENT = new RMFaultCode(
- "InvalidAcknowledgement",
- "The SequenceAcknowledgement violates the cumulative Acknowledgement
invariant."
+ RMSequenceFaultCode.INVALID_ACKNOWLEDGEMENT,
+ "The SequenceAcknowledgement violates the cumulative Acknowledgement
invariant."
);
/**
* Message number in /wsrm:Sequence/wsrm:MessageNumber of a Received
- * message exceeds the internal limitations of an RM Destination
+ * message exceeds the internal limitations of an RM Destination.
+ * It is an unrecoverable error and terminates the Sequence.
* <p>
* <table>
* <tr><td>[Code]</td><td>Sender</td></tr>
@@ -103,8 +106,8 @@
* </p>
*/
public static final RMFaultCode MESSAGE_NUMBER_ROLLOVER = new RMFaultCode(
- "MessageNumberRollover",
- "The maximum value for wsrm:MessageNumber has been exceeded."
+ RMSequenceFaultCode.MESSAGE_NUMBER_ROLLOVER,
+ "The maximum value for wsrm:MessageNumber has been exceeded."
);
/**
@@ -120,8 +123,8 @@
* </p>
*/
public static final RMFaultCode CREATE_SEQUENCE_REFUSED = new RMFaultCode(
- "CreateSequenceRefused",
- "The Create Sequence request has been refused by the RM Destination."
+ RMSequenceFaultCode.CREATE_SEQUENCE_REFUSED,
+ "The Create Sequence request has been refused by the RM Destination."
);
/**
@@ -139,15 +142,14 @@
* </p>
*/
public static final RMFaultCode SEQUENCE_CLOSED = new RMFaultCode(
- "SequenceClosed",
- "The Sequence is closed and cannot accept new messages."
+ RMSequenceFaultCode.SEQUENCE_CLOSED,
+ "The Sequence is closed and cannot accept new messages."
);
/**
* If an RM Destination requires the use of WS-RM,
* this fault is generated when it Receives an incoming
* message that did not use this protocol.
- *
* <p>
* <table>
* <tr><td>[Code]</td><td>Sender</td></tr>
@@ -158,16 +160,35 @@
* </p>
*/
public static final RMFaultCode WSRM_REQUIRED = new RMFaultCode(
- "WSRMRequired",
- "The RM Destination requires the use of WSRM"
+ RMSequenceFaultCode.WSRM_REQUIRED,
+ "The RM Destination requires the use of WSRM"
);
+
+ /**
+ * This fault is sent by an RM Destination to indicate that it has received a message
that
+ * has a <MessageNumber> within a Sequence that exceeds the value of
the
+ * <MessageNumber> element that accompanied a
<LastMessage> element for the
+ * Sequence. This is an unrecoverable error and terminates the Sequence.
+ * <p>
+ * <table>
+ * <tr><td>[Code]</td><td>Sender</td></tr>
+ *
<tr><td>[Subcode]</td><td>wsrm:LastMessageNumberExceeded</td></tr>
+ * <tr><td>[Reason]</td><td>The value for wsrm:MessageNumber
exceeds the value of the MessageNumber accompanying a LastMessage element in this
Sequence.</td></tr>
+ * <tr><td>[Detail]</td><td><wsrm:Identifier...>
xs:anyURI </wsrm:Identifier></td></tr>
+ * </table>
+ * </p>
+ */
+ public static final RMFaultCode LAST_MESSAGE_NUMBER_EXCEEDED = new RMFaultCode(
+ RMSequenceFaultCode.LAST_MESSAGE_NUMBER_EXCEEDED,
+ "The value for wsrm:MessageNumber exceeds the value of the MessageNumber
accompanying a LastMessage element in this Sequence"
+ );
/**
* Hidden constructor
* @param subcode the subcode
* @param reason message
*/
- private RMFaultCode(String subcode, String reason)
+ private RMFaultCode(RMSequenceFaultCode subcode, String reason)
{
super();
this.subcode = subcode;
@@ -178,7 +199,7 @@
* Gets subcode
* @return subcode
*/
- public final String getSubcode()
+ public final RMSequenceFaultCode getSubcode()
{
return this.subcode;
}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerAbstractBase.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerAbstractBase.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerAbstractBase.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -31,6 +31,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
import org.jboss.ws.extensions.wsrm.RMConstant;
+import org.jboss.ws.extensions.wsrm.RMFault;
import org.jboss.ws.extensions.wsrm.RMSequence;
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSerializable;
@@ -78,4 +79,15 @@
catch (RMException ignore) {}
}
+ protected final void serialize(QName msgQN, List<QName> outMsgs, Map<QName,
RMSerializable> data, SOAPMessage soapMessage, RMFault fault)
+ {
+ RMSerializable msg = RMHandlerHelper.prepareData(msgQN, outMsgs, fault);
+ if (msg != null)
+ {
+ msg.serializeTo(soapMessage);
+ data.put(msgQN, msg);
+ log.debug(msgQN.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+ }
+
}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerHelper.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerHelper.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandlerHelper.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -26,6 +26,7 @@
import javax.xml.namespace.QName;
+import org.jboss.ws.extensions.wsrm.RMFault;
import org.jboss.ws.extensions.wsrm.RMSequence;
import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
@@ -37,6 +38,7 @@
import org.jboss.ws.extensions.wsrm.spi.protocol.RMCreateSequence;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMCreateSequenceResponse;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceAcknowledgement;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceFault;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSerializable;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMTerminateSequence;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMTerminateSequenceResponse;
@@ -143,6 +145,29 @@
return null;
}
+ public static RMSerializable prepareData(QName msgQN, List<QName> outMsgs,
RMFault fault)
+ {
+ if (outMsgs.contains(msgQN))
+ {
+ if (rmConstants.getSequenceFaultQName().equals(msgQN))
+ {
+ return newSequenceFault(fault);
+ }
+
+ throw new IllegalArgumentException(msgQN.toString());
+ }
+
+ return null;
+ }
+
+ private static RMSerializable newSequenceFault(RMFault fault)
+ {
+ RMSequenceFault sequenceFault = rmFactory.newSequenceFault();
+ sequenceFault.setDetail(fault);
+ sequenceFault.setFaultCode(fault.getFaultCode().getSubcode());
+ return sequenceFault;
+ }
+
private static RMSerializable newCreateSequence(RMSequence seq)
{
RMCreateSequence createSequence = rmFactory.newCreateSequence();
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -36,8 +36,8 @@
import org.jboss.ws.core.CommonMessageContext;
import org.jboss.ws.extensions.wsrm.RMConstant;
+import org.jboss.ws.extensions.wsrm.RMFault;
import org.jboss.ws.extensions.wsrm.RMSequence;
-import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSerializable;
@@ -88,10 +88,8 @@
serialize(rmConstants.getSequenceAcknowledgementQName(), outMsgs, data,
soapMessage, sequenceImpl);
if ((outMsgs.size() != 0) && (data.size() == 0))
- throw new RMException("RM handler have not serialized WS-RM message to the
payload");
+ throw new IllegalStateException("RM handler have not serialized WS-RM
message to the payload");
- // TODO: implement SequenceFault serialization
-
return true;
}
@@ -127,7 +125,7 @@
deserialize(rmConstants.getTerminateSequenceQName(), soapMessage, messages, data);
if (data.size() == 0)
- throw new RMException("RM handler was not able to find WS-RM message in the
payload");
+ throw new IllegalStateException("RM handler was not able to find WS-RM
message in the payload");
// propagate RM response context to higher layers
msgContext.put(RMConstant.REQUEST_CONTEXT, rmResponseContext);
@@ -136,4 +134,28 @@
return true;
}
+ @Override
+ public boolean handleFault(MessageContext msgContext)
+ {
+ log.debug("handling fault message");
+ CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
+ SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)commonMsgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+ Map<String, Object> rmOutboundContext = (Map<String,
Object>)commonMsgContext.get(RMConstant.RESPONSE_CONTEXT);
+ List<QName> outMsgs =
(List<QName>)rmOutboundContext.get(RMConstant.PROTOCOL_MESSAGES);
+ Map<QName, RMSerializable> data = new HashMap<QName,
RMSerializable>();
+ String optionalMessageId = (addrProps.getMessageID() != null) ?
addrProps.getMessageID().getURI().toString() : null;
+ rmOutboundContext.put(RMConstant.WSA_MESSAGE_ID, optionalMessageId);
+ rmOutboundContext.put(RMConstant.PROTOCOL_MESSAGES_MAPPING, data);
+ SOAPMessage soapMessage = ((SOAPMessageContext)commonMsgContext).getMessage();
+ RMFault sequenceFault =
(RMFault)rmOutboundContext.get(RMConstant.FAULT_REFERENCE);
+
+ // try to serialize SequenceFault to message
+ serialize(rmConstants.getSequenceFaultQName(), outMsgs, data, soapMessage,
sequenceFault);
+
+ if ((outMsgs.size() != 0) && (data.size() == 0))
+ throw new IllegalStateException("RM handler have not serialized WS-RM
message to the payload");
+
+ return true;
+ }
+
}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-28
15:17:44 UTC (rev 5850)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/server/RMInvocationHandler.java 2008-02-28
16:32:23 UTC (rev 5851)
@@ -293,7 +293,22 @@
@Override
public final void invoke(Endpoint ep, Invocation inv) throws Exception
{
- Map<String, Object> rmResponseContext = prepareResponseContext(ep, inv,
this.dataDir);
+ Map<String, Object> rmResponseContext = null;
+ try
+ {
+ rmResponseContext = prepareResponseContext(ep, inv, this.dataDir);
+ }
+ catch (RMFault fault)
+ {
+ rmResponseContext = new HashMap<String, Object>();
+ List<QName> protocolMessages = new LinkedList<QName>();
+ protocolMessages.add(rmConstants.getSequenceFaultQName());
+ rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES, protocolMessages);
+ rmResponseContext.put(RMConstant.FAULT_REFERENCE, fault);
+ CommonMessageContext msgCtx = MessageContextAssociation.peekMessageContext();
+ msgCtx.put(RMConstant.RESPONSE_CONTEXT, rmResponseContext);
+ throw fault; // rethrow
+ }
if (inv.getJavaMethod() != null)
{