Author: richard.opalka(a)jboss.com
Date: 2007-12-12 07:37:50 -0500 (Wed, 12 Dec 2007)
New Revision: 5265
Added:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientSequenceImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceIface.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMClientHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java
Removed:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientHandler.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMTransportHelper.java
stack/native/trunk/src/test/resources/jaxws/wsrm/META-INF/wsrm-jaxws-client-config.xml
Log:
creating server side RM handler
Modified: stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/core/jaxws/client/ClientImpl.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -67,7 +67,7 @@
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.extensions.addressing.AddressingClientUtil;
import org.jboss.ws.extensions.wsrm.RMConstant;
-import org.jboss.ws.extensions.wsrm.RMSequenceImpl;
+import org.jboss.ws.extensions.wsrm.RMClientSequenceImpl;
import org.jboss.ws.extensions.wsrm.api.RMException;
import org.jboss.ws.extensions.wsrm.common.RMHelper;
import org.jboss.ws.extensions.wsrm.spi.RMConstants;
@@ -105,14 +105,14 @@
private static HandlerType[] HANDLER_TYPES = new HandlerType[] { HandlerType.PRE,
HandlerType.ENDPOINT, HandlerType.POST };
// WS-RM sequence associated with the proxy
- private RMSequenceImpl wsrmSequence;
+ private RMClientSequenceImpl wsrmSequence;
- public final void setWSRMSequence(RMSequenceImpl wsrmSequence)
+ public final void setWSRMSequence(RMClientSequenceImpl wsrmSequence)
{
this.wsrmSequence = wsrmSequence;
}
- public final RMSequenceImpl getWSRMSequence()
+ public final RMClientSequenceImpl getWSRMSequence()
{
return this.wsrmSequence;
}
@@ -513,7 +513,7 @@
try
{
// set up addressing data
- RMSequenceImpl candidateSequence = new RMSequenceImpl(addressableClient,
getEndpointMetaData().getConfig().getRMMetaData());
+ RMClientSequenceImpl candidateSequence = new
RMClientSequenceImpl(addressableClient,
getEndpointMetaData().getConfig().getRMMetaData());
String address = getEndpointMetaData().getEndpointAddress();
String action = RMConstant.CREATE_SEQUENCE_WSA_ACTION;
AddressingProperties addressingProps = null;
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientHandler.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientHandler.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -1,318 +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.ws.extensions.wsrm;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.addressing.JAXWSAConstants;
-import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
-import javax.xml.ws.handler.MessageContext;
-import javax.xml.ws.handler.MessageContext.Scope;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.CommonMessageContext;
-import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
-import org.jboss.ws.extensions.wsrm.api.RMException;
-import org.jboss.ws.extensions.wsrm.spi.RMConstants;
-import org.jboss.ws.extensions.wsrm.spi.RMMessageFactory;
-import org.jboss.ws.extensions.wsrm.spi.RMProvider;
-import org.jboss.ws.extensions.wsrm.spi.protocol.RMAckRequested;
-import org.jboss.ws.extensions.wsrm.spi.protocol.RMCloseSequence;
-import org.jboss.ws.extensions.wsrm.spi.protocol.RMCloseSequenceResponse;
-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.RMSequence;
-import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceAcknowledgement;
-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;
-
-/**
- * TODO: add comment
- *
- * @author richard.opalka(a)jboss.com
- *
- * @since Oct 23, 2007
- */
-@SuppressWarnings("unchecked")
-public final class RMClientHandler extends GenericSOAPHandler
-{
- private static final Logger log = Logger.getLogger(RMClientHandler.class);
- private static final RMMessageFactory rmFactory =
RMProvider.get().getMessageFactory();
- private static final RMConstants rmConstants = RMProvider.get().getConstants();
- private static final Set headers = RMConstant.PROTOCOL_OPERATION_QNAMES;
-
- public Set getHeaders()
- {
- return headers;
- }
-
- protected boolean handleOutbound(MessageContext msgContext)
- {
- log.debug("handling outbound message");
-
- CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
- SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)commonMsgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
- if (addrProps == null)
- throw new RMException("WS-Addressing properties not found in message
context");
-
- Map rmRequestContext = (Map)commonMsgContext.get(RMConstant.REQUEST_CONTEXT);
- List<QName> outMsgs =
(List<QName>)rmRequestContext.get(RMConstant.PROTOCOL_MESSAGES);
- Map<QName, RMSerializable> data = new HashMap<QName,
RMSerializable>();
- String optionalMessageId = (addrProps.getMessageID() != null) ?
addrProps.getMessageID().getURI().toString() : null;
- rmRequestContext.put(RMConstant.WSA_MESSAGE_ID, optionalMessageId);
- rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES_MAPPING, data);
- SOAPMessage soapMessage = ((SOAPMessageContext)commonMsgContext).getMessage();
- RMSequenceImpl sequenceImpl =
(RMSequenceImpl)rmRequestContext.get(RMConstant.SEQUENCE_REFERENCE);
-
- QName msgQName = rmConstants.getCreateSequenceQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize CreateSequence to message
- String replyTo = addrProps.getReplyTo().getAddress().getURI().toString();
- RMCreateSequence createSequence = rmFactory.newCreateSequence();
- createSequence.setAcksTo(replyTo);
- createSequence.serializeTo(soapMessage);
- data.put(msgQName, createSequence);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getSequenceQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize Sequence to message
- RMSequence sequence = rmFactory.newSequence();
- sequence.setIdentifier(sequenceImpl.getOutboundId());
- sequence.setMessageNumber(sequenceImpl.newMessageNumber());
- sequence.serializeTo(soapMessage);
- data.put(msgQName, sequence);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getAckRequestedQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize AckRequested to message
- RMAckRequested ackRequested = rmFactory.newAckRequested();
- ackRequested.setIdentifier(sequenceImpl.getOutboundId());
- ackRequested.setMessageNumber(sequenceImpl.getLastMessageNumber());
- ackRequested.serializeTo(soapMessage);
- data.put(msgQName, ackRequested);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getCloseSequenceQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize CloseSequence to message
- RMCloseSequence closeSequence = rmFactory.newCloseSequence();
- closeSequence.setIdentifier(sequenceImpl.getOutboundId());
- closeSequence.setLastMsgNumber(sequenceImpl.getLastMessageNumber());
- closeSequence.serializeTo(soapMessage);
- data.put(msgQName, closeSequence);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getCloseSequenceResponseQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize CloseSequenceResponse to message
- RMCloseSequenceResponse closeSequenceResponse =
rmFactory.newCloseSequenceResponse();
- closeSequenceResponse.setIdentifier(sequenceImpl.getOutboundId());
- data.put(msgQName, closeSequenceResponse);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getTerminateSequenceQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize TerminateSequence to message
- RMTerminateSequence terminateSequence = rmFactory.newTerminateSequence();
- terminateSequence.setIdentifier(sequenceImpl.getOutboundId());
- terminateSequence.setLastMsgNumber(sequenceImpl.getLastMessageNumber());
- terminateSequence.serializeTo(soapMessage);
- data.put(msgQName, terminateSequence);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getTerminateSequenceResponseQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize terminateSequenceResponse to message
- RMTerminateSequenceResponse terminateSequenceResponse =
rmFactory.newTerminateSequenceResponse();
- terminateSequenceResponse.setIdentifier(sequenceImpl.getOutboundId());
- terminateSequenceResponse.serializeTo(soapMessage);
- data.put(msgQName, terminateSequenceResponse);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- msgQName = rmConstants.getSequenceAcknowledgementQName();
- if (outMsgs.contains(msgQName))
- {
- // try to serialize SequenceAcknowledgement to message
- RMSequenceAcknowledgement sequenceAcknowledgement =
rmFactory.newSequenceAcknowledgement();
- sequenceAcknowledgement.setIdentifier(sequenceImpl.getInboundId());
- Iterator<Long> receivedInboudMessages =
sequenceImpl.getReceivedInboundMessages().iterator();
- while (receivedInboudMessages.hasNext())
- {
- long messageNo = receivedInboudMessages.next();
- RMSequenceAcknowledgement.RMAcknowledgementRange range =
sequenceAcknowledgement.newAcknowledgementRange();
- range.setLower(messageNo);
- range.setUpper(messageNo);
- sequenceAcknowledgement.addAcknowledgementRange(range);
- }
- sequenceAcknowledgement.serializeTo(soapMessage);
- data.put(msgQName, sequenceAcknowledgement);
- log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
- }
-
- // TODO: implement SequenceFault serialization
-
- return true;
- }
-
- protected boolean handleInbound(MessageContext msgContext)
- {
- log.debug("handling inbound message");
-
- SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
- Map<String, Object> rmResponseContext = new HashMap();
- List<QName> messages = new LinkedList<QName>();
- rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES, messages);
- Map<QName, RMSerializable> data = new HashMap<QName,
RMSerializable>();
- rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES_MAPPING, data);
- msgContext.put(RMConstant.RESPONSE_CONTEXT, rmResponseContext);
- msgContext.setScope(RMConstant.RESPONSE_CONTEXT, Scope.APPLICATION);
-
- try
- {
- // try to deserialize CreateSequenceResponse from message
- QName msgQName = rmConstants.getCreateSequenceResponseQName();
- RMCreateSequenceResponse wsrmMsg = rmFactory.newCreateSequenceResponse();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize AckRequested from message
- QName msgQName = rmConstants.getAckRequestedQName();
- RMAckRequested wsrmMsg = rmFactory.newAckRequested();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize Sequence from message
- QName msgQName = rmConstants.getSequenceQName();
- RMSequence wsrmMsg = rmFactory.newSequence();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize SequenceAcknowledgement from message
- QName msgQName = rmConstants.getSequenceAcknowledgementQName();
- RMSequenceAcknowledgement wsrmMsg = rmFactory.newSequenceAcknowledgement();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize CloseSequence from message
- QName msgQName = rmConstants.getCloseSequenceQName();
- RMCloseSequence wsrmMsg = rmFactory.newCloseSequence();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize CloseSequence from message
- QName msgQName = rmConstants.getCloseSequenceResponseQName();
- RMCloseSequenceResponse wsrmMsg = rmFactory.newCloseSequenceResponse();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize TerminateSequence from message
- QName msgQName = rmConstants.getTerminateSequenceQName();
- RMTerminateSequence wsrmMsg = rmFactory.newTerminateSequence();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- try
- {
- // try to deserialize TerminateSequenceResponse from message
- QName msgQName = rmConstants.getTerminateSequenceResponseQName();
- RMTerminateSequenceResponse wsrmMsg = rmFactory.newTerminateSequenceResponse();
- wsrmMsg.deserializeFrom(soapMessage);
- messages.add(msgQName);
- data.put(msgQName, wsrmMsg);
- log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
- }
- catch (RMException ignore) {}
-
- // TODO: implement SequenceFault deserialization
-
- if (data.size() == 0)
- throw new RMException("RM handler was not able to find WS-RM message in the
payload");
-
- return true;
- }
-
-}
Added:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientSequenceImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientSequenceImpl.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientSequenceImpl.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -0,0 +1,326 @@
+/*
+ * 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.ws.extensions.wsrm;
+
+import java.net.InetAddress;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.addressing.AddressingBuilder;
+import javax.xml.ws.addressing.AddressingProperties;
+import javax.xml.ws.addressing.JAXWSAConstants;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.jaxws.client.ClientImpl;
+import org.jboss.ws.core.utils.UUIDGenerator;
+import org.jboss.ws.extensions.addressing.AddressingClientUtil;
+import org.jboss.ws.extensions.wsrm.config.RMConfig;
+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.RMIncompleteSequenceBehavior;
+import org.jboss.ws.extensions.wsrm.transport.RMUnassignedMessageListener;
+
+/**
+ * Client side implementation of the RM sequence
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Oct 25, 2007
+ */
+@SuppressWarnings("unchecked")
+public final class RMClientSequenceImpl implements RMSequenceIface,
RMUnassignedMessageListener
+{
+ private static final Logger logger = Logger.getLogger(RMClientSequenceImpl.class);
+ private static final String PATH_PREFIX = "/temporary_listen_address/";
+ private static final RMConstants wsrmConstants = RMProvider.get().getConstants();
+
+ private final RMConfig wsrmConfig;
+ private final boolean addressableClient;
+ private final Set<Long> acknowledgedOutboundMessages = new
TreeSet<Long>();
+ private final Set<Long> receivedInboundMessages = new TreeSet<Long>();
+ private RMIncompleteSequenceBehavior behavior =
RMIncompleteSequenceBehavior.NO_DISCARD;
+ private String incomingSequenceId;
+ private String outgoingSequenceId;
+ private long duration = -1;
+ private long creationTime;
+ private URI backPort;
+ private ClientImpl client;
+ private boolean isFinal;
+ private AtomicBoolean inboundMessageAckRequested = new AtomicBoolean();
+ private AtomicLong messageNumber = new AtomicLong();
+ private AtomicInteger countOfUnassignedMessagesAvailable = new AtomicInteger();
+
+ public RMClientSequenceImpl(boolean addrType, RMConfig wsrmConfig)
+ {
+ super();
+ if (wsrmConfig == null)
+ throw new RMException("WS-RM configuration missing");
+ if (wsrmConfig.getBackPortsServer() == null)
+ throw new RMException("WS-RM backports server configuration
missing");
+
+ this.addressableClient = addrType;
+ this.wsrmConfig = wsrmConfig;
+ try
+ {
+ String host = wsrmConfig.getBackPortsServer().getHost();
+ if (host == null)
+ {
+ host = InetAddress.getLocalHost().getCanonicalHostName();
+ logger.debug("Backports server configuration omits host configuration -
using autodetected " + host);
+ }
+ String port = wsrmConfig.getBackPortsServer().getPort();
+ String path = PATH_PREFIX + UUIDGenerator.generateRandomUUIDString();
+ this.backPort = new URI("http://" + host + ":" + port +
path);
+ }
+ catch (URISyntaxException use)
+ {
+ logger.warn(use);
+ throw new RMException(use.getMessage(), use);
+ }
+ catch (UnknownHostException uhe)
+ {
+ logger.warn(uhe);
+ throw new RMException(uhe.getMessage(), uhe);
+ }
+ }
+
+ public void unassignedMessageReceived()
+ {
+ // we can't use objectLock in the method - possible deadlock
+ this.countOfUnassignedMessagesAvailable.addAndGet(1);
+ logger.debug("Expected sequence expiration in " +
((System.currentTimeMillis() - this.creationTime) / 1000) + "seconds");
+ logger.debug("Unassigned message available in callback handler");
+ }
+
+ public final RMConfig getRMConfig()
+ {
+ return this.wsrmConfig;
+ }
+
+ public final Set<Long> getReceivedInboundMessages()
+ {
+ return this.receivedInboundMessages;
+ }
+
+ public final BindingProvider getBindingProvider()
+ {
+ return (BindingProvider)this.client;
+ }
+
+ public final void setFinal()
+ {
+ this.isFinal = true;
+ logger.debug("Sequence " + this.outgoingSequenceId + " state changed
to final");
+ }
+
+ public final void ackRequested(boolean requested)
+ {
+ this.inboundMessageAckRequested.set(requested);
+ logger.debug("Inbound Sequence: " + this.incomingSequenceId + ", ack
requested. Messages in the queue: " + this.receivedInboundMessages);
+ }
+
+ public final boolean isAckRequested()
+ {
+ return this.inboundMessageAckRequested.get();
+ }
+
+ public final void addReceivedInboundMessage(long messageId)
+ {
+ this.receivedInboundMessages.add(messageId);
+ logger.debug("Inbound Sequence: " + this.incomingSequenceId + ",
received message no. " + messageId);
+ }
+
+ public final void addReceivedOutboundMessage(long messageId)
+ {
+ this.acknowledgedOutboundMessages.add(messageId);
+ logger.debug("Outbound Sequence: " + this.outgoingSequenceId + ",
message no. " + messageId + " acknowledged by server");
+ }
+
+ public final void setOutboundId(String outboundId)
+ {
+ this.outgoingSequenceId = outboundId;
+ }
+
+ public final void setInboundId(String inboundId)
+ {
+ this.incomingSequenceId = inboundId;
+ }
+
+ public final void setClient(ClientImpl client)
+ {
+ this.client = client;
+ }
+
+ public final void setDuration(long duration)
+ {
+ if (duration > 0)
+ {
+ this.creationTime = System.currentTimeMillis();
+ this.duration = duration;
+ }
+ }
+
+ public final long getDuration()
+ {
+ return this.duration;
+ }
+
+ public final URI getBackPort()
+ {
+ // no need for synchronization
+ return (this.addressableClient) ? this.backPort : null;
+ }
+
+ public final long newMessageNumber()
+ {
+ // no need for synchronization
+ return this.messageNumber.incrementAndGet();
+ }
+
+ public final long getLastMessageNumber()
+ {
+ // no need for synchronization
+ return this.messageNumber.get();
+ }
+
+ public final void close() throws RMException
+ {
+ try
+ {
+ sendCloseMessage();
+ sendTerminateMessage();
+ }
+ finally
+ {
+ this.client.setWSRMSequence(null);
+ }
+ }
+
+ /**
+ * Sets up terminated flag to true.
+ */
+ private void sendMessage(String action, QName operationQName, List protocolMessages)
throws RMException
+ {
+ try
+ {
+ // set up addressing properties
+ String address = client.getEndpointMetaData().getEndpointAddress();
+ AddressingProperties props = null;
+ if (this.client.getWSRMSequence().getBackPort() != null)
+ {
+ props = AddressingClientUtil.createDefaultProps(action, address);
+
props.setReplyTo(AddressingBuilder.getAddressingBuilder().newEndpointReference(this.client.getWSRMSequence().getBackPort()));
+ }
+ else
+ {
+ props = AddressingClientUtil.createAnonymousProps(action, address);
+ }
+ // prepare WS-RM request context
+ Map requestContext = client.getBindingProvider().getRequestContext();
+ Map rmRequestContext = (Map)requestContext.get(RMConstant.REQUEST_CONTEXT);
+ if (rmRequestContext == null)
+ {
+ rmRequestContext = new HashMap();
+ }
+ rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES, protocolMessages);
+ rmRequestContext.put(RMConstant.SEQUENCE_REFERENCE, this);
+ // set up method invocation context
+ requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
props);
+ requestContext.put(RMConstant.REQUEST_CONTEXT, rmRequestContext);
+ // call stub method
+ this.client.invoke(operationQName, new Object[] {},
client.getBindingProvider().getResponseContext());
+ }
+ catch (Exception e)
+ {
+ throw new RMException("Unable to terminate WSRM sequence", e);
+ }
+ }
+
+ public final void sendCloseMessage()
+ {
+ while (this.isAckRequested())
+ {
+ logger.debug("Waiting till all inbound sequence acknowledgements will be
sent");
+ sendSequenceAcknowledgementMessage();
+ }
+ Map<String, Object> wsrmReqCtx = new HashMap<String, Object>();
+ wsrmReqCtx.put(RMConstant.ONE_WAY_OPERATION, false);
+ this.getBindingProvider().getRequestContext().put(RMConstant.REQUEST_CONTEXT,
wsrmReqCtx);
+ List msgs = new LinkedList();
+ msgs.add(wsrmConstants.getCloseSequenceQName());
+ sendMessage(RMConstant.CLOSE_SEQUENCE_WSA_ACTION,
wsrmConstants.getCloseSequenceQName(), msgs);
+ }
+
+ public final void sendTerminateMessage()
+ {
+ List msgs = new LinkedList();
+ msgs.add(wsrmConstants.getTerminateSequenceQName());
+ if (this.getInboundId() != null)
+ {
+ msgs.add(wsrmConstants.getSequenceAcknowledgementQName());
+ }
+ sendMessage(RMConstant.TERMINATE_SEQUENCE_WSA_ACTION,
wsrmConstants.getTerminateSequenceQName(), msgs);
+ }
+
+ public final void sendSequenceAcknowledgementMessage()
+ {
+ Map<String, Object> wsrmReqCtx = new HashMap<String, Object>();
+ wsrmReqCtx.put(RMConstant.ONE_WAY_OPERATION, true);
+ this.getBindingProvider().getRequestContext().put(RMConstant.REQUEST_CONTEXT,
wsrmReqCtx);
+ ackRequested(false);
+ List msgs = new LinkedList();
+ msgs.add(wsrmConstants.getSequenceAcknowledgementQName());
+ sendMessage(RMConstant.SEQUENCE_ACKNOWLEDGEMENT_WSA_ACTION,
wsrmConstants.getSequenceAcknowledgementQName(), msgs);
+ }
+
+ public final void setBehavior(RMIncompleteSequenceBehavior behavior)
+ {
+ if (behavior != null)
+ {
+ this.behavior = behavior;
+ }
+ }
+
+ public final String getOutboundId()
+ {
+ return outgoingSequenceId;
+ }
+
+ public final String getInboundId()
+ {
+ return incomingSequenceId;
+ }
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMClientSequenceImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceIface.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceIface.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceIface.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -0,0 +1,42 @@
+/*
+ * 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.ws.extensions.wsrm;
+
+import java.util.Set;
+
+import org.jboss.ws.extensions.wsrm.api.RMSequence;
+
+/**
+ * Detailed view to the sequence - not visible to API clients
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Dec 12, 2007
+ */
+public interface RMSequenceIface extends RMSequence
+{
+ String getOutboundId();
+ long newMessageNumber();
+ long getLastMessageNumber();
+ String getInboundId();
+ Set<Long> getReceivedInboundMessages();
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceIface.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/RMSequenceImpl.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -1,328 +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.ws.extensions.wsrm;
-
-import java.net.InetAddress;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.UnknownHostException;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import javax.xml.namespace.QName;
-import javax.xml.ws.BindingProvider;
-import javax.xml.ws.addressing.AddressingBuilder;
-import javax.xml.ws.addressing.AddressingProperties;
-import javax.xml.ws.addressing.JAXWSAConstants;
-
-import org.jboss.logging.Logger;
-import org.jboss.ws.core.jaxws.client.ClientImpl;
-import org.jboss.ws.core.utils.UUIDGenerator;
-import org.jboss.ws.extensions.addressing.AddressingClientUtil;
-import org.jboss.ws.extensions.wsrm.config.RMConfig;
-import org.jboss.ws.extensions.wsrm.api.RMException;
-import org.jboss.ws.extensions.wsrm.api.RMSequence;
-import org.jboss.ws.extensions.wsrm.spi.RMConstants;
-import org.jboss.ws.extensions.wsrm.spi.RMProvider;
-import org.jboss.ws.extensions.wsrm.spi.protocol.RMIncompleteSequenceBehavior;
-import org.jboss.ws.extensions.wsrm.transport.RMUnassignedMessageListener;
-
-/**
- * TODO: all termination methods such as terminate, discard, ... etc must unregister the
sequence from client
- * Reliable messaging sequence implementation
- *
- * @author richard.opalka(a)jboss.com
- *
- * @since Oct 25, 2007
- */
-@SuppressWarnings("unchecked")
-public final class RMSequenceImpl implements RMSequence, RMUnassignedMessageListener
-{
- private static final Logger logger = Logger.getLogger(RMSequenceImpl.class);
- private static final String PATH_PREFIX = "/temporary_listen_address/";
- private static final RMConstants wsrmConstants = RMProvider.get().getConstants();
-
- private final RMConfig wsrmConfig;
- private final boolean addressableClient;
- private final Set<Long> acknowledgedOutboundMessages = new
TreeSet<Long>();
- private final Set<Long> receivedInboundMessages = new TreeSet<Long>();
- private RMIncompleteSequenceBehavior behavior =
RMIncompleteSequenceBehavior.NO_DISCARD;
- private String incomingSequenceId;
- private String outgoingSequenceId;
- private long duration = -1;
- private long creationTime;
- private URI backPort;
- private ClientImpl client;
- private boolean isFinal;
- private AtomicBoolean inboundMessageAckRequested = new AtomicBoolean();
- private AtomicLong messageNumber = new AtomicLong();
- private AtomicInteger countOfUnassignedMessagesAvailable = new AtomicInteger();
-
- public RMSequenceImpl(boolean addrType, RMConfig wsrmConfig)
- {
- super();
- if (wsrmConfig == null)
- throw new RMException("WS-RM configuration missing");
- if (wsrmConfig.getBackPortsServer() == null)
- throw new RMException("WS-RM backports server configuration
missing");
-
- this.addressableClient = addrType;
- this.wsrmConfig = wsrmConfig;
- try
- {
- String host = wsrmConfig.getBackPortsServer().getHost();
- if (host == null)
- {
- host = InetAddress.getLocalHost().getCanonicalHostName();
- logger.debug("Backports server configuration omits host configuration -
using autodetected " + host);
- }
- String port = wsrmConfig.getBackPortsServer().getPort();
- String path = PATH_PREFIX + UUIDGenerator.generateRandomUUIDString();
- this.backPort = new URI("http://" + host + ":" + port +
path);
- }
- catch (URISyntaxException use)
- {
- logger.warn(use);
- throw new RMException(use.getMessage(), use);
- }
- catch (UnknownHostException uhe)
- {
- logger.warn(uhe);
- throw new RMException(uhe.getMessage(), uhe);
- }
- }
-
- public void unassignedMessageReceived()
- {
- // we can't use objectLock in the method - possible deadlock
- this.countOfUnassignedMessagesAvailable.addAndGet(1);
- logger.debug("Expected sequence expiration in " +
((System.currentTimeMillis() - this.creationTime) / 1000) + "seconds");
- logger.debug("Unassigned message available in callback handler");
- }
-
- public final RMConfig getRMConfig()
- {
- return this.wsrmConfig;
- }
-
- public final Set<Long> getReceivedInboundMessages()
- {
- return this.receivedInboundMessages;
- }
-
- public final BindingProvider getBindingProvider()
- {
- return (BindingProvider)this.client;
- }
-
- public final void setFinal()
- {
- this.isFinal = true;
- logger.debug("Sequence " + this.outgoingSequenceId + " state changed
to final");
- }
-
- public final void ackRequested(boolean requested)
- {
- this.inboundMessageAckRequested.set(requested);
- logger.debug("Inbound Sequence: " + this.incomingSequenceId + ", ack
requested. Messages in the queue: " + this.receivedInboundMessages);
- }
-
- public final boolean isAckRequested()
- {
- return this.inboundMessageAckRequested.get();
- }
-
- public final void addReceivedInboundMessage(long messageId)
- {
- this.receivedInboundMessages.add(messageId);
- logger.debug("Inbound Sequence: " + this.incomingSequenceId + ",
received message no. " + messageId);
- }
-
- public final void addReceivedOutboundMessage(long messageId)
- {
- this.acknowledgedOutboundMessages.add(messageId);
- logger.debug("Outbound Sequence: " + this.outgoingSequenceId + ",
message no. " + messageId + " acknowledged by server");
- }
-
- public final void setOutboundId(String outboundId)
- {
- this.outgoingSequenceId = outboundId;
- }
-
- public final void setInboundId(String inboundId)
- {
- this.incomingSequenceId = inboundId;
- }
-
- public final void setClient(ClientImpl client)
- {
- this.client = client;
- }
-
- public final void setDuration(long duration)
- {
- if (duration > 0)
- {
- this.creationTime = System.currentTimeMillis();
- this.duration = duration;
- }
- }
-
- public final long getDuration()
- {
- return this.duration;
- }
-
- public final URI getBackPort()
- {
- // no need for synchronization
- return (this.addressableClient) ? this.backPort : null;
- }
-
- public final long newMessageNumber()
- {
- // no need for synchronization
- return this.messageNumber.incrementAndGet();
- }
-
- public final long getLastMessageNumber()
- {
- // no need for synchronization
- return this.messageNumber.get();
- }
-
- public final void close() throws RMException
- {
- try
- {
- sendCloseMessage();
- sendTerminateMessage();
- }
- finally
- {
- this.client.setWSRMSequence(null);
- }
- }
-
- /**
- * Sets up terminated flag to true.
- */
- private void sendMessage(String action, QName operationQName, List protocolMessages)
throws RMException
- {
- try
- {
- // set up addressing properties
- String address = client.getEndpointMetaData().getEndpointAddress();
- AddressingProperties props = null;
- if (this.client.getWSRMSequence().getBackPort() != null)
- {
- props = AddressingClientUtil.createDefaultProps(action, address);
-
props.setReplyTo(AddressingBuilder.getAddressingBuilder().newEndpointReference(this.client.getWSRMSequence().getBackPort()));
- }
- else
- {
- props = AddressingClientUtil.createAnonymousProps(action, address);
- }
- // prepare WS-RM request context
- Map requestContext = client.getBindingProvider().getRequestContext();
- Map rmRequestContext = (Map)requestContext.get(RMConstant.REQUEST_CONTEXT);
- if (rmRequestContext == null)
- {
- rmRequestContext = new HashMap();
- }
- rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES, protocolMessages);
- rmRequestContext.put(RMConstant.SEQUENCE_REFERENCE, this);
- // set up method invocation context
- requestContext.put(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND,
props);
- requestContext.put(RMConstant.REQUEST_CONTEXT, rmRequestContext);
- // call stub method
- this.client.invoke(operationQName, new Object[] {},
client.getBindingProvider().getResponseContext());
- }
- catch (Exception e)
- {
- throw new RMException("Unable to terminate WSRM sequence", e);
- }
- }
-
- public final void sendCloseMessage()
- {
- while (this.isAckRequested())
- {
- logger.debug("Waiting till all inbound sequence acknowledgements will be
sent");
- sendSequenceAcknowledgementMessage();
- }
- Map<String, Object> wsrmReqCtx = new HashMap<String, Object>();
- wsrmReqCtx.put(RMConstant.ONE_WAY_OPERATION, false);
- this.getBindingProvider().getRequestContext().put(RMConstant.REQUEST_CONTEXT,
wsrmReqCtx);
- List msgs = new LinkedList();
- msgs.add(wsrmConstants.getCloseSequenceQName());
- sendMessage(RMConstant.CLOSE_SEQUENCE_WSA_ACTION,
wsrmConstants.getCloseSequenceQName(), msgs);
- }
-
- public final void sendTerminateMessage()
- {
- List msgs = new LinkedList();
- msgs.add(wsrmConstants.getTerminateSequenceQName());
- if (this.getInboundId() != null)
- {
- msgs.add(wsrmConstants.getSequenceAcknowledgementQName());
- }
- sendMessage(RMConstant.TERMINATE_SEQUENCE_WSA_ACTION,
wsrmConstants.getTerminateSequenceQName(), msgs);
- }
-
- public final void sendSequenceAcknowledgementMessage()
- {
- Map<String, Object> wsrmReqCtx = new HashMap<String, Object>();
- wsrmReqCtx.put(RMConstant.ONE_WAY_OPERATION, true);
- this.getBindingProvider().getRequestContext().put(RMConstant.REQUEST_CONTEXT,
wsrmReqCtx);
- ackRequested(false);
- List msgs = new LinkedList();
- msgs.add(wsrmConstants.getSequenceAcknowledgementQName());
- sendMessage(RMConstant.SEQUENCE_ACKNOWLEDGEMENT_WSA_ACTION,
wsrmConstants.getSequenceAcknowledgementQName(), msgs);
- }
-
- public final void setBehavior(RMIncompleteSequenceBehavior behavior)
- {
- if (behavior != null)
- {
- this.behavior = behavior;
- }
- }
-
- public final String getOutboundId()
- {
- return outgoingSequenceId;
- }
-
- public final String getInboundId()
- {
- return incomingSequenceId;
- }
-
-}
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/common/RMHelper.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -30,10 +30,10 @@
import javax.xml.namespace.QName;
import org.jboss.logging.Logger;
-import org.jboss.ws.extensions.wsrm.RMClientHandler;
import org.jboss.ws.extensions.wsrm.RMConstant;
-import org.jboss.ws.extensions.wsrm.RMSequenceImpl;
+import org.jboss.ws.extensions.wsrm.RMClientSequenceImpl;
import org.jboss.ws.extensions.wsrm.api.RMException;
+import org.jboss.ws.extensions.wsrm.jaxws.RMHandler;
import org.jboss.ws.extensions.wsrm.spi.RMProvider;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMAckRequested;
import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequence;
@@ -90,7 +90,7 @@
return d.getTimeInMillis(new Date());
}
- public static void handleSequenceAcknowledgementHeader(RMSequenceAcknowledgement
seqAckHeader, RMSequenceImpl sequence)
+ public static void handleSequenceAcknowledgementHeader(RMSequenceAcknowledgement
seqAckHeader, RMClientSequenceImpl sequence)
{
String seqId = seqAckHeader.getIdentifier();
if (sequence.getOutboundId().equals(seqId))
@@ -115,7 +115,7 @@
}
}
- public static void handleAckRequestedHeader(RMAckRequested ackReqHeader,
RMSequenceImpl sequence)
+ public static void handleAckRequestedHeader(RMAckRequested ackReqHeader,
RMClientSequenceImpl sequence)
{
String inboundSeqId = ackReqHeader.getIdentifier();
if (false == sequence.getInboundId().equals(inboundSeqId))
@@ -127,7 +127,7 @@
sequence.ackRequested(true);
}
- public static void handleSequenceHeader(RMSequence seqHeader, RMSequenceImpl
sequence)
+ public static void handleSequenceHeader(RMSequence seqHeader, RMClientSequenceImpl
sequence)
{
String inboundSeqId = seqHeader.getIdentifier();
if (null == sequence.getInboundId())
Added:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMClientHandler.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMClientHandler.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMClientHandler.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -0,0 +1,34 @@
+/*
+ * 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.ws.extensions.wsrm.jaxws;
+
+/**
+ * Client WS-RM JAX-WS handler
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Dec 12, 2007
+ */
+public final class RMClientHandler extends RMHandler
+{
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMClientHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandler.java
===================================================================
--- stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandler.java
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandler.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -0,0 +1,320 @@
+/*
+ * 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.ws.extensions.wsrm.jaxws;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.addressing.JAXWSAConstants;
+import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.MessageContext.Scope;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.jboss.logging.Logger;
+import org.jboss.ws.core.CommonMessageContext;
+import org.jboss.ws.core.jaxws.handler.GenericSOAPHandler;
+import org.jboss.ws.extensions.wsrm.RMConstant;
+import org.jboss.ws.extensions.wsrm.RMSequenceIface;
+import org.jboss.ws.extensions.wsrm.api.RMException;
+import org.jboss.ws.extensions.wsrm.spi.RMConstants;
+import org.jboss.ws.extensions.wsrm.spi.RMMessageFactory;
+import org.jboss.ws.extensions.wsrm.spi.RMProvider;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMAckRequested;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMCloseSequence;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMCloseSequenceResponse;
+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.RMSequence;
+import org.jboss.ws.extensions.wsrm.spi.protocol.RMSequenceAcknowledgement;
+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;
+
+/**
+ * RM generic JAX-WS handler
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Oct 23, 2007
+ */
+@SuppressWarnings("unchecked")
+public class RMHandler extends GenericSOAPHandler
+{
+ private static final Logger log = Logger.getLogger(RMHandler.class);
+ private static final RMMessageFactory rmFactory =
RMProvider.get().getMessageFactory();
+ private static final RMConstants rmConstants = RMProvider.get().getConstants();
+ private static final Set headers = RMConstant.PROTOCOL_OPERATION_QNAMES;
+
+ public final Set getHeaders()
+ {
+ return headers;
+ }
+
+ protected final boolean handleOutbound(MessageContext msgContext)
+ {
+ log.debug("handling outbound message");
+
+ CommonMessageContext commonMsgContext = (CommonMessageContext)msgContext;
+ SOAPAddressingProperties addrProps =
(SOAPAddressingProperties)commonMsgContext.get(JAXWSAConstants.CLIENT_ADDRESSING_PROPERTIES_OUTBOUND);
+ if (addrProps == null)
+ throw new RMException("WS-Addressing properties not found in message
context");
+
+ Map rmRequestContext = (Map)commonMsgContext.get(RMConstant.REQUEST_CONTEXT);
+ List<QName> outMsgs =
(List<QName>)rmRequestContext.get(RMConstant.PROTOCOL_MESSAGES);
+ Map<QName, RMSerializable> data = new HashMap<QName,
RMSerializable>();
+ String optionalMessageId = (addrProps.getMessageID() != null) ?
addrProps.getMessageID().getURI().toString() : null;
+ rmRequestContext.put(RMConstant.WSA_MESSAGE_ID, optionalMessageId);
+ rmRequestContext.put(RMConstant.PROTOCOL_MESSAGES_MAPPING, data);
+ SOAPMessage soapMessage = ((SOAPMessageContext)commonMsgContext).getMessage();
+ RMSequenceIface sequenceImpl =
(RMSequenceIface)rmRequestContext.get(RMConstant.SEQUENCE_REFERENCE);
+
+ QName msgQName = rmConstants.getCreateSequenceQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize CreateSequence to message
+ String replyTo = addrProps.getReplyTo().getAddress().getURI().toString();
+ RMCreateSequence createSequence = rmFactory.newCreateSequence();
+ createSequence.setAcksTo(replyTo);
+ createSequence.serializeTo(soapMessage);
+ data.put(msgQName, createSequence);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getSequenceQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize Sequence to message
+ RMSequence sequence = rmFactory.newSequence();
+ sequence.setIdentifier(sequenceImpl.getOutboundId());
+ sequence.setMessageNumber(sequenceImpl.newMessageNumber());
+ sequence.serializeTo(soapMessage);
+ data.put(msgQName, sequence);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getAckRequestedQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize AckRequested to message
+ RMAckRequested ackRequested = rmFactory.newAckRequested();
+ ackRequested.setIdentifier(sequenceImpl.getOutboundId());
+ ackRequested.setMessageNumber(sequenceImpl.getLastMessageNumber());
+ ackRequested.serializeTo(soapMessage);
+ data.put(msgQName, ackRequested);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getCloseSequenceQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize CloseSequence to message
+ RMCloseSequence closeSequence = rmFactory.newCloseSequence();
+ closeSequence.setIdentifier(sequenceImpl.getOutboundId());
+ closeSequence.setLastMsgNumber(sequenceImpl.getLastMessageNumber());
+ closeSequence.serializeTo(soapMessage);
+ data.put(msgQName, closeSequence);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getCloseSequenceResponseQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize CloseSequenceResponse to message
+ RMCloseSequenceResponse closeSequenceResponse =
rmFactory.newCloseSequenceResponse();
+ closeSequenceResponse.setIdentifier(sequenceImpl.getOutboundId());
+ data.put(msgQName, closeSequenceResponse);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getTerminateSequenceQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize TerminateSequence to message
+ RMTerminateSequence terminateSequence = rmFactory.newTerminateSequence();
+ terminateSequence.setIdentifier(sequenceImpl.getOutboundId());
+ terminateSequence.setLastMsgNumber(sequenceImpl.getLastMessageNumber());
+ terminateSequence.serializeTo(soapMessage);
+ data.put(msgQName, terminateSequence);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getTerminateSequenceResponseQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize terminateSequenceResponse to message
+ RMTerminateSequenceResponse terminateSequenceResponse =
rmFactory.newTerminateSequenceResponse();
+ terminateSequenceResponse.setIdentifier(sequenceImpl.getOutboundId());
+ terminateSequenceResponse.serializeTo(soapMessage);
+ data.put(msgQName, terminateSequenceResponse);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ msgQName = rmConstants.getSequenceAcknowledgementQName();
+ if (outMsgs.contains(msgQName))
+ {
+ // try to serialize SequenceAcknowledgement to message
+ RMSequenceAcknowledgement sequenceAcknowledgement =
rmFactory.newSequenceAcknowledgement();
+ sequenceAcknowledgement.setIdentifier(sequenceImpl.getInboundId());
+ Iterator<Long> receivedInboudMessages =
sequenceImpl.getReceivedInboundMessages().iterator();
+ while (receivedInboudMessages.hasNext())
+ {
+ long messageNo = receivedInboudMessages.next();
+ RMSequenceAcknowledgement.RMAcknowledgementRange range =
sequenceAcknowledgement.newAcknowledgementRange();
+ range.setLower(messageNo);
+ range.setUpper(messageNo);
+ sequenceAcknowledgement.addAcknowledgementRange(range);
+ }
+ sequenceAcknowledgement.serializeTo(soapMessage);
+ data.put(msgQName, sequenceAcknowledgement);
+ log.debug(msgQName.getLocalPart() + " WSRM message was serialized to
payload");
+ }
+
+ // TODO: implement SequenceFault serialization
+
+ return true;
+ }
+
+ protected final boolean handleInbound(MessageContext msgContext)
+ {
+ log.debug("handling inbound message");
+
+ SOAPMessage soapMessage = ((SOAPMessageContext)msgContext).getMessage();
+ Map<String, Object> rmResponseContext = new HashMap();
+ List<QName> messages = new LinkedList<QName>();
+ rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES, messages);
+ Map<QName, RMSerializable> data = new HashMap<QName,
RMSerializable>();
+ rmResponseContext.put(RMConstant.PROTOCOL_MESSAGES_MAPPING, data);
+ msgContext.put(RMConstant.RESPONSE_CONTEXT, rmResponseContext);
+ msgContext.setScope(RMConstant.RESPONSE_CONTEXT, Scope.APPLICATION);
+
+ try
+ {
+ // try to deserialize CreateSequenceResponse from message
+ QName msgQName = rmConstants.getCreateSequenceResponseQName();
+ RMCreateSequenceResponse wsrmMsg = rmFactory.newCreateSequenceResponse();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize AckRequested from message
+ QName msgQName = rmConstants.getAckRequestedQName();
+ RMAckRequested wsrmMsg = rmFactory.newAckRequested();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize Sequence from message
+ QName msgQName = rmConstants.getSequenceQName();
+ RMSequence wsrmMsg = rmFactory.newSequence();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize SequenceAcknowledgement from message
+ QName msgQName = rmConstants.getSequenceAcknowledgementQName();
+ RMSequenceAcknowledgement wsrmMsg = rmFactory.newSequenceAcknowledgement();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize CloseSequence from message
+ QName msgQName = rmConstants.getCloseSequenceQName();
+ RMCloseSequence wsrmMsg = rmFactory.newCloseSequence();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize CloseSequence from message
+ QName msgQName = rmConstants.getCloseSequenceResponseQName();
+ RMCloseSequenceResponse wsrmMsg = rmFactory.newCloseSequenceResponse();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize TerminateSequence from message
+ QName msgQName = rmConstants.getTerminateSequenceQName();
+ RMTerminateSequence wsrmMsg = rmFactory.newTerminateSequence();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ try
+ {
+ // try to deserialize TerminateSequenceResponse from message
+ QName msgQName = rmConstants.getTerminateSequenceResponseQName();
+ RMTerminateSequenceResponse wsrmMsg = rmFactory.newTerminateSequenceResponse();
+ wsrmMsg.deserializeFrom(soapMessage);
+ messages.add(msgQName);
+ data.put(msgQName, wsrmMsg);
+ log.debug(msgQName.getLocalPart() + " WSRM message was deserialized from
payload");
+ }
+ catch (RMException ignore) {}
+
+ // TODO: implement SequenceFault deserialization
+
+ if (data.size() == 0)
+ throw new RMException("RM handler was not able to find WS-RM message in the
payload");
+
+ return true;
+ }
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
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
(rev 0)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -0,0 +1,34 @@
+/*
+ * 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.ws.extensions.wsrm.jaxws;
+
+/**
+ * Client WS-RM JAX-WS handler
+ *
+ * @author richard.opalka(a)jboss.com
+ *
+ * @since Dec 12, 2007
+ */
+public final class RMServerHandler extends RMHandler
+{
+
+}
Property changes on:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/jaxws/RMServerHandler.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMChannelTask.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -33,7 +33,7 @@
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
import org.jboss.ws.core.MessageTrace;
-import org.jboss.ws.extensions.wsrm.RMSequenceImpl;
+import org.jboss.ws.extensions.wsrm.RMClientSequenceImpl;
import org.jboss.ws.extensions.wsrm.transport.backchannel.RMCallbackHandler;
import org.jboss.ws.extensions.wsrm.transport.backchannel.RMCallbackHandlerFactory;
@@ -78,7 +78,7 @@
if (backPort != null)
{
callbackHandler = RMCallbackHandlerFactory.getCallbackHandler(backPort);
- RMSequenceImpl sequence = RMTransportHelper.getSequence(rmRequest);
+ RMClientSequenceImpl sequence = RMTransportHelper.getSequence(rmRequest);
if (sequence != null)
{
callbackHandler.addUnassignedMessageListener(sequence);
Modified:
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMTransportHelper.java
===================================================================
---
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMTransportHelper.java 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/main/java/org/jboss/ws/extensions/wsrm/transport/RMTransportHelper.java 2007-12-12
12:37:50 UTC (rev 5265)
@@ -7,7 +7,7 @@
import org.jboss.logging.Logger;
import org.jboss.ws.extensions.wsrm.RMConstant;
-import org.jboss.ws.extensions.wsrm.RMSequenceImpl;
+import org.jboss.ws.extensions.wsrm.RMClientSequenceImpl;
/**
* Utility class heavily used in this transport implementation
@@ -45,9 +45,9 @@
return (Map<String, Object>)invocationCtx.get(REQUEST_CONTEXT);
}
- public static RMSequenceImpl getSequence(RMMessage rmRequest)
+ public static RMClientSequenceImpl getSequence(RMMessage rmRequest)
{
- return (RMSequenceImpl)getWsrmRequestContext(rmRequest).get(SEQUENCE_REFERENCE);
+ return
(RMClientSequenceImpl)getWsrmRequestContext(rmRequest).get(SEQUENCE_REFERENCE);
}
public static boolean isOneWayOperation(RMMessage rmRequest)
Modified:
stack/native/trunk/src/test/resources/jaxws/wsrm/META-INF/wsrm-jaxws-client-config.xml
===================================================================
---
stack/native/trunk/src/test/resources/jaxws/wsrm/META-INF/wsrm-jaxws-client-config.xml 2007-12-12
08:22:15 UTC (rev 5264)
+++
stack/native/trunk/src/test/resources/jaxws/wsrm/META-INF/wsrm-jaxws-client-config.xml 2007-12-12
12:37:50 UTC (rev 5265)
@@ -21,7 +21,7 @@
</javaee:handler>
<javaee:handler>
<javaee:handler-name>WSRM Handler</javaee:handler-name>
-
<javaee:handler-class>org.jboss.ws.extensions.wsrm.RMClientHandler</javaee:handler-class>
+
<javaee:handler-class>org.jboss.ws.extensions.wsrm.jaxws.RMClientHandler</javaee:handler-class>
</javaee:handler>
</javaee:handler-chain>
</post-handler-chains>