You are viewing a plain text version of this content. The canonical link for it is here.
Posted to sandesha-dev@ws.apache.org by ch...@apache.org on 2007/05/27 03:50:01 UTC
svn commit: r541957 - in
/webservices/sandesha/trunk/java/modules/core/src/main:
java/org/apache/sandesha2/ java/org/apache/sandesha2/handlers/
java/org/apache/sandesha2/i18n/ java/org/apache/sandesha2/msgprocessors/
java/org/apache/sandesha2/msgreceiv...
Author: chamikara
Date: Sat May 26 18:49:59 2007
New Revision: 541957
URL: http://svn.apache.org/viewvc?view=rev&rev=541957
Log:
Merged the recent changes from the branch see r541573
Modified:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/MessageValidator.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/LastMessageProcessor.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/MsgProcessorFactory.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SpecSpecificConstants.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/MessageValidator.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/MessageValidator.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/MessageValidator.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/MessageValidator.java Sat May 26 18:49:59 2007
@@ -1,94 +1,127 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *
- */
-
-package org.apache.sandesha2;
-
-import org.apache.sandesha2.i18n.SandeshaMessageHelper;
-import org.apache.sandesha2.i18n.SandeshaMessageKeys;
-import org.apache.sandesha2.policy.SandeshaPolicyBean;
-import org.apache.sandesha2.storage.StorageManager;
-import org.apache.sandesha2.storage.beans.RMDBean;
-import org.apache.sandesha2.storage.beans.RMSBean;
-import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.util.SpecSpecificConstants;
-
-/**
- * Used to validate RM messages. This include both application messages and RM
- * control messages.
- */
-public class MessageValidator {
-
- public static void validateMessage(RMMsgContext rmMsg,
- StorageManager storageManager) throws SandeshaException {
-
- int type = rmMsg.getMessageType();
- if (type != Sandesha2Constants.MessageTypes.CREATE_SEQ && type != Sandesha2Constants.MessageTypes.UNKNOWN) {
-
- String sequenceID = SandeshaUtil.getSequenceIDFromRMMessage(rmMsg);
-
- if (sequenceID != null) {
- String rmVersionOfSequence = null;
-
- RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(
- storageManager, sequenceID);
- if (rmsBean != null)
- rmVersionOfSequence = rmsBean.getRMVersion();
- else {
- RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(
- storageManager, sequenceID);
- if (rmdBean != null)
- rmVersionOfSequence = rmdBean.getRMVersion();
- }
-
- String rmNamespaceOfMsg = rmMsg.getRMNamespaceValue();
- String rmNamespaceOfSequence = null;
- if (rmVersionOfSequence != null)
- rmNamespaceOfSequence = SpecSpecificConstants
- .getRMNamespaceValue(rmVersionOfSequence);
-
- if (rmNamespaceOfSequence != null
- && !rmNamespaceOfSequence.equals(rmNamespaceOfMsg)) {
- String message = SandeshaMessageHelper
- .getMessage(
- SandeshaMessageKeys.rmNamespaceNotMatchSequence,
- rmNamespaceOfMsg, rmNamespaceOfSequence,
- sequenceID);
- throw new SandeshaException(message);
- }
-
- }
- } else if (type == Sandesha2Constants.MessageTypes.UNKNOWN) {
-
- // checking if policies hv been set to enforceRM.
- // If this is set and this message is not an RM message, validation
- // will fail here.
-
- SandeshaPolicyBean propertyBean = SandeshaUtil
- .getPropertyBean(rmMsg.getMessageContext()
- .getAxisOperation());
- if (propertyBean.isEnforceRM()) {
- String message = SandeshaMessageHelper.getMessage(
- SandeshaMessageKeys.rmEnforceFailure, rmMsg
- .getMessageId());
- throw new SandeshaException(message);
- }
- }
-
- // TODO do validation based on states
-
- }
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.sandesha2;
+
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.WSDL2Constants;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
+import org.apache.sandesha2.policy.SandeshaPolicyBean;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+
+/**
+ * Used to validate RM messages. This include both application messages and RM
+ * control messages.
+ */
+public class MessageValidator {
+
+ public static void validateIncomingMessage(RMMsgContext rmMsg,
+ StorageManager storageManager) throws SandeshaException {
+
+ int type = rmMsg.getMessageType();
+ if (type != Sandesha2Constants.MessageTypes.CREATE_SEQ && type != Sandesha2Constants.MessageTypes.UNKNOWN) {
+
+ String sequenceID = SandeshaUtil.getSequenceIDFromRMMessage(rmMsg);
+
+ if (sequenceID != null) {
+ String rmVersionOfSequence = null;
+
+ RMSBean rmsBean = SandeshaUtil.getRMSBeanFromSequenceId(
+ storageManager, sequenceID);
+ if (rmsBean != null)
+ rmVersionOfSequence = rmsBean.getRMVersion();
+ else {
+ RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(
+ storageManager, sequenceID);
+ if (rmdBean != null)
+ rmVersionOfSequence = rmdBean.getRMVersion();
+ }
+
+ String rmNamespaceOfMsg = rmMsg.getRMNamespaceValue();
+ String rmNamespaceOfSequence = null;
+ if (rmVersionOfSequence != null)
+ rmNamespaceOfSequence = SpecSpecificConstants
+ .getRMNamespaceValue(rmVersionOfSequence);
+
+ if (rmNamespaceOfSequence != null
+ && !rmNamespaceOfSequence.equals(rmNamespaceOfMsg)) {
+ String message = SandeshaMessageHelper
+ .getMessage(
+ SandeshaMessageKeys.rmNamespaceNotMatchSequence,
+ rmNamespaceOfMsg, rmNamespaceOfSequence,
+ sequenceID);
+ throw new SandeshaException(message);
+ }
+
+ }
+ } else if (type == Sandesha2Constants.MessageTypes.UNKNOWN) {
+
+ // checking if policies hv been set to enforceRM.
+ // If this is set and this message is not an RM message, validation
+ // will fail here.
+
+ SandeshaPolicyBean propertyBean = SandeshaUtil
+ .getPropertyBean(rmMsg.getMessageContext()
+ .getAxisOperation());
+ if (propertyBean.isEnforceRM()) {
+ String message = SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.rmEnforceFailure, rmMsg
+ .getMessageId());
+ throw new SandeshaException(message);
+ }
+ }
+
+ // TODO do validation based on states
+
+ }
+
+ public static void validateOutgoingMessage (RMMsgContext rmMsgContext) throws SandeshaException {
+
+ MessageContext msgContext = rmMsgContext.getMessageContext();
+ if (!msgContext.isServerSide()) {
+ //validating messages from the client.
+
+ //if sync InOut and NoOffer and RM 1.0 an exception should be thrown
+ String rmNamespace = rmMsgContext.getRMNamespaceValue();
+ String mep = msgContext.getAxisOperation().getMessageExchangePattern();
+ String offer = (String) msgContext.getProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID);
+
+ EndpointReference replyTo = rmMsgContext.getMessageContext().getOptions().getReplyTo();
+ boolean anonReplyTo = false;
+ if (replyTo==null || replyTo.hasAnonymousAddress())
+ anonReplyTo = true;
+
+ if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(rmMsgContext.getRMSpecVersion()) &&
+ WSDL2Constants.MEP_URI_OUT_IN.equals(mep) &&
+ offer==null && anonReplyTo) {
+
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.offerRequiredForAnon);
+ throw new SandeshaException(message);
+
+ }
+
+ }
+ }
+}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/RMMsgContext.java Sat May 26 18:49:59 2007
@@ -1,336 +1,337 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package org.apache.sandesha2;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.addressing.RelatesTo;
-import org.apache.axis2.context.ConfigurationContext;
-import org.apache.axis2.context.MessageContext;
-import org.apache.sandesha2.client.SandeshaClientConstants;
-import org.apache.sandesha2.util.SOAPAbstractFactory;
-import org.apache.sandesha2.wsrm.IOMRMPart;
-
-/**
- * This class is used to hold a MessageContext within Sandesha. This is used to
- * easily manupilate the properties of a MessageContext.
- */
-
-public class RMMsgContext {
-
- private MessageContext msgContext;
-
- private HashMap rmMessageParts;
-
- private int messageType;
-
- private String rmNamespaceValue = null;
-
- private String rmSpecVersion = null;
-
- public RMMsgContext() {
- rmMessageParts = new HashMap();
- messageType = Sandesha2Constants.MessageTypes.UNKNOWN;
- }
-
- public void setMessageContext(MessageContext msgCtx) {
- this.msgContext = msgCtx;
- }
-
- public RMMsgContext(MessageContext ctx) {
- this();
- this.msgContext = ctx;
- }
-
- /**
- * To add a new SOAP envelope to the message. The generated envelope will belong
- * to the SOAP version of the MessageContext.
- *
- * @throws SandeshaException
- */
- public void addSOAPEnvelope() throws AxisFault {
- int SOAPVersion = Sandesha2Constants.SOAPVersion.v1_1;
-
- if (!msgContext.isSOAP11())
- SOAPVersion = Sandesha2Constants.SOAPVersion.v1_2;
-
- if (msgContext.getEnvelope() == null) {
- try {
- msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(
- SOAPVersion).getDefaultEnvelope());
- } catch (AxisFault e) {
- throw new SandeshaException(e.getMessage());
- }
- }
-
- SOAPEnvelope envelope = msgContext.getEnvelope();
- Iterator keys = rmMessageParts.keySet().iterator();
- while (keys.hasNext()) {
- Integer key = (Integer) keys.next();
- int partId = key.intValue();
-
- if (isMultiPart(partId)) {
- for (Iterator it=getMessageParts(partId);it.hasNext();) {
- IOMRMPart rmPart = (IOMRMPart) it.next();
- rmPart.toSOAPEnvelope(envelope);
- }
- } else {
- IOMRMPart rmPart = (IOMRMPart) rmMessageParts.get(key);
- rmPart.toSOAPEnvelope(envelope);
- }
- }
- }
-
- public int getMessageType() {
- return messageType;
- }
-
-
- /**
- * The message type can be used to easily identify what this message is.
- * Possible message types are given in the Constnts.MessageTypes interface.
- *
- * @param msgType
- */
- public void setMessageType(int msgType) {
- if (msgType >= 0 && msgType <= Sandesha2Constants.MessageTypes.MAX_MESSAGE_TYPE)
- this.messageType = msgType;
- }
-
-
- /**
- * Sets an IRMPart object to the MessageContext. Possible parts are give in the
- *
- *
- * @param partId
- * @param part
- */
- public void setMessagePart(int partId, IOMRMPart part) {
- if (partId >= 0 && partId <= Sandesha2Constants.MessageParts.MAX_MSG_PART_ID) {
- if (isMultiPart(partId)) {
- ArrayList partList = (ArrayList) rmMessageParts.get(new Integer (partId));
- if (partList==null) {
- partList = new ArrayList ();
- rmMessageParts.put(new Integer (partId),partList);
- }
- partList.add(part);
- } else {
- rmMessageParts.put(new Integer(partId), part);
- }
- }
- }
-
-
- public IOMRMPart getMessagePart(int partId) throws SandeshaException {
- if (isMultiPart(partId)) {
- String message = "It is possible for a multiple MessageParts of this type to exit. Please call the 'getMessageParts' method";
- throw new SandeshaException (message);
- }
-
- return (IOMRMPart) rmMessageParts.get(new Integer(partId));
- }
-
- public Iterator getMessageParts (int partId) {
- Object obj = rmMessageParts.get(new Integer (partId));
- if (obj==null)
- return new ArrayList().iterator();
-
- if (obj instanceof ArrayList) {
- return ((ArrayList) obj).iterator();
- } else {
- ArrayList arr = new ArrayList ();
- arr.add(obj);
- return arr.iterator();
- }
- }
-
- public void removeMessageParts (int messageType) {
- rmMessageParts.remove (new Integer (messageType));
- }
-
- //checks weather there can be multiple elements of these parts,
- //if so getMessageParts method has to be called to get a ArrayList of parts..
- public boolean isMultiPart (int messagePartId) {
- if (messagePartId==Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT||
- messagePartId==Sandesha2Constants.MessageParts.ACK_REQUEST)
- return true;
-
- return false;
- }
-
- public EndpointReference getFrom() {
- return msgContext.getFrom();
- }
-
- public EndpointReference getTo() {
- return msgContext.getTo();
- }
-
- public EndpointReference getReplyTo() {
- return msgContext.getReplyTo();
- }
-
- public RelatesTo getRelatesTo() {
- return msgContext.getRelatesTo();
- }
-
- public String getMessageId() {
- return msgContext.getMessageID();
- }
-
- public void setFaultTo(EndpointReference epr) {
- msgContext.setFaultTo(epr);
- }
-
- public EndpointReference getFaultTo() {
- return msgContext.getFaultTo();
- }
-
- public SOAPEnvelope getSOAPEnvelope() {
- return msgContext.getEnvelope();
- }
-
- public void setSOAPEnvelop(SOAPEnvelope envelope) throws SandeshaException {
-
- try {
- msgContext.setEnvelope(envelope);
- } catch (AxisFault e) {
- throw new SandeshaException(e.getMessage());
- }
- }
-
- public void setFrom(EndpointReference epr) {
- msgContext.setFrom(epr);
- }
-
- public void setTo(EndpointReference epr) {
- msgContext.setTo(epr);
- }
-
- public void setReplyTo(EndpointReference epr) {
- msgContext.setReplyTo(epr);
- }
-
- public void setMessageId(String messageId) {
- msgContext.setMessageID(messageId);
- }
-
- public void setAction(String action) {
- msgContext.setWSAAction(action);
- }
-
- public void addRelatesTo(RelatesTo relatesTo) {
- msgContext.addRelatesTo(relatesTo);
- }
-
- public void setWSAAction(String URI) {
- msgContext.setWSAAction(URI);
- }
-
- public String getWSAAction() {
- return msgContext.getWSAAction();
- }
-
- public MessageContext getMessageContext() {
- return msgContext;
- }
-
- public Object getProperty(String key) {
- if (msgContext == null)
- return null;
-
- return msgContext.getProperty(key);
- }
-
- public boolean setProperty(String key, Object val) {
- if (msgContext == null)
- return false;
-
- msgContext.setProperty(key, val);
- return true;
- }
-
- public ConfigurationContext getConfigurationContext() {
- if (msgContext == null)
- return null;
-
- return msgContext.getConfigurationContext();
- }
-
-
- public void setSOAPAction(String SOAPAction) {
- msgContext.setSoapAction(SOAPAction);
- }
-
- public void pause () {
- if (msgContext!=null)
- msgContext.pause();
- }
-
- public void setPaused (boolean pause) {
- if (msgContext!=null)
- msgContext.setPaused(pause);
- }
-
- public String getRMNamespaceValue() {
- return rmNamespaceValue;
- }
-
- public void setRMNamespaceValue(String rmNamespaceValue) {
- this.rmNamespaceValue = rmNamespaceValue;
-
- if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmNamespaceValue)) {
- rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
- } else if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(rmNamespaceValue)) {
- rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
- }
- }
-
- public String getRMSpecVersion () {
- if (rmSpecVersion==null) {
- //this may hv been set in the Options object.
- if (msgContext!=null && msgContext.getOptions()!=null)
- rmSpecVersion = (String) msgContext.getOptions().getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
- }
-
- return rmSpecVersion;
- }
-
- public void setFlow (int flow) {
- msgContext.setFLOW(flow);
- }
-
- public int getFlow () {
- return msgContext.getFLOW();
- }
-
- /**
- * This will return the sequenceId if it could be derived from the SOAP envelope, in the
- * message initiation.
- *
- * @return
- */
- public String getGeneratedSequenceId () {
- return (String) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
- }
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.sandesha2;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.apache.axis2.addressing.RelatesTo;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.util.SOAPAbstractFactory;
+import org.apache.sandesha2.wsrm.IOMRMPart;
+
+/**
+ * This class is used to hold a MessageContext within Sandesha. This is used to
+ * easily manupilate the properties of a MessageContext.
+ */
+
+public class RMMsgContext {
+
+ private MessageContext msgContext;
+
+ private HashMap rmMessageParts;
+
+ private int messageType;
+
+ private String rmNamespaceValue = null;
+
+ private String rmSpecVersion = null;
+
+ public RMMsgContext() {
+ rmMessageParts = new HashMap();
+ messageType = Sandesha2Constants.MessageTypes.UNKNOWN;
+ rmNamespaceValue = Sandesha2Constants.DEFAULT_RM_NAMESPACE;
+ }
+
+ public void setMessageContext(MessageContext msgCtx) {
+ this.msgContext = msgCtx;
+ }
+
+ public RMMsgContext(MessageContext ctx) {
+ this();
+ this.msgContext = ctx;
+ }
+
+ /**
+ * To add a new SOAP envelope to the message. The generated envelope will belong
+ * to the SOAP version of the MessageContext.
+ *
+ * @throws SandeshaException
+ */
+ public void addSOAPEnvelope() throws AxisFault {
+ int SOAPVersion = Sandesha2Constants.SOAPVersion.v1_1;
+
+ if (!msgContext.isSOAP11())
+ SOAPVersion = Sandesha2Constants.SOAPVersion.v1_2;
+
+ if (msgContext.getEnvelope() == null) {
+ try {
+ msgContext.setEnvelope(SOAPAbstractFactory.getSOAPFactory(
+ SOAPVersion).getDefaultEnvelope());
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+ }
+
+ SOAPEnvelope envelope = msgContext.getEnvelope();
+ Iterator keys = rmMessageParts.keySet().iterator();
+ while (keys.hasNext()) {
+ Integer key = (Integer) keys.next();
+ int partId = key.intValue();
+
+ if (isMultiPart(partId)) {
+ for (Iterator it=getMessageParts(partId);it.hasNext();) {
+ IOMRMPart rmPart = (IOMRMPart) it.next();
+ rmPart.toSOAPEnvelope(envelope);
+ }
+ } else {
+ IOMRMPart rmPart = (IOMRMPart) rmMessageParts.get(key);
+ rmPart.toSOAPEnvelope(envelope);
+ }
+ }
+ }
+
+ public int getMessageType() {
+ return messageType;
+ }
+
+
+ /**
+ * The message type can be used to easily identify what this message is.
+ * Possible message types are given in the Constnts.MessageTypes interface.
+ *
+ * @param msgType
+ */
+ public void setMessageType(int msgType) {
+ if (msgType >= 0 && msgType <= Sandesha2Constants.MessageTypes.MAX_MESSAGE_TYPE)
+ this.messageType = msgType;
+ }
+
+
+ /**
+ * Sets an IRMPart object to the MessageContext. Possible parts are give in the
+ *
+ *
+ * @param partId
+ * @param part
+ */
+ public void setMessagePart(int partId, IOMRMPart part) {
+ if (partId >= 0 && partId <= Sandesha2Constants.MessageParts.MAX_MSG_PART_ID) {
+ if (isMultiPart(partId)) {
+ ArrayList partList = (ArrayList) rmMessageParts.get(new Integer (partId));
+ if (partList==null) {
+ partList = new ArrayList ();
+ rmMessageParts.put(new Integer (partId),partList);
+ }
+ partList.add(part);
+ } else {
+ rmMessageParts.put(new Integer(partId), part);
+ }
+ }
+ }
+
+
+ public IOMRMPart getMessagePart(int partId) throws SandeshaException {
+ if (isMultiPart(partId)) {
+ String message = "It is possible for a multiple MessageParts of this type to exit. Please call the 'getMessageParts' method";
+ throw new SandeshaException (message);
+ }
+
+ return (IOMRMPart) rmMessageParts.get(new Integer(partId));
+ }
+
+ public Iterator getMessageParts (int partId) {
+ Object obj = rmMessageParts.get(new Integer (partId));
+ if (obj==null)
+ return new ArrayList().iterator();
+
+ if (obj instanceof ArrayList) {
+ return ((ArrayList) obj).iterator();
+ } else {
+ ArrayList arr = new ArrayList ();
+ arr.add(obj);
+ return arr.iterator();
+ }
+ }
+
+ public void removeMessageParts (int messageType) {
+ rmMessageParts.remove (new Integer (messageType));
+ }
+
+ //checks weather there can be multiple elements of these parts,
+ //if so getMessageParts method has to be called to get a ArrayList of parts..
+ public boolean isMultiPart (int messagePartId) {
+ if (messagePartId==Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT||
+ messagePartId==Sandesha2Constants.MessageParts.ACK_REQUEST)
+ return true;
+
+ return false;
+ }
+
+ public EndpointReference getFrom() {
+ return msgContext.getFrom();
+ }
+
+ public EndpointReference getTo() {
+ return msgContext.getTo();
+ }
+
+ public EndpointReference getReplyTo() {
+ return msgContext.getReplyTo();
+ }
+
+ public RelatesTo getRelatesTo() {
+ return msgContext.getRelatesTo();
+ }
+
+ public String getMessageId() {
+ return msgContext.getMessageID();
+ }
+
+ public void setFaultTo(EndpointReference epr) {
+ msgContext.setFaultTo(epr);
+ }
+
+ public EndpointReference getFaultTo() {
+ return msgContext.getFaultTo();
+ }
+
+ public SOAPEnvelope getSOAPEnvelope() {
+ return msgContext.getEnvelope();
+ }
+
+ public void setSOAPEnvelop(SOAPEnvelope envelope) throws SandeshaException {
+
+ try {
+ msgContext.setEnvelope(envelope);
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+ }
+
+ public void setFrom(EndpointReference epr) {
+ msgContext.setFrom(epr);
+ }
+
+ public void setTo(EndpointReference epr) {
+ msgContext.setTo(epr);
+ }
+
+ public void setReplyTo(EndpointReference epr) {
+ msgContext.setReplyTo(epr);
+ }
+
+ public void setMessageId(String messageId) {
+ msgContext.setMessageID(messageId);
+ }
+
+ public void setAction(String action) {
+ msgContext.setWSAAction(action);
+ }
+
+ public void addRelatesTo(RelatesTo relatesTo) {
+ msgContext.addRelatesTo(relatesTo);
+ }
+
+ public void setWSAAction(String URI) {
+ msgContext.setWSAAction(URI);
+ }
+
+ public String getWSAAction() {
+ return msgContext.getWSAAction();
+ }
+
+ public MessageContext getMessageContext() {
+ return msgContext;
+ }
+
+ public Object getProperty(String key) {
+ if (msgContext == null)
+ return null;
+
+ return msgContext.getProperty(key);
+ }
+
+ public boolean setProperty(String key, Object val) {
+ if (msgContext == null)
+ return false;
+
+ msgContext.setProperty(key, val);
+ return true;
+ }
+
+ public ConfigurationContext getConfigurationContext() {
+ if (msgContext == null)
+ return null;
+
+ return msgContext.getConfigurationContext();
+ }
+
+
+ public void setSOAPAction(String SOAPAction) {
+ msgContext.setSoapAction(SOAPAction);
+ }
+
+ public void pause () {
+ if (msgContext!=null)
+ msgContext.pause();
+ }
+
+ public void setPaused (boolean pause) {
+ if (msgContext!=null)
+ msgContext.setPaused(pause);
+ }
+
+ public String getRMNamespaceValue() {
+ return rmNamespaceValue;
+ }
+
+ public void setRMNamespaceValue(String rmNamespaceValue) {
+ this.rmNamespaceValue = rmNamespaceValue;
+
+ if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(rmNamespaceValue)) {
+ rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
+ } else if (Sandesha2Constants.SPEC_2007_02.NS_URI.equals(rmNamespaceValue)) {
+ rmSpecVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
+ }
+ }
+
+ public String getRMSpecVersion () {
+ if (rmSpecVersion==null) {
+ //this may hv been set in the Options object.
+ if (msgContext!=null && msgContext.getOptions()!=null)
+ rmSpecVersion = (String) msgContext.getOptions().getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
+ }
+
+ return rmSpecVersion;
+ }
+
+ public void setFlow (int flow) {
+ msgContext.setFLOW(flow);
+ }
+
+ public int getFlow () {
+ return msgContext.getFLOW();
+ }
+
+ /**
+ * This will return the sequenceId if it could be derived from the SOAP envelope, in the
+ * message initiation.
+ *
+ * @return
+ */
+ public String getGeneratedSequenceId () {
+ return (String) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID);
+ }
+}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/Sandesha2Constants.java Sat May 26 18:49:59 2007
@@ -28,7 +28,6 @@
public interface Sandesha2Constants {
-
public interface SPEC_VERSIONS {
String v1_0 = "Spec_2005_02";
String v1_1 = "Spec_2007_02";
@@ -563,6 +562,9 @@
static final QName RM_DUPLICATE_OPERATION = new QName(SANDESHA_OP_PREFIX + "Duplicate");
static final QName RM_IN_OUT_OPERATION = new QName(SANDESHA_OP_PREFIX + "InOut");
static final QName RM_IN_ONLY_OPERATION = new QName(SANDESHA_OP_PREFIX + "InOnly");
+
+ static final String DEFAULT_RM_NAMESPACE = Sandesha2Constants.SPEC_2005_02.NS_URI;
+ static final String OUT_LAST_MESSAGE = "OutLastMessage";
static final String [] SPEC_NS_URIS = {
SPEC_2005_02.NS_URI,
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java Sat May 26 18:49:59 2007
@@ -131,7 +131,9 @@
//This is responsible for Sandesha2 specific
InvocationResponse response = FaultManager.processMessagesForFaults(rmMsgCtx, storageManager);
- if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
+ //both application msgs and lastMsg msgs will be processed in the same way here.
+ if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION ||
+ rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.LAST_MESSAGE) {
processApplicationMessage(rmMsgCtx);
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaInHandler.java Sat May 26 18:49:59 2007
@@ -108,7 +108,7 @@
rmMsgCtx = MsgInitializer.initializeMessage(msgCtx);
// validating the message
- MessageValidator.validateMessage(rmMsgCtx, storageManager);
+ MessageValidator.validateIncomingMessage(rmMsgCtx, storageManager);
// commit the current transaction
if(transaction != null && transaction.isActive()) transaction.commit();
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java Sat May 26 18:49:59 2007
@@ -234,5 +234,6 @@
public final static String cannotSetPolicyBeanServiceNull = "cannotSetPolicyBeanServiceNull";
public final static String noPolling="noPolling";
public final static String freeingTransport="freeingTransport";
+ public final static String offerRequiredForAnon = "offerRequiredForAnon";
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Sat May 26 18:49:59 2007
@@ -29,6 +29,7 @@
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.sandesha2.MessageValidator;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.Sandesha2Constants;
import org.apache.sandesha2.SandeshaException;
@@ -88,6 +89,9 @@
MessageContext msgContext = rmMsgCtx.getMessageContext();
ConfigurationContext configContext = msgContext.getConfigurationContext();
+ //validating the outgoing message
+ MessageValidator.validateOutgoingMessage(rmMsgCtx);
+
// setting the Fault callback
SandeshaListener faultCallback = (SandeshaListener) msgContext.getOptions().getProperty(
SandeshaClientConstants.SANDESHA_LISTENER);
@@ -278,7 +282,7 @@
if (serverSide) {
// Deciding whether this is the last message. We assume it is if it relates to
- // a message which arrived with the LastMessage flag on it.
+ // a message which arrived with the LastMessage flag on it.
RMDBean rmdBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
// Get the last in message
String lastRequestId = rmdBean.getLastInMessageId();
@@ -287,6 +291,11 @@
lastRequestId.equals(relatesTo.getValue())) {
lastMessage = true;
}
+
+ //or a constant property may call it as the last msg
+ Boolean inboundLast = (Boolean) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE);
+ if (inboundLast!=null && inboundLast.booleanValue())
+ lastMessage = true;
}
if (lastMessage)
@@ -376,22 +385,20 @@
}
EndpointReference toEPR = msgContext.getTo();
- if (toEPR == null) {
- String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
- log.debug(message);
- throw new SandeshaException(message);
- }
- // setting default actions.
- String to = toEPR.getAddress();
- String operationName = msgContext.getOperationContext().getAxisOperation().getName().getLocalPart();
- if (msgContext.getWSAAction() == null) {
- msgContext.setWSAAction(to + "/" + operationName);
- }
- if (msgContext.getSoapAction() == null) {
- msgContext.setSoapAction("\"" + to + "/" + operationName + "\"");
+
+ if (toEPR != null) {
+ // setting default actions.
+ String to = toEPR.getAddress();
+ String operationName = msgContext.getOperationContext().getAxisOperation().getName().getLocalPart();
+ if (msgContext.getWSAAction() == null) {
+ msgContext.setWSAAction(to + "/" + operationName);
+ }
+ if (msgContext.getSoapAction() == null) {
+ msgContext.setSoapAction("\"" + to + "/" + operationName + "\"");
+ }
}
-
+
// processing the response if not an dummy.
if (!dummyMessage)
processResponseMessage(rmMsgCtx, rmsBean, internalSequenceId, outSequenceID, messageNumber, storageKey, storageManager);
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java Sat May 26 18:49:59 2007
@@ -42,6 +42,7 @@
import org.apache.sandesha2.security.SecurityToken;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
import org.apache.sandesha2.storage.beans.RMDBean;
import org.apache.sandesha2.storage.beans.RMSBean;
import org.apache.sandesha2.util.FaultManager;
@@ -214,6 +215,9 @@
rMSBean.setOfferedEndPoint(endpoint.getEPR().getAddress());
}
+ rmdBean.setOutboundInternalSequence(outgoingSideInternalSequenceId);
+ RMDBeanMgr rmdBeanMgr = storageManager.getRMDBeanMgr();
+ rmdBeanMgr.update(rmdBean);
// Store the inbound token (if any) with the new sequence
rMSBean.setSecurityTokenData(rmdBean.getSecurityTokenData());
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/LastMessageProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/LastMessageProcessor.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/LastMessageProcessor.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/LastMessageProcessor.java Sat May 26 18:49:59 2007
@@ -3,36 +3,120 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axiom.soap.SOAPFactory;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
import org.apache.axis2.client.Options;
+import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisOperationFactory;
+import org.apache.axis2.description.OutInAxisOperation;
import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.util.MessageContextBuilder;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.storage.StorageManager;
+import org.apache.sandesha2.storage.Transaction;
+import org.apache.sandesha2.storage.beanmanagers.RMDBeanMgr;
+import org.apache.sandesha2.storage.beanmanagers.RMSBeanMgr;
+import org.apache.sandesha2.storage.beans.RMDBean;
+import org.apache.sandesha2.storage.beans.RMSBean;
+import org.apache.sandesha2.util.MsgInitializer;
+import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
+import org.apache.sandesha2.wsrm.Sequence;
+import org.ietf.jgss.MessageProp;
-public class LastMessageProcessor {
+public class LastMessageProcessor implements MsgProcessor {
+
+
+
+
+ public boolean processInMessage(RMMsgContext rmMsgCtx, Transaction transaction) throws AxisFault {
+ processLastMessage(rmMsgCtx);
+ return true;
+ }
+
+ public boolean processOutMessage(RMMsgContext rmMsgCtx) throws AxisFault {
+ // TODO Auto-generated method stub
+ return false;
+ }
public static void processLastMessage(RMMsgContext rmMsgCtx) throws AxisFault {
if (!Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(rmMsgCtx.getRMSpecVersion()))
return;
- MessageContext msgContext = rmMsgCtx.getMessageContext();
- MessageContext outMessage = MessageContextBuilder.createOutMessageContext(msgContext);
+ Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+ String sequenceId = sequence.getIdentifier().getIdentifier();
- //add the SOAP envelope with body null
- SOAPFactory factory = (SOAPFactory) msgContext.getEnvelope().getOMFactory();
- SOAPEnvelope envelope = factory.getDefaultEnvelope();
- outMessage.setEnvelope(envelope);
-
- //set the LastMessageAction and the property
- if (outMessage.getOptions()==null)
- outMessage.setOptions(new Options ());
+ ConfigurationContext configurationContext = rmMsgCtx.getConfigurationContext();
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(
+ configurationContext, configurationContext.getAxisConfiguration());
+
+ RMDBeanMgr rmdMgr = storageManager.getRMDBeanMgr();
+ RMDBean rmdBean = rmdMgr.retrieve(sequenceId);
+ String outBoundInternalSequence = rmdBean.getOutboundInternalSequence();
+
+ RMSBeanMgr rmsBeanMgr = storageManager.getRMSBeanMgr();
+ RMSBean findBean = new RMSBean ();
+ findBean.setInternalSequenceID(outBoundInternalSequence);
+ RMSBean rmsBean = rmsBeanMgr.findUnique (findBean);
+
+ if (rmsBean!=null && rmsBean.getLastOutMessage()<=0) {
+ //there is a RMS sequence without a LastMsg entry
+
+ MessageContext msgContext = rmMsgCtx.getMessageContext();
+// MessageContext outMessage = MessageContextBuilder.createOutMessageContext(msgContext);
+
+ MessageContext outMessageContext = new MessageContext ();
+ outMessageContext.setServerSide(true);
+
+ outMessageContext.setTransportOut(msgContext.getTransportOut());
+ outMessageContext.setProperty (Constants.OUT_TRANSPORT_INFO, msgContext.getProperty(Constants.OUT_TRANSPORT_INFO));
+ outMessageContext.setProperty (MessageContext.TRANSPORT_OUT, msgContext.getProperty(MessageContext.TRANSPORT_OUT));
+
+ //add the SOAP envelope with body null
+ SOAPFactory factory = (SOAPFactory) msgContext.getEnvelope().getOMFactory();
+ SOAPEnvelope envelope = factory.getDefaultEnvelope();
+ outMessageContext.setEnvelope(envelope);
+
+ //set the LastMessageAction and the property
+ if (outMessageContext.getOptions()==null)
+ outMessageContext.setOptions(new Options ());
+
+ outMessageContext.setConfigurationContext(msgContext.getConfigurationContext());
+ outMessageContext.setServiceContext(msgContext.getServiceContext());
+ outMessageContext.setAxisService(msgContext.getAxisService());
+
+ AxisOperation operation = SpecSpecificConstants.getWSRMOperation(Sandesha2Constants.MessageTypes.LAST_MESSAGE,
+ rmMsgCtx.getRMSpecVersion() , msgContext.getAxisService());
+
+ OperationContext operationContext = new OperationContext (operation,msgContext.getServiceContext());
+ operationContext.addMessageContext(outMessageContext);
+
+ String inboundSequenceId = (String) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
+ operationContext.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID,
+ inboundSequenceId);
+
+ Long inboundMSgNo = (Long) msgContext.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER);
+ operationContext.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_MESSAGE_NUMBER,
+ inboundMSgNo);
+
+ outMessageContext.setAxisOperation(operation);
+ outMessageContext.setOperationContext(operationContext);
+
+ outMessageContext.getOptions().setAction(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_LAST_MESSAGE);
+
+ //says that the inbound msg of this was a LastMessage - so the new msg will also be a LastMessage
+ outMessageContext.setProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE, Boolean.TRUE);
+
+ AxisEngine engine = new AxisEngine (rmMsgCtx.getConfigurationContext());
+ engine.send(outMessageContext);
+
+ }
- outMessage.getOptions().setAction(Sandesha2Constants.SPEC_2005_02.Actions.ACTION_LAST_MESSAGE);
- AxisEngine engine = new AxisEngine (rmMsgCtx.getConfigurationContext());
- engine.send(outMessage);
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/MsgProcessorFactory.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/MsgProcessorFactory.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/MsgProcessorFactory.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/MsgProcessorFactory.java Sat May 26 18:49:59 2007
@@ -1,52 +1,54 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *
- */
-
-package org.apache.sandesha2.msgprocessors;
-
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-
-/**
- * Used to get a suitable message processor. Given the message type.
- */
-
-public class MsgProcessorFactory {
-
- public static MsgProcessor getMessageProcessor(RMMsgContext rmMessageContext) {
-
- int messageType = rmMessageContext.getMessageType();
-
- switch (messageType) {
- case (Sandesha2Constants.MessageTypes.CREATE_SEQ):
- return new CreateSeqMsgProcessor();
- case (Sandesha2Constants.MessageTypes.TERMINATE_SEQ):
- return new TerminateSeqMsgProcessor();
- case (Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE):
- return new TerminateSeqResponseMsgProcessor();
- case (Sandesha2Constants.MessageTypes.APPLICATION):
- return new ApplicationMsgProcessor();
- case (Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE):
- return new CreateSeqResponseMsgProcessor();
- case (Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE):
- return new CloseSequenceProcessor();
- case (Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG):
- return new MakeConnectionProcessor ();
- default:
- return null;
- }
- }
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.sandesha2.msgprocessors;
+
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+
+/**
+ * Used to get a suitable message processor. Given the message type.
+ */
+
+public class MsgProcessorFactory {
+
+ public static MsgProcessor getMessageProcessor(RMMsgContext rmMessageContext) {
+
+ int messageType = rmMessageContext.getMessageType();
+
+ switch (messageType) {
+ case (Sandesha2Constants.MessageTypes.CREATE_SEQ):
+ return new CreateSeqMsgProcessor();
+ case (Sandesha2Constants.MessageTypes.TERMINATE_SEQ):
+ return new TerminateSeqMsgProcessor();
+ case (Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE):
+ return new TerminateSeqResponseMsgProcessor();
+ case (Sandesha2Constants.MessageTypes.APPLICATION):
+ return new ApplicationMsgProcessor();
+ case (Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE):
+ return new CreateSeqResponseMsgProcessor();
+ case (Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE):
+ return new CloseSequenceProcessor();
+ case (Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG):
+ return new MakeConnectionProcessor ();
+ case (Sandesha2Constants.MessageTypes.LAST_MESSAGE):
+ return new LastMessageProcessor ();
+ default:
+ return null;
+ }
+ }
+}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/SequenceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/SequenceProcessor.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/SequenceProcessor.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/SequenceProcessor.java Sat May 26 18:49:59 2007
@@ -55,6 +55,7 @@
import org.apache.sandesha2.util.AcknowledgementManager;
import org.apache.sandesha2.util.FaultManager;
import org.apache.sandesha2.util.SandeshaUtil;
+import org.apache.sandesha2.util.SpecSpecificConstants;
import org.apache.sandesha2.util.TerminateManager;
import org.apache.sandesha2.workers.SandeshaThread;
import org.apache.sandesha2.wsrm.Sequence;
@@ -318,8 +319,9 @@
boolean sendAck = false;
+ boolean ackBackChannel = SpecSpecificConstants.sendAckInBackChannel (rmMsgCtx.getMessageType());
EndpointReference acksTo = new EndpointReference (bean.getAcksToEPR());
- if (acksTo.hasAnonymousAddress() && backchannelFree) {
+ if (acksTo.hasAnonymousAddress() && backchannelFree && ackBackChannel) {
Object responseWritten = msgCtx.getOperationContext().getProperty(Constants.RESPONSE_WRITTEN);
if (responseWritten==null || !Constants.VALUE_TRUE.equals(responseWritten)) {
sendAck = true;
@@ -355,7 +357,7 @@
// Whatever the MEP, we stop processing here and the invoker will do the real work. We only
// SUSPEND if we need to keep the backchannel open for the response... we may as well ABORT
// to let other cases end more quickly.
- if(backchannelFree) {
+ if(backchannelFree && ackBackChannel) {
result = InvocationResponse.ABORT;
} else {
result = InvocationResponse.SUSPEND;
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgreceivers/RMMessageReceiver.java Sat May 26 18:49:59 2007
@@ -74,14 +74,8 @@
msgProcessor.processInMessage(rmMsgCtx, transaction);
- //If message is a LastMessage then we deligate the processing to the LastMessageProcessor
- Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
- if (sequence!=null && sequence.getLastMessage()!=null) {
- LastMessageProcessor.processLastMessage(rmMsgCtx);
- }
-
- if(transaction != null && transaction.isActive()) transaction.commit();
- transaction = null;
+ if(transaction != null && transaction.isActive()) transaction.commit();
+ transaction = null;
} catch (Exception e) {
if (log.isDebugEnabled())
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/storage/beans/RMSBean.java Sat May 26 18:49:59 2007
@@ -152,7 +152,7 @@
private static final int TERM_PAUSER_FOR_CS = 0x00000002;
private static final int EXPECTED_REPLIES = 0x00000020;
private static final int SOAP_VERSION_FLAG = 0x00000200;
-
+
/**
* In WSRM Anon URI scenario, we may not want to terminate a perticular sequence until the CreateSequence has been received
* for the response side, other wise PollingManager will pause the polling process in termination and we will never be able
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/MsgInitializer.java Sat May 26 18:49:59 2007
@@ -1,257 +1,270 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- *
- */
-
-package org.apache.sandesha2.util;
-
-import java.util.Iterator;
-
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.context.MessageContext;
-import org.apache.sandesha2.RMMsgContext;
-import org.apache.sandesha2.Sandesha2Constants;
-import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.wsrm.AckRequested;
-import org.apache.sandesha2.wsrm.CloseSequence;
-import org.apache.sandesha2.wsrm.CloseSequenceResponse;
-import org.apache.sandesha2.wsrm.CreateSequence;
-import org.apache.sandesha2.wsrm.CreateSequenceResponse;
-import org.apache.sandesha2.wsrm.MakeConnection;
-import org.apache.sandesha2.wsrm.RMElements;
-import org.apache.sandesha2.wsrm.Sequence;
-import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
-import org.apache.sandesha2.wsrm.TerminateSequence;
-import org.apache.sandesha2.wsrm.TerminateSequenceResponse;
-
-/**
- * This class is used to create an RMMessageContext out of an MessageContext.
- */
-
-public class MsgInitializer {
-
- /**
- * Called to create a rmMessageContext out of an message context. Finds out
- * things like rm version and message type as well.
- *
- * @param ctx
- * @param assumedRMNamespace
- * this is used for validation (to find out weather the
- * rmNamespace of the current message is equal to the regietered
- * rmNamespace of the sequence). If null validation will not
- * happen.
- *
- * @return
- * @throws SandeshaException
- */
- public static RMMsgContext initializeMessage(MessageContext ctx) throws AxisFault {
- RMMsgContext rmMsgCtx = new RMMsgContext(ctx);
-
- populateRMMsgContext(ctx, rmMsgCtx);
- validateMessage(rmMsgCtx);
- return rmMsgCtx;
- }
-
- /**
- * Adds the message parts the the RMMessageContext.
- *
- * @param msgCtx
- * @param rmMsgContext
- */
- private static void populateRMMsgContext(MessageContext msgCtx, RMMsgContext rmMsgContext) throws AxisFault {
-
- // if client side and the addressing version is not set. assuming the
- // default addressing version
- String addressingNamespace = (String) msgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
- if (addressingNamespace == null && !msgCtx.isServerSide())
- addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
-
- RMElements elements = new RMElements(addressingNamespace);
- elements.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());
-
- String rmNamespace = null;
-
- if (elements.getCreateSequence() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ, elements.getCreateSequence());
- rmNamespace = elements.getCreateSequence().getNamespaceValue();
- }
-
- if (elements.getCreateSequenceResponse() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE, elements
- .getCreateSequenceResponse());
- rmNamespace = elements.getCreateSequenceResponse().getNamespaceValue();
- }
-
- if (elements.getSequence() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, elements.getSequence());
- rmNamespace = elements.getSequence().getNamespaceValue();
- }
-
- //In case of ack messages RM Namespace is decided based on the sequenceId of the last
- //sequence Ack. In other words Sandesha2 does not expect to receive two SequenceAcknowledgements
- //of different RM specifications in the same incoming message
- for (Iterator iter = elements.getSequenceAcknowledgements();iter.hasNext();) {
- SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) iter.next();
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
- rmNamespace = sequenceAck.getNamespaceValue();
- }
-
- if (elements.getTerminateSequence() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ, elements.getTerminateSequence());
- rmNamespace = elements.getTerminateSequence().getNamespaceValue();
- }
-
- if (elements.getTerminateSequenceResponse() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE, elements
- .getTerminateSequenceResponse());
- rmNamespace = elements.getTerminateSequenceResponse().getNamespaceValue();
- }
-
- //In case of ack request messages RM Namespace is decided based on the sequenceId of the last
- //ack request.
- for (Iterator iter = elements.getAckRequests();iter.hasNext();) {
- AckRequested ackRequest = (AckRequested) iter.next();
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequest);
- rmNamespace = ackRequest.getNamespaceValue();
- }
-
- if (elements.getCloseSequence() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE, elements.getCloseSequence());
- rmNamespace = elements.getCloseSequence().getNamespaceValue();
- }
-
- if (elements.getCloseSequenceResponse() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE, elements
- .getCloseSequenceResponse());
- rmNamespace = elements.getCloseSequenceResponse().getNamespaceValue();
- }
-
- if (elements.getUsesSequenceSTR() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.USES_SEQUENCE_STR, elements
- .getUsesSequenceSTR());
- }
-
- if (elements.getMakeConnection() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION,
- elements.getMakeConnection());
- String makeConnectionNamespace = elements.getMakeConnection().getNamespaceValue();
- if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnectionNamespace))
- rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
- }
-
- if (elements.getMessagePending() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MESSAGE_PENDING,
- elements.getMessagePending());
- rmNamespace = elements.getMessagePending().getNamespaceValue();
- }
-
- if (elements.getSequenceFault() != null) {
- rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE_FAULT,
- elements.getSequenceFault());
- }
-
- rmMsgContext.setRMNamespaceValue(rmNamespace);
-
- }
-
- /**
- * This is used to validate the message. Also set an Message type. Possible
- * types are given in the Sandesha2Constants.MessageTypes interface.
- *
- * @param rmMsgCtx
- * @return
- * @throws SandeshaException
- */
- private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
-
- String sequenceID = null;
-
- CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.CREATE_SEQ);
- CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
- TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.TERMINATE_SEQ);
- TerminateSequenceResponse terminateSequenceResponse = (TerminateSequenceResponse) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
- Iterator sequenceAcknowledgementsIter = rmMsgCtx.getMessageParts(
- Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
- Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.SEQUENCE);
- Iterator ackRequestedIter = rmMsgCtx.getMessageParts(
- Sandesha2Constants.MessageParts.ACK_REQUEST);
- CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
- CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
- MakeConnection makeConnection = (MakeConnection) rmMsgCtx.getMessagePart(
- Sandesha2Constants.MessageParts.MAKE_CONNECTION);
-
- // Setting message type.
- if (createSequence != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
- } else if (createSequenceResponse != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
- sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
- } else if (terminateSequence != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
- sequenceID = terminateSequence.getIdentifier().getIdentifier();
- } else if (terminateSequenceResponse != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
- sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
- } else if (rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE) != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
- sequenceID = sequence.getIdentifier().getIdentifier();
- } else if (sequenceAcknowledgementsIter.hasNext()) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
- SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) sequenceAcknowledgementsIter.next();
-
- //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
- if (!sequenceAcknowledgementsIter.hasNext())
- sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
- } else if (ackRequestedIter.hasNext()) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
- AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
-
- //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
- if (!ackRequestedIter.hasNext())
- sequenceID = ackRequest.getIdentifier().getIdentifier();
- } else if (closeSequence != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE);
- sequenceID = closeSequence.getIdentifier().getIdentifier();
- } else if (closeSequenceResponse != null) {
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE);
- sequenceID = closeSequenceResponse.getIdentifier().getIdentifier();
- } else if (makeConnection != null){
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);
- if (makeConnection.getIdentifier()!=null) {
- sequenceID = makeConnection.getIdentifier().getIdentifier();
- } else if (makeConnection.getAddress()!=null){
- //TODO get sequenceId based on the anonymous address.
- } else {
- throw new SandeshaException (
- "Invalid MakeConnection message. Either Address or Identifier must be present");
- }
- } else
- rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.UNKNOWN);
-
- if (sequenceID!=null)
- rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID,sequenceID);
-
- return true;
- }
-
-}
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.sandesha2.util;
+
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.sandesha2.RMMsgContext;
+import org.apache.sandesha2.Sandesha2Constants;
+import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.wsrm.AckRequested;
+import org.apache.sandesha2.wsrm.CloseSequence;
+import org.apache.sandesha2.wsrm.CloseSequenceResponse;
+import org.apache.sandesha2.wsrm.CreateSequence;
+import org.apache.sandesha2.wsrm.CreateSequenceResponse;
+import org.apache.sandesha2.wsrm.LastMessage;
+import org.apache.sandesha2.wsrm.MakeConnection;
+import org.apache.sandesha2.wsrm.RMElements;
+import org.apache.sandesha2.wsrm.Sequence;
+import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
+import org.apache.sandesha2.wsrm.TerminateSequence;
+import org.apache.sandesha2.wsrm.TerminateSequenceResponse;
+
+/**
+ * This class is used to create an RMMessageContext out of an MessageContext.
+ */
+
+public class MsgInitializer {
+
+ /**
+ * Called to create a rmMessageContext out of an message context. Finds out
+ * things like rm version and message type as well.
+ *
+ * @param ctx
+ * @param assumedRMNamespace
+ * this is used for validation (to find out weather the
+ * rmNamespace of the current message is equal to the regietered
+ * rmNamespace of the sequence). If null validation will not
+ * happen.
+ *
+ * @return
+ * @throws SandeshaException
+ */
+ public static RMMsgContext initializeMessage(MessageContext ctx) throws AxisFault {
+ RMMsgContext rmMsgCtx = new RMMsgContext(ctx);
+
+ populateRMMsgContext(ctx, rmMsgCtx);
+ validateMessage(rmMsgCtx);
+ return rmMsgCtx;
+ }
+
+ /**
+ * Adds the message parts the the RMMessageContext.
+ *
+ * @param msgCtx
+ * @param rmMsgContext
+ */
+ private static void populateRMMsgContext(MessageContext msgCtx, RMMsgContext rmMsgContext) throws AxisFault {
+
+ // if client side and the addressing version is not set. assuming the
+ // default addressing version
+ String addressingNamespace = (String) msgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+ if (addressingNamespace == null && !msgCtx.isServerSide())
+ addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE;
+
+ RMElements elements = new RMElements(addressingNamespace);
+ elements.fromSOAPEnvelope(msgCtx.getEnvelope(), msgCtx.getWSAAction());
+
+ String rmNamespace = null;
+
+ if (elements.getCreateSequence() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ, elements.getCreateSequence());
+ rmNamespace = elements.getCreateSequence().getNamespaceValue();
+ }
+
+ if (elements.getCreateSequenceResponse() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE, elements
+ .getCreateSequenceResponse());
+ rmNamespace = elements.getCreateSequenceResponse().getNamespaceValue();
+ }
+
+ if (elements.getSequence() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, elements.getSequence());
+ rmNamespace = elements.getSequence().getNamespaceValue();
+ }
+
+ //In case of ack messages RM Namespace is decided based on the sequenceId of the last
+ //sequence Ack. In other words Sandesha2 does not expect to receive two SequenceAcknowledgements
+ //of different RM specifications in the same incoming message
+ for (Iterator iter = elements.getSequenceAcknowledgements();iter.hasNext();) {
+ SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) iter.next();
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
+ rmNamespace = sequenceAck.getNamespaceValue();
+ }
+
+ if (elements.getTerminateSequence() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ, elements.getTerminateSequence());
+ rmNamespace = elements.getTerminateSequence().getNamespaceValue();
+ }
+
+ if (elements.getTerminateSequenceResponse() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE, elements
+ .getTerminateSequenceResponse());
+ rmNamespace = elements.getTerminateSequenceResponse().getNamespaceValue();
+ }
+
+ //In case of ack request messages RM Namespace is decided based on the sequenceId of the last
+ //ack request.
+ for (Iterator iter = elements.getAckRequests();iter.hasNext();) {
+ AckRequested ackRequest = (AckRequested) iter.next();
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequest);
+ rmNamespace = ackRequest.getNamespaceValue();
+ }
+
+ if (elements.getCloseSequence() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE, elements.getCloseSequence());
+ rmNamespace = elements.getCloseSequence().getNamespaceValue();
+ }
+
+ if (elements.getCloseSequenceResponse() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE, elements
+ .getCloseSequenceResponse());
+ rmNamespace = elements.getCloseSequenceResponse().getNamespaceValue();
+ }
+
+ if (elements.getUsesSequenceSTR() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.USES_SEQUENCE_STR, elements
+ .getUsesSequenceSTR());
+ }
+
+ if (elements.getMakeConnection() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MAKE_CONNECTION,
+ elements.getMakeConnection());
+ String makeConnectionNamespace = elements.getMakeConnection().getNamespaceValue();
+ if (Sandesha2Constants.SPEC_2007_02.MC_NS_URI.equals(makeConnectionNamespace))
+ rmNamespace = Sandesha2Constants.SPEC_2007_02.NS_URI;
+ }
+
+ if (elements.getMessagePending() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.MESSAGE_PENDING,
+ elements.getMessagePending());
+ rmNamespace = elements.getMessagePending().getNamespaceValue();
+ }
+
+ if (elements.getSequenceFault() != null) {
+ rmMsgContext.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE_FAULT,
+ elements.getSequenceFault());
+ }
+
+ if (rmNamespace!=null)
+ rmMsgContext.setRMNamespaceValue(rmNamespace);
+
+ }
+
+ /**
+ * This is used to validate the message. Also set an Message type. Possible
+ * types are given in the Sandesha2Constants.MessageTypes interface.
+ *
+ * @param rmMsgCtx
+ * @return
+ * @throws SandeshaException
+ */
+ private static boolean validateMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
+
+ String sequenceID = null;
+
+ CreateSequence createSequence = (CreateSequence) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.CREATE_SEQ);
+ CreateSequenceResponse createSequenceResponse = (CreateSequenceResponse) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
+ TerminateSequence terminateSequence = (TerminateSequence) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.TERMINATE_SEQ);
+ TerminateSequenceResponse terminateSequenceResponse = (TerminateSequenceResponse) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.TERMINATE_SEQ_RESPONSE);
+ Iterator sequenceAcknowledgementsIter = rmMsgCtx.getMessageParts(
+ Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
+ Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.SEQUENCE);
+ Iterator ackRequestedIter = rmMsgCtx.getMessageParts(
+ Sandesha2Constants.MessageParts.ACK_REQUEST);
+ CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
+ CloseSequenceResponse closeSequenceResponse = (CloseSequenceResponse) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.CLOSE_SEQUENCE_RESPONSE);
+ MakeConnection makeConnection = (MakeConnection) rmMsgCtx.getMessagePart(
+ Sandesha2Constants.MessageParts.MAKE_CONNECTION);
+
+ // Setting message type.
+ if (createSequence != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
+ } else if (createSequenceResponse != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ_RESPONSE);
+ sequenceID = createSequenceResponse.getIdentifier().getIdentifier();
+ } else if (terminateSequence != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ);
+ sequenceID = terminateSequence.getIdentifier().getIdentifier();
+ } else if (terminateSequenceResponse != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.TERMINATE_SEQ_RESPONSE);
+ sequenceID = terminateSequenceResponse.getIdentifier().getIdentifier();
+ } else if (rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE) != null) {
+
+ Sequence seq = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+ LastMessage lastMessage = seq.getLastMessage();
+ SOAPEnvelope envelope = rmMsgCtx.getSOAPEnvelope();
+
+ if (lastMessage!=null && envelope.getBody().getFirstOMChild()==null) {
+ //the message is an empty body last message
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
+ }else
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
+
+ sequenceID = sequence.getIdentifier().getIdentifier();
+ } else if (sequenceAcknowledgementsIter.hasNext()) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
+ SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) sequenceAcknowledgementsIter.next();
+
+ //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
+ if (!sequenceAcknowledgementsIter.hasNext())
+ sequenceID = sequenceAcknowledgement.getIdentifier().getIdentifier();
+ } else if (ackRequestedIter.hasNext()) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK_REQUEST);
+ AckRequested ackRequest = (AckRequested) ackRequestedIter.next();
+
+ //if there is only on sequenceAck, sequenceId will be set. Otherwise it will not be.
+ if (!ackRequestedIter.hasNext())
+ sequenceID = ackRequest.getIdentifier().getIdentifier();
+ } else if (closeSequence != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE);
+ sequenceID = closeSequence.getIdentifier().getIdentifier();
+ } else if (closeSequenceResponse != null) {
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.CLOSE_SEQUENCE_RESPONSE);
+ sequenceID = closeSequenceResponse.getIdentifier().getIdentifier();
+ } else if (makeConnection != null){
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.MAKE_CONNECTION_MSG);
+ if (makeConnection.getIdentifier()!=null) {
+ sequenceID = makeConnection.getIdentifier().getIdentifier();
+ } else if (makeConnection.getAddress()!=null){
+ //TODO get sequenceId based on the anonymous address.
+ } else {
+ throw new SandeshaException (
+ "Invalid MakeConnection message. Either Address or Identifier must be present");
+ }
+ } else
+ rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.UNKNOWN);
+
+ if (sequenceID!=null)
+ rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.SEQUENCE_ID,sequenceID);
+
+ return true;
+ }
+
+}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SpecSpecificConstants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SpecSpecificConstants.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SpecSpecificConstants.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SpecSpecificConstants.java Sat May 26 18:49:59 2007
@@ -439,5 +439,17 @@
return result;
}
+
+ public static boolean sendAckInBackChannel (int messageType) {
+ boolean result = true;
+
+ switch (messageType) {
+ case Sandesha2Constants.MessageTypes.LAST_MESSAGE:
+ result = false;
+ break;
+ }
+
+ return result;
+ }
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/workers/SenderWorker.java Sat May 26 18:49:59 2007
@@ -408,7 +408,7 @@
sequence.setMessageNumber(msgNumber);
if(senderBean.isLastMessage() &&
- SpecSpecificConstants.isLastMessageIndicatorRequired(rmVersion)) {
+ SpecSpecificConstants.isLastMessageIndicatorRequired(rmVersion)) {
sequence.setLastMessage(new LastMessage(namespace));
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties?view=diff&rev=541957&r1=541956&r2=541957
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties Sat May 26 18:49:59 2007
@@ -219,6 +219,7 @@
invalidElementFoundWithinElement=Found invalid ''{0}'' element within ''{1}'' element.
invokerNotFound=An invoker thread was not found to dispatch messages on the inbound sequence {0}.
cannotSetPolicyBeanServiceNull=Cannot set the given SandeshaPolicyBean since the AxisService is not present
+offerRequiredForAnon=If you are going to try sync in-out message exchanges with RM 1.0, you must do an offer
#------------------
# Security messages
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org