You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by ch...@apache.org on 2005/11/03 02:32:41 UTC
svn commit: r330406 [2/3] - in
/webservices/sandesha/trunk/src/org/apache/sandesha2: ./ handlers/
msgprocessors/ storage/ storage/beanmanagers/ storage/beans/
storage/inmemory/ util/ workers/ wsrm/
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageManager.java Wed Nov 2 17:27:17 2005
@@ -1,23 +1,22 @@
/*
* Copyright 2004,2005 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.
*
+ * 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.storage.inmemory;
-import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.Transaction;
@@ -26,20 +25,19 @@
import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
-import org.apache.sandesha2.storage.beans.RetransmitterBean;
public class InMemoryStorageManager extends StorageManager {
-
+
private static InMemoryStorageManager instance = null;
- public InMemoryStorageManager (ConfigurationContext context) {
- super (context);
+ public InMemoryStorageManager(ConfigurationContext context) {
+ super(context);
}
-
- public Transaction getTransaction () {
- return new InMemoryTransaction ();
+
+ public Transaction getTransaction() {
+ return new InMemoryTransaction();
}
-
+
public CreateSeqBeanMgr getCreateSeqBeanMgr() {
return new InMemoryCreateSeqBeanMgr(getContext());
}
@@ -72,15 +70,15 @@
// }
// }
-
public void init(ConfigurationContext context) {
setContext(context);
}
- public static InMemoryStorageManager getInstance(ConfigurationContext context) {
+ public static InMemoryStorageManager getInstance(
+ ConfigurationContext context) {
if (instance == null)
instance = new InMemoryStorageManager(context);
return instance;
}
-}
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageMapBeanMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageMapBeanMgr.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageMapBeanMgr.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryStorageMapBeanMgr.java Wed Nov 2 17:27:17 2005
@@ -21,13 +21,9 @@
import java.util.Collection;
import java.util.Hashtable;
import java.util.Iterator;
-
import org.apache.axis2.context.AbstractContext;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.sandesha2.Constants;
-import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
-import org.apache.sandesha2.storage.beans.CreateSeqBean;
import org.apache.sandesha2.storage.beans.StorageMapBean;
/**
@@ -102,7 +98,7 @@
public boolean update(StorageMapBean bean) {
if (!table.contains(bean))
return false;
-
+
return table.put(bean.getKey(), bean) != null;
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/storage/inmemory/InMemoryTransaction.java Wed Nov 2 17:27:17 2005
@@ -1,18 +1,18 @@
/*
- * 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.
- *
+ * 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.storage.inmemory;
@@ -20,13 +20,13 @@
import org.apache.sandesha2.storage.Transaction;
public class InMemoryTransaction implements Transaction {
-
- public void commit () {
-
+
+ public void commit() {
+
}
-
- public void rollback () {
-
+
+ public void rollback() {
+
}
-
-}
+
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultMgr.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultMgr.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultMgr.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/FaultMgr.java Wed Nov 2 17:27:17 2005
@@ -42,22 +42,14 @@
import org.apache.axis2.soap.SOAPFaultText;
import org.apache.axis2.soap.SOAPFaultValue;
import org.apache.axis2.soap.SOAPHeader;
-import org.apache.axis2.soap.impl.llom.soap12.SOAP12Factory;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.MessageTypes;
-import org.apache.sandesha2.Constants.SOAPVersion;
-import org.apache.sandesha2.Constants.SequenceProperties;
-import org.apache.sandesha2.Constants.WSRM;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.StorageMapBeanMgr;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
-import org.apache.sandesha2.storage.inmemory.InMemoryNextMsgBeanMgr;
-import org.apache.sandesha2.storage.inmemory.InMemorySequencePropertyBeanMgr;
-import org.apache.sandesha2.storage.inmemory.InMemoryStorageMapBeanMgr;
import org.apache.sandesha2.wsrm.FaultCode;
import org.apache.sandesha2.wsrm.SequenceFault;
@@ -67,467 +59,458 @@
public class FaultMgr {
- private static final String WSA_ACTION_FAULT
- = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
-
- public static final int UNKNOWN_SEQUENCE_TYPE = 1;
- public static final int MESSAGE_NUMBER_ROLLOVER_TYPE = 2;
- public static final int INVALID_ACKNOWLEDGEMENT_TYPE = 3;
-
-
- public static final String UNKNOW_SEQUENCE_CODE = "Sender";
- public static final String UNKNOW_SEQUENCE_SUBCODE
- = "wsrm:UnknowSequence";
- public static final String UNKNOW_SEQUENCE_RESON
- = "The vaule of wsrm:Identifier is not a known Sequence Identifer";
-
- public static final String MESSAGE_NUMBER_ROLLOVER_CODE = "Sender";
- public static final String MESSAGE_NUMBER_ROLLOVER_SUBCODE
- = "wsrm:MessageNumberRollover";
- public static final String MESSAGE_NUMBER_ROLLOVER_REASON
- = "The maximum value of wsrm:MessageNumber has been exceeded.";
-
- public static final String INVALID_ACKNOWLEDGEMENT_CODE = "Sender";
- public static final String INVALID_ACKNOWLEDGEMENT_SUBCODE
- = "wsrm:InvalidAcknowledgement";
- public static final String INVALID_ACKNOWLEDGEMENT_REASON
- = "The SequenceAcknowledgement violates the cumlative acknowledgement";
-
- protected class FaultData {
- int type;
- String code;
- String subcode;
- String reason;
- OMElement detail;
- MessageContext msgCtx;
- }
-
- public FaultMgr() {
- }
-
- /**
- *
- * @param msgCtx
- * @return
- * @throws SandeshaException
- */
- public RMMsgContext check(MessageContext msgCtx) throws SandeshaException {
- int msgType = getMessageType(msgCtx);
-
- switch (msgType) {
-
- case Constants.MessageTypes.APPLICATION:
-
- /* Sequence*/
- return checkSequenceMsg(msgCtx);
-
- case Constants.MessageTypes.ACK:
-
- /* SequenceAcknowledgement */
- return checkSequenceAcknowledgementMsg(msgCtx);
-
- default:
-
- /* TODO check for other message types */
- return null;
- }
- }
-
- /**
- * Check whether a Sequence message
- * (a) belongs to a unknown sequence (generates an UnknownSequence fault)
- * (b) message number exceeds a predifined limit ( genenrates a Message
- * Number Rollover fault)
- *
- * @param msgCtx
- * @return
- * @throws SandeshaException
- */
- public RMMsgContext checkSequenceMsg(MessageContext msgCtx)
- throws SandeshaException {
-
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getSystemContext());
- NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
- SOAPEnvelope envelope = msgCtx.getEnvelope();
-
- OMElement element = envelope.getHeader().getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE));
- OMElement identifier = element.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.IDENTIFIER));
-
- String identifierString = identifier.getText().trim();
-
- if (mgr.retrieve(identifierString) == null) {
-
- // should throw an UnknownSequence fault
- return getFault(FaultMgr.UNKNOWN_SEQUENCE_TYPE, msgCtx);
- }
-
- OMElement msgNumber = element.getFirstChildWithName(
- new QName (Constants.WSRM.NS_URI_RM,Constants.WSRM.MSG_NUMBER));
-
- BigInteger bigInteger = new BigInteger(msgNumber.getText().trim());
-
- // throws new MessageNumberRollover fault
- if (bigInteger.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1) {
- return getFault(FaultMgr.MESSAGE_NUMBER_ROLLOVER_TYPE,
- msgCtx);
- }
-
- // Phew !! no faults ..
- return null;
- }
-
- /**
- *
- * @param msgCtx
- * @return
- * @throws SandeshaException
- */
- public RMMsgContext checkSequenceAcknowledgementMsg(MessageContext msgCtx)
- throws SandeshaException {
-
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getSystemContext());
-
- NextMsgBeanMgr mgr
- = storageManager.getNextMsgBeanMgr();
- StorageMapBeanMgr smgr
- = storageManager.getStorageMapBeanMgr();
- SequencePropertyBeanMgr propertyBeanMgr
- = storageManager.getSequencePropretyBeanMgr();
-
- SOAPEnvelope envelope = msgCtx.getEnvelope();
- // this is a SequenceAcknowledgement message
- OMElement element = envelope.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE_ACK));
- OMElement identifier = element.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.IDENTIFIER));
-
- if (mgr.retrieve(identifier.getText()) == null) {
- //throw UnknownSequenceFault
- return getFault(FaultMgr.UNKNOWN_SEQUENCE_TYPE, msgCtx);
- }
-
- String identifierString = identifier.getText().trim();
- SequencePropertyBean propertyBean =
- propertyBeanMgr.retrieve(identifierString,
- Constants.SequenceProperties.TEMP_SEQUENCE_ID);
-
- //TODO
- String acksString = ""; //propertyBean.getAcksString();
- String[] msgNumberStrs = acksString.split(",");
-
- //TODO move this to a util class
- long[] msgNumbers = new long[msgNumberStrs.length];
- for (int i=0; i < msgNumbers.length; i++) {
- msgNumbers[i] = Long.parseLong(msgNumberStrs[i]);
- }
-
- Iterator acks = element.getChildrenWithName(new QName(
- Constants.WSRM.NS_URI_RM, Constants.WSRM.ACK_RANGE));
- while (acks.hasNext()) {
- OMElement ack = (OMElement) acks.next();
-
- OMAttribute lowerAttrib = ack.getAttribute(
- new QName(Constants.WSRM.LOWER));
- long lower = Long.parseLong(lowerAttrib.getAttributeValue());
-
- OMAttribute upperAttrib = ack.getAttribute(
- new QName(Constants.WSRM.UPPER));
- long upper = Long.parseLong(upperAttrib.getAttributeValue());
-
- for (; lower <= upper; lower++) {
- boolean found = false;
- for (int j = 0; j < msgNumbers.length; j++) {
- if (lower == msgNumbers[j]) {
- found = true;
- break;
- }
- }
- if (!found) {
- //TODO throw new InvalidAcknowledgement
- }
- }
- }
-
- Iterator nacks = element.getChildrenWithName(new QName(
- Constants.WSRM.NS_URI_RM, Constants.WSRM.NACK));
-
- while (nacks.hasNext()) {
- OMElement nack = (OMElement) nacks.next();
- long msgNo = Long.parseLong(nack.getText());
-
- boolean found = false;
- for (int j = 0; j < msgNumbers.length; j++) {
- if (msgNo == msgNumbers[j]) {
- found = true;
- break;
- }
- }
- if (!found) {
- //TODO throw new InvalidAcknowledgement
- }
- }
- return null;
- }
-
- /**
- *
- * @param type
- * @param msgCtx
- * @return
- * @throws SandeshaException
- */
- public RMMsgContext getFault(int type, MessageContext msgCtx)
- throws SandeshaException {
-
- FaultData data = new FaultData();
-
- switch (type) {
- case FaultMgr.UNKNOWN_SEQUENCE_TYPE:
- data.code = FaultMgr.UNKNOW_SEQUENCE_CODE;
- data.subcode = FaultMgr.UNKNOW_SEQUENCE_SUBCODE;
- data.reason = FaultMgr.UNKNOW_SEQUENCE_RESON;
- data.msgCtx = msgCtx;
- break;
-
- case FaultMgr.MESSAGE_NUMBER_ROLLOVER_TYPE:
- data.code = FaultMgr.MESSAGE_NUMBER_ROLLOVER_CODE;
- data.subcode = FaultMgr.MESSAGE_NUMBER_ROLLOVER_SUBCODE;
- data.reason = FaultMgr.MESSAGE_NUMBER_ROLLOVER_REASON;
- data.msgCtx = msgCtx;
- break;
-
- case FaultMgr.INVALID_ACKNOWLEDGEMENT_TYPE:
- data.code = FaultMgr.INVALID_ACKNOWLEDGEMENT_CODE;
- data.subcode = FaultMgr.INVALID_ACKNOWLEDGEMENT_SUBCODE;
- data.reason = FaultMgr.INVALID_ACKNOWLEDGEMENT_REASON;
- data.msgCtx = msgCtx;
- break;
- }
-
- data.type = getMessageType(msgCtx);
-
- MessageContext newMsgCtx = SandeshaUtil.shallowCopy(msgCtx);
- newMsgCtx.setServiceGroupContextId(msgCtx.getServiceGroupContextId());
- newMsgCtx.setServiceContext(msgCtx.getServiceContext());
- RMMsgContext newRMMsgCtx = new RMMsgContext(newMsgCtx);
-
- SequenceFault seqFault = new SequenceFault();
- FaultCode faultCode = new FaultCode();
- faultCode.setFaultCode(data.code);
- seqFault.setFaultCode(faultCode);
-
- //TODO
- //newRMMsgCtx.setMessagePart(Constants.MessageParts.SEQUENCE_FAULT, seqFault);
-
- String str = msgCtx.getEnvelope().getNamespace().getName();
-
- if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
- msgCtx.getEnvelope().getNamespace().getName())) {
- doSOAP11Encoding(data, newMsgCtx);
-
- } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
- msgCtx.getEnvelope().getNamespace().getName())) {
- doSOAP12Encoding(data, newMsgCtx);
-
- } else {
- //TODO should I throw an exception ?
- }
-
- return newRMMsgCtx;
- }
-
- /**
- *
- * @param data
- * @param msgCtx
- * @throws SandeshaException
- */
- public void doSOAP11Encoding(FaultData data, MessageContext msgCtx)
- throws SandeshaException {
-
-
- SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(Constants.SOAPVersion.v1_1);
- SOAPEnvelope faultMsgEnvelope = factory.getDefaultFaultEnvelope();
-
- SOAPFault fault;
- SOAPFaultCode faultCode;
- SOAPFaultReason faultReason;
- SOAPFaultText faultText;
-
- switch (data.type) {
- case Constants.MessageTypes.CREATE_SEQ:
-
- /* CreateSequence */
- fault = faultMsgEnvelope.getBody().getFault();
- faultCode = fault.getCode();
- faultCode.getValue().setText(data.subcode);
-
- faultReason = fault.getReason();
- faultReason.getSOAPText().setText(data.reason);
-
- // TODO
- OMNamespace namespace =
- factory.createOMNamespace(
- OMConstants.XMLNS_URI,
- OMConstants.XMLNS_PREFIX);
- faultReason.getSOAPText().addAttribute("lang", "en", namespace);
- break;
-
- default:
-
- /* */
- fault = faultMsgEnvelope.getBody().getFault();
- faultCode = fault.getCode();
- faultCode.getValue().setText(data.code);
-
- faultReason = fault.getReason();
- faultReason.getSOAPText().setText(data.reason);
- break;
- }
-
- try {
- msgCtx.setEnvelope(faultMsgEnvelope);
-
- } catch (AxisFault axisFault) {
- throw new SandeshaException(axisFault.getMessage());
- }
- }
-
- /**
- *
- * @param msgCtx
- * @return
- */
- public void doSOAP12Encoding(FaultData data, MessageContext msgCtx)
- throws SandeshaException{
-
- SOAPFactory factory =
- SOAPAbstractFactory.getSOAPFactory(Constants.SOAPVersion.v1_2);
- SOAPEnvelope envelope = factory.getDefaultFaultEnvelope();
-
- SOAPFault fault = envelope.getBody().getFault();
- SOAPFaultCode faultCode = fault.getCode();
- SOAPFaultValue codeValue = faultCode.getValue();
- codeValue.setText(data.code);
-
- SOAPFaultSubCode faultSubCode = factory.createSOAPFaultSubCode(faultCode);
- SOAPFaultValue subCodeValue = factory.createSOAPFaultValue(faultSubCode);
- subCodeValue.setText(data.subcode);
-
- SOAPFaultReason faultReason = fault.getReason();
- SOAPFaultText faultText = faultReason.getSOAPText();
- faultText.setText(data.reason);
-
- SOAPFaultDetail faultDetail = fault.getDetail();
-
- SOAPEnvelope ienvelope = data.msgCtx.getEnvelope();
-
- switch (data.type) {
- case Constants.MessageTypes.APPLICATION:
-
- /* Sequence */
- OMElement sequence = ienvelope.getHeader().getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM,
- Constants.WSRM.SEQUENCE));
- OMElement sidentifier = sequence.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM,
- Constants.WSRM.IDENTIFIER));
-
- OMNamespace snamespace =
- factory.createOMNamespace(
- Constants.WSRM.NS_URI_RM,
- Constants.WSRM.NS_PREFIX_RM);
- OMElement selement = factory.createOMElement(
- Constants.WSRM.IDENTIFIER, snamespace);
-
- selement.setText(sidentifier.getText());
- faultDetail.addChild(selement);
- break;
-
- case Constants.MessageTypes.ACK:
-
- /* SequenceAcknowledge */
-
- OMElement sequenceAck
- = ienvelope.getHeader().getFirstChildWithName(
- new QName(
- Constants.WSRM.NS_URI_RM,
- Constants.WSRM.SEQUENCE_ACK));
- OMElement aidentifier
- = sequenceAck.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM,
- Constants.WSRM.IDENTIFIER));
- OMNamespace anamespace =
- factory.createOMNamespace(
- Constants.WSRM.NS_URI_RM,
- Constants.WSRM.NS_PREFIX_RM);
- OMElement aelement = factory.createOMElement(
- Constants.WSRM.IDENTIFIER, anamespace);
-
- aelement.setText(aidentifier.getText());
- faultDetail.addChild(aelement);
- break;
-
- default:
-
- /* TODO for other message types */
- break;
-
- }
-
- msgCtx.setProperty(AddressingConstants.WSA_ACTION, WSA_ACTION_FAULT);
-
- try {
- msgCtx.setEnvelope(envelope);
- } catch (AxisFault e) {
- throw new SandeshaException(e.getMessage());
- }
- }
-
-
- public int getMessageType(MessageContext msgCtx) {
-
- SOAPHeader header = msgCtx.getEnvelope().getHeader();
- SOAPBody body = msgCtx.getEnvelope().getBody();
-
- if (header.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE))
- != null) {
- return Constants.MessageTypes.APPLICATION;
-
- } else if (header.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE_ACK))
- != null) {
- return Constants.MessageTypes.ACK;
-
- } else if (body.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.CREATE_SEQUENCE))
- != null) {
- return Constants.MessageTypes.CREATE_SEQ;
-
- } else if (body.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.CREATE_SEQUENCE_RESPONSE))
- != null) {
- return Constants.MessageTypes.CREATE_SEQ_RESPONSE;
-
- } else if (body.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.TERMINATE_SEQUENCE))
- != null) {
- return Constants.MessageTypes.TERMINATE_SEQ;
-
- } else if (header.getFirstChildWithName(
- new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.ACK_REQUESTED))
- != null) {
- //TODO fix this ..
- return Constants.MessageTypes.UNKNOWN;
-
- } else {
- return Constants.MessageTypes.UNKNOWN;
- }
-
-
- }
-
-}
+ private static final String WSA_ACTION_FAULT = "http://schemas.xmlsoap.org/ws/2004/08/addressing/fault";
+
+ public static final int UNKNOWN_SEQUENCE_TYPE = 1;
+
+ public static final int MESSAGE_NUMBER_ROLLOVER_TYPE = 2;
+
+ public static final int INVALID_ACKNOWLEDGEMENT_TYPE = 3;
+
+ public static final String UNKNOW_SEQUENCE_CODE = "Sender";
+
+ public static final String UNKNOW_SEQUENCE_SUBCODE = "wsrm:UnknowSequence";
+
+ public static final String UNKNOW_SEQUENCE_RESON = "The vaule of wsrm:Identifier is not a known Sequence Identifer";
+
+ public static final String MESSAGE_NUMBER_ROLLOVER_CODE = "Sender";
+
+ public static final String MESSAGE_NUMBER_ROLLOVER_SUBCODE = "wsrm:MessageNumberRollover";
+
+ public static final String MESSAGE_NUMBER_ROLLOVER_REASON = "The maximum value of wsrm:MessageNumber has been exceeded.";
+
+ public static final String INVALID_ACKNOWLEDGEMENT_CODE = "Sender";
+
+ public static final String INVALID_ACKNOWLEDGEMENT_SUBCODE = "wsrm:InvalidAcknowledgement";
+
+ public static final String INVALID_ACKNOWLEDGEMENT_REASON = "The SequenceAcknowledgement violates the cumlative acknowledgement";
+
+ protected class FaultData {
+ int type;
+
+ String code;
+
+ String subcode;
+
+ String reason;
+
+ OMElement detail;
+
+ MessageContext msgCtx;
+ }
+
+ public FaultMgr() {
+ }
+
+ /**
+ *
+ * @param msgCtx
+ * @return @throws
+ * SandeshaException
+ */
+ public RMMsgContext check(MessageContext msgCtx) throws SandeshaException {
+ int msgType = getMessageType(msgCtx);
+
+ switch (msgType) {
+
+ case Constants.MessageTypes.APPLICATION:
+
+ /* Sequence */
+ return checkSequenceMsg(msgCtx);
+
+ case Constants.MessageTypes.ACK:
+
+ /* SequenceAcknowledgement */
+ return checkSequenceAcknowledgementMsg(msgCtx);
+
+ default:
+
+ /* TODO check for other message types */
+ return null;
+ }
+ }
+
+ /**
+ * Check whether a Sequence message (a) belongs to a unknown sequence
+ * (generates an UnknownSequence fault) (b) message number exceeds a
+ * predifined limit ( genenrates a Message Number Rollover fault)
+ *
+ * @param msgCtx
+ * @return @throws
+ * SandeshaException
+ */
+ public RMMsgContext checkSequenceMsg(MessageContext msgCtx)
+ throws SandeshaException {
+
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(msgCtx.getSystemContext());
+ NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
+ SOAPEnvelope envelope = msgCtx.getEnvelope();
+
+ OMElement element = envelope.getHeader().getFirstChildWithName(
+ new QName(Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE));
+ OMElement identifier = element.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.IDENTIFIER));
+
+ String identifierString = identifier.getText().trim();
+
+ if (mgr.retrieve(identifierString) == null) {
+
+ // should throw an UnknownSequence fault
+ return getFault(FaultMgr.UNKNOWN_SEQUENCE_TYPE, msgCtx);
+ }
+
+ OMElement msgNumber = element.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.MSG_NUMBER));
+
+ BigInteger bigInteger = new BigInteger(msgNumber.getText().trim());
+
+ // throws new MessageNumberRollover fault
+ if (bigInteger.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1) {
+ return getFault(FaultMgr.MESSAGE_NUMBER_ROLLOVER_TYPE, msgCtx);
+ }
+
+ // Phew !! no faults ..
+ return null;
+ }
+
+ /**
+ *
+ * @param msgCtx
+ * @return @throws
+ * SandeshaException
+ */
+ public RMMsgContext checkSequenceAcknowledgementMsg(MessageContext msgCtx)
+ throws SandeshaException {
+
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(msgCtx.getSystemContext());
+
+ NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
+ StorageMapBeanMgr smgr = storageManager.getStorageMapBeanMgr();
+ SequencePropertyBeanMgr propertyBeanMgr = storageManager
+ .getSequencePropretyBeanMgr();
+
+ SOAPEnvelope envelope = msgCtx.getEnvelope();
+ // this is a SequenceAcknowledgement message
+ OMElement element = envelope.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE_ACK));
+ OMElement identifier = element.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.IDENTIFIER));
+
+ if (mgr.retrieve(identifier.getText()) == null) {
+ //throw UnknownSequenceFault
+ return getFault(FaultMgr.UNKNOWN_SEQUENCE_TYPE, msgCtx);
+ }
+
+ String identifierString = identifier.getText().trim();
+ SequencePropertyBean propertyBean = propertyBeanMgr
+ .retrieve(identifierString,
+ Constants.SequenceProperties.TEMP_SEQUENCE_ID);
+
+ //TODO
+ String acksString = ""; //propertyBean.getAcksString();
+ String[] msgNumberStrs = acksString.split(",");
+
+ //TODO move this to a util class
+ long[] msgNumbers = new long[msgNumberStrs.length];
+ for (int i = 0; i < msgNumbers.length; i++) {
+ msgNumbers[i] = Long.parseLong(msgNumberStrs[i]);
+ }
+
+ Iterator acks = element.getChildrenWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.ACK_RANGE));
+ while (acks.hasNext()) {
+ OMElement ack = (OMElement) acks.next();
+
+ OMAttribute lowerAttrib = ack.getAttribute(new QName(
+ Constants.WSRM.LOWER));
+ long lower = Long.parseLong(lowerAttrib.getAttributeValue());
+
+ OMAttribute upperAttrib = ack.getAttribute(new QName(
+ Constants.WSRM.UPPER));
+ long upper = Long.parseLong(upperAttrib.getAttributeValue());
+
+ for (; lower <= upper; lower++) {
+ boolean found = false;
+ for (int j = 0; j < msgNumbers.length; j++) {
+ if (lower == msgNumbers[j]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ //TODO throw new InvalidAcknowledgement
+ }
+ }
+ }
+
+ Iterator nacks = element.getChildrenWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.NACK));
+
+ while (nacks.hasNext()) {
+ OMElement nack = (OMElement) nacks.next();
+ long msgNo = Long.parseLong(nack.getText());
+
+ boolean found = false;
+ for (int j = 0; j < msgNumbers.length; j++) {
+ if (msgNo == msgNumbers[j]) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ //TODO throw new InvalidAcknowledgement
+ }
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param type
+ * @param msgCtx
+ * @return @throws
+ * SandeshaException
+ */
+ public RMMsgContext getFault(int type, MessageContext msgCtx)
+ throws SandeshaException {
+
+ FaultData data = new FaultData();
+
+ switch (type) {
+ case FaultMgr.UNKNOWN_SEQUENCE_TYPE:
+ data.code = FaultMgr.UNKNOW_SEQUENCE_CODE;
+ data.subcode = FaultMgr.UNKNOW_SEQUENCE_SUBCODE;
+ data.reason = FaultMgr.UNKNOW_SEQUENCE_RESON;
+ data.msgCtx = msgCtx;
+ break;
+
+ case FaultMgr.MESSAGE_NUMBER_ROLLOVER_TYPE:
+ data.code = FaultMgr.MESSAGE_NUMBER_ROLLOVER_CODE;
+ data.subcode = FaultMgr.MESSAGE_NUMBER_ROLLOVER_SUBCODE;
+ data.reason = FaultMgr.MESSAGE_NUMBER_ROLLOVER_REASON;
+ data.msgCtx = msgCtx;
+ break;
+
+ case FaultMgr.INVALID_ACKNOWLEDGEMENT_TYPE:
+ data.code = FaultMgr.INVALID_ACKNOWLEDGEMENT_CODE;
+ data.subcode = FaultMgr.INVALID_ACKNOWLEDGEMENT_SUBCODE;
+ data.reason = FaultMgr.INVALID_ACKNOWLEDGEMENT_REASON;
+ data.msgCtx = msgCtx;
+ break;
+ }
+
+ data.type = getMessageType(msgCtx);
+
+ MessageContext newMsgCtx = SandeshaUtil.shallowCopy(msgCtx);
+ newMsgCtx.setServiceGroupContextId(msgCtx.getServiceGroupContextId());
+ newMsgCtx.setServiceContext(msgCtx.getServiceContext());
+ RMMsgContext newRMMsgCtx = new RMMsgContext(newMsgCtx);
+
+ SequenceFault seqFault = new SequenceFault();
+ FaultCode faultCode = new FaultCode();
+ faultCode.setFaultCode(data.code);
+ seqFault.setFaultCode(faultCode);
+
+ //TODO
+ //newRMMsgCtx.setMessagePart(Constants.MessageParts.SEQUENCE_FAULT,
+ // seqFault);
+
+ String str = msgCtx.getEnvelope().getNamespace().getName();
+
+ if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(msgCtx
+ .getEnvelope().getNamespace().getName())) {
+ doSOAP11Encoding(data, newMsgCtx);
+
+ } else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(msgCtx
+ .getEnvelope().getNamespace().getName())) {
+ doSOAP12Encoding(data, newMsgCtx);
+
+ } else {
+ //TODO should I throw an exception ?
+ }
+
+ return newRMMsgCtx;
+ }
+
+ /**
+ *
+ * @param data
+ * @param msgCtx
+ * @throws SandeshaException
+ */
+ public void doSOAP11Encoding(FaultData data, MessageContext msgCtx)
+ throws SandeshaException {
+
+ SOAPFactory factory = SOAPAbstractFactory
+ .getSOAPFactory(Constants.SOAPVersion.v1_1);
+ SOAPEnvelope faultMsgEnvelope = factory.getDefaultFaultEnvelope();
+
+ SOAPFault fault;
+ SOAPFaultCode faultCode;
+ SOAPFaultReason faultReason;
+ SOAPFaultText faultText;
+
+ switch (data.type) {
+ case Constants.MessageTypes.CREATE_SEQ:
+
+ /* CreateSequence */
+ fault = faultMsgEnvelope.getBody().getFault();
+ faultCode = fault.getCode();
+ faultCode.getValue().setText(data.subcode);
+
+ faultReason = fault.getReason();
+ faultReason.getSOAPText().setText(data.reason);
+
+ // TODO
+ OMNamespace namespace = factory.createOMNamespace(
+ OMConstants.XMLNS_URI, OMConstants.XMLNS_PREFIX);
+ faultReason.getSOAPText().addAttribute("lang", "en", namespace);
+ break;
+
+ default:
+
+ /* */
+ fault = faultMsgEnvelope.getBody().getFault();
+ faultCode = fault.getCode();
+ faultCode.getValue().setText(data.code);
+
+ faultReason = fault.getReason();
+ faultReason.getSOAPText().setText(data.reason);
+ break;
+ }
+
+ try {
+ msgCtx.setEnvelope(faultMsgEnvelope);
+
+ } catch (AxisFault axisFault) {
+ throw new SandeshaException(axisFault.getMessage());
+ }
+ }
+
+ /**
+ *
+ * @param msgCtx
+ * @return
+ */
+ public void doSOAP12Encoding(FaultData data, MessageContext msgCtx)
+ throws SandeshaException {
+
+ SOAPFactory factory = SOAPAbstractFactory
+ .getSOAPFactory(Constants.SOAPVersion.v1_2);
+ SOAPEnvelope envelope = factory.getDefaultFaultEnvelope();
+
+ SOAPFault fault = envelope.getBody().getFault();
+ SOAPFaultCode faultCode = fault.getCode();
+ SOAPFaultValue codeValue = faultCode.getValue();
+ codeValue.setText(data.code);
+
+ SOAPFaultSubCode faultSubCode = factory
+ .createSOAPFaultSubCode(faultCode);
+ SOAPFaultValue subCodeValue = factory
+ .createSOAPFaultValue(faultSubCode);
+ subCodeValue.setText(data.subcode);
+
+ SOAPFaultReason faultReason = fault.getReason();
+ SOAPFaultText faultText = faultReason.getSOAPText();
+ faultText.setText(data.reason);
+
+ SOAPFaultDetail faultDetail = fault.getDetail();
+
+ SOAPEnvelope ienvelope = data.msgCtx.getEnvelope();
+
+ switch (data.type) {
+ case Constants.MessageTypes.APPLICATION:
+
+ /* Sequence */
+ OMElement sequence = ienvelope.getHeader()
+ .getFirstChildWithName(
+ new QName(Constants.WSRM.NS_URI_RM,
+ Constants.WSRM.SEQUENCE));
+ OMElement sidentifier = sequence.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.IDENTIFIER));
+
+ OMNamespace snamespace = factory.createOMNamespace(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ OMElement selement = factory.createOMElement(
+ Constants.WSRM.IDENTIFIER, snamespace);
+
+ selement.setText(sidentifier.getText());
+ faultDetail.addChild(selement);
+ break;
+
+ case Constants.MessageTypes.ACK:
+
+ /* SequenceAcknowledge */
+
+ OMElement sequenceAck = ienvelope.getHeader()
+ .getFirstChildWithName(
+ new QName(Constants.WSRM.NS_URI_RM,
+ Constants.WSRM.SEQUENCE_ACK));
+ OMElement aidentifier = sequenceAck
+ .getFirstChildWithName(new QName(Constants.WSRM.NS_URI_RM,
+ Constants.WSRM.IDENTIFIER));
+ OMNamespace anamespace = factory.createOMNamespace(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.NS_PREFIX_RM);
+ OMElement aelement = factory.createOMElement(
+ Constants.WSRM.IDENTIFIER, anamespace);
+
+ aelement.setText(aidentifier.getText());
+ faultDetail.addChild(aelement);
+ break;
+
+ default:
+
+ /* TODO for other message types */
+ break;
+
+ }
+
+ msgCtx.setProperty(AddressingConstants.WSA_ACTION, WSA_ACTION_FAULT);
+
+ try {
+ msgCtx.setEnvelope(envelope);
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+ }
+
+ public int getMessageType(MessageContext msgCtx) {
+
+ SOAPHeader header = msgCtx.getEnvelope().getHeader();
+ SOAPBody body = msgCtx.getEnvelope().getBody();
+
+ if (header.getFirstChildWithName(new QName(Constants.WSRM.NS_URI_RM,
+ Constants.WSRM.SEQUENCE)) != null) {
+ return Constants.MessageTypes.APPLICATION;
+
+ } else if (header.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.SEQUENCE_ACK)) != null) {
+ return Constants.MessageTypes.ACK;
+
+ } else if (body.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.CREATE_SEQUENCE)) != null) {
+ return Constants.MessageTypes.CREATE_SEQ;
+
+ } else if (body.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM,
+ Constants.WSRM.CREATE_SEQUENCE_RESPONSE)) != null) {
+ return Constants.MessageTypes.CREATE_SEQ_RESPONSE;
+
+ } else if (body.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.TERMINATE_SEQUENCE)) != null) {
+ return Constants.MessageTypes.TERMINATE_SEQ;
+
+ } else if (header.getFirstChildWithName(new QName(
+ Constants.WSRM.NS_URI_RM, Constants.WSRM.ACK_REQUESTED)) != null) {
+ //TODO fix this ..
+ return Constants.MessageTypes.UNKNOWN;
+
+ } else {
+ return Constants.MessageTypes.UNKNOWN;
+ }
+
+ }
+
+}
\ No newline at end of file
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgInitializer.java Wed Nov 2 17:27:17 2005
@@ -1,41 +1,28 @@
/*
- * 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.
- *
+ * 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 javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.axis2.addressing.om.AddressingHeaders;
import org.apache.axis2.context.MessageContext;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.MessageParts;
-import org.apache.sandesha2.Constants.MessageTypes;
-import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.wsrm.RMElements;
-/**
- * @author Chamikara
- * @author Sanka
- * @author Jaliya
- */
-
public class MsgInitializer {
public static RMMsgContext initializeMessage(MessageContext ctx)
@@ -78,7 +65,7 @@
if (elements.getAckRequested() != null)
rmMsgContext.setMessagePart(Constants.MessageParts.ACK_REQUEST,
elements.getAckRequested());
-
+
}
private static boolean validateMessage(RMMsgContext rmMsgCtx)
@@ -97,7 +84,8 @@
rmMsgCtx.setMessageType(Constants.MessageTypes.TERMINATE_SEQ);
else if (rmMsgCtx.getMessagePart(Constants.MessageParts.SEQUENCE) != null)
rmMsgCtx.setMessageType(Constants.MessageTypes.APPLICATION);
- else if (rmMsgCtx.getMessagePart(Constants.MessageParts.SEQ_ACKNOWLEDGEMENT)!=null)
+ else if (rmMsgCtx
+ .getMessagePart(Constants.MessageParts.SEQ_ACKNOWLEDGEMENT) != null)
rmMsgCtx.setMessageType(Constants.MessageTypes.ACK);
else
rmMsgCtx.setMessageType(Constants.MessageTypes.UNKNOWN);
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgValidator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgValidator.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgValidator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/MsgValidator.java Wed Nov 2 17:27:17 2005
@@ -18,7 +18,6 @@
package org.apache.sandesha2.util;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
import org.apache.sandesha2.RMMsgContext;
/**
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/RMMsgCreator.java Wed Nov 2 17:27:17 2005
@@ -1,18 +1,18 @@
/*
- * 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.
- *
+ * 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;
@@ -20,14 +20,9 @@
import java.util.ArrayList;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.MessageInformationHeaders;
-import org.apache.axis2.addressing.om.AddressingHeaders;
-import org.apache.axis2.clientapi.Call;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.context.OperationContext;
@@ -38,55 +33,32 @@
import org.apache.axis2.description.AxisService;
import org.apache.axis2.description.AxisServiceGroup;
import org.apache.axis2.engine.AxisConfiguration;
-import org.apache.axis2.engine.AxisConfigurationImpl;
-import org.apache.axis2.engine.Phase;
-import org.apache.axis2.om.OMAbstractFactory;
-import org.apache.axis2.om.impl.MIMEOutputUtils;
import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.wsdl.builder.wsdl4j.WSDL11MEPFinder;
-import org.apache.log4j.spi.Configurator;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.MessageParts;
-import org.apache.sandesha2.Constants.SOAPVersion;
-import org.apache.sandesha2.Constants.SequenceProperties;
-import org.apache.sandesha2.Constants.WSA;
-import org.apache.sandesha2.Constants.WSRM;
-import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
-import org.apache.sandesha2.storage.inmemory.InMemorySequencePropertyBeanMgr;
import org.apache.sandesha2.wsrm.Accept;
-import org.apache.sandesha2.wsrm.AckRequested;
import org.apache.sandesha2.wsrm.AcknowledgementRange;
import org.apache.sandesha2.wsrm.AcksTo;
import org.apache.sandesha2.wsrm.Address;
import org.apache.sandesha2.wsrm.CreateSequence;
import org.apache.sandesha2.wsrm.CreateSequenceResponse;
import org.apache.sandesha2.wsrm.IOMRMElement;
-import org.apache.sandesha2.wsrm.IOMRMPart;
import org.apache.sandesha2.wsrm.Identifier;
import org.apache.sandesha2.wsrm.Sequence;
import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
import org.apache.sandesha2.wsrm.SequenceOffer;
import org.apache.sandesha2.wsrm.TerminateSequence;
-import org.apache.wsdl.WSDLConstants;
-
-
-/**
- * @author Chamikara
- * @author Sanka
- * @author Jaliya
- */
public class RMMsgCreator {
- public static RMMsgContext createCreateSeqMsg(RMMsgContext applicationRMMsg, String tempSequenceId, String acksTo)
+ public static RMMsgContext createCreateSeqMsg(
+ RMMsgContext applicationRMMsg, String tempSequenceId, String acksTo)
throws SandeshaException {
-
+
MessageContext applicationMsgContext = applicationRMMsg
.getMessageContext();
if (applicationMsgContext == null)
@@ -95,8 +67,10 @@
if (context == null)
throw new SandeshaException("Configuration Context is null");
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
- SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(context);
+ SequencePropertyBeanMgr seqPropMgr = storageManager
+ .getSequencePropretyBeanMgr();
MessageContext createSeqmsgContext;
try {
//creating by copying common contents. (this will not set contexts
@@ -119,15 +93,23 @@
String createSeqMsgId = SandeshaUtil.getUUID();
try {
- AxisOperation appMsgOperationDesc = applicationMsgContext.getAxisOperation();
- AxisOperation createSeqOperationDesc = AxisOperationFactory.getOperetionDescription(AxisOperationFactory.MEP_URI_OUT_IN);
- if (appMsgOperationDesc!=null) {
- createSeqOperationDesc.setPhasesOutFlow(appMsgOperationDesc.getPhasesOutFlow());
- createSeqOperationDesc.setPhasesOutFaultFlow(appMsgOperationDesc.getPhasesOutFaultFlow());
- createSeqOperationDesc.setPhasesInFaultFlow(appMsgOperationDesc.getPhasesInFaultFlow());
- createSeqOperationDesc.setRemainingPhasesInFlow(appMsgOperationDesc.getRemainingPhasesInFlow());
+ AxisOperation appMsgOperationDesc = applicationMsgContext
+ .getAxisOperation();
+ AxisOperation createSeqOperationDesc = AxisOperationFactory
+ .getOperetionDescription(AxisOperationFactory.MEP_URI_OUT_IN);
+ if (appMsgOperationDesc != null) {
+ createSeqOperationDesc.setPhasesOutFlow(appMsgOperationDesc
+ .getPhasesOutFlow());
+ createSeqOperationDesc
+ .setPhasesOutFaultFlow(appMsgOperationDesc
+ .getPhasesOutFaultFlow());
+ createSeqOperationDesc.setPhasesInFaultFlow(appMsgOperationDesc
+ .getPhasesInFaultFlow());
+ createSeqOperationDesc
+ .setRemainingPhasesInFlow(appMsgOperationDesc
+ .getRemainingPhasesInFlow());
}
-
+
createSeqmsgContext.setAxisOperation(createSeqOperationDesc);
//TODO set a suitable ope. description
OperationContext createSeqOpContext = new OperationContext(
@@ -135,16 +117,17 @@
createSeqmsgContext.setOperationContext(createSeqOpContext);
createSeqOpContext.addMessageContext(createSeqmsgContext);
//registering opearion context
- context.registerOperationContext(createSeqMsgId,createSeqOpContext);
+ context
+ .registerOperationContext(createSeqMsgId,
+ createSeqOpContext);
-
//Setting a new SOAP Envelop.
SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
createSeqmsgContext.setEnvelope(envelope);
-// createSeqOpContext.addMessageContext(createSeqmsgContext);
-// createSeqmsgContext.setOperationContext(createSeqOpContext);
+ // createSeqOpContext.addMessageContext(createSeqmsgContext);
+ // createSeqmsgContext.setOperationContext(createSeqOpContext);
} catch (AxisFault e2) {
throw new SandeshaException(e2.getMessage());
}
@@ -156,55 +139,55 @@
CreateSequence createSequencePart = new CreateSequence();
-
//Adding sequence offer - if present
- String offeredSequence = (String) context.getProperty(Constants.OFFERED_SEQUENCE_ID);
- if (offeredSequence!=null && !"".equals(offeredSequence))
- {
- SequenceOffer offerPart = new SequenceOffer ();
- Identifier identifier = new Identifier ();
+ String offeredSequence = (String) context
+ .getProperty(Constants.OFFERED_SEQUENCE_ID);
+ if (offeredSequence != null && !"".equals(offeredSequence)) {
+ SequenceOffer offerPart = new SequenceOffer();
+ Identifier identifier = new Identifier();
identifier.setIndentifer(offeredSequence);
offerPart.setIdentifier(identifier);
createSequencePart.setSequenceOffer(offerPart);
}
-
+
//TODO decide - where to send create seq. Acksto or replyTo
- SequencePropertyBean replyToBean = seqPropMgr.retrieve(tempSequenceId, Constants.SequenceProperties.REPLY_TO_EPR);
- SequencePropertyBean toBean = seqPropMgr.retrieve(tempSequenceId,Constants.SequenceProperties.TO_EPR);
+ SequencePropertyBean replyToBean = seqPropMgr.retrieve(tempSequenceId,
+ Constants.SequenceProperties.REPLY_TO_EPR);
+ SequencePropertyBean toBean = seqPropMgr.retrieve(tempSequenceId,
+ Constants.SequenceProperties.TO_EPR);
+
+ if (toBean == null || toBean.getValue() == null)
+ throw new SandeshaException("To EPR is not set.");
- if (toBean==null || toBean.getValue()==null)
- throw new SandeshaException ("To EPR is not set.");
-
EndpointReference toEPR = (EndpointReference) toBean.getValue();
EndpointReference replyToEPR = null;
EndpointReference acksToEPR = null;
-
+
//AcksTo value is replyto value (if set). Otherwise anonymous.
-// if (replyToBean==null || replyToBean.getValue()==null){
-// if (acksTo==null)
-// acksToEPR = new EndpointReference (Constants.WSA.NS_URI_ANONYMOUS);
-// }else {
-// acksToEPR = (EndpointReference) replyToBean.getValue();
-// }
-
- if (acksTo==null || "".equals(acksTo))
+ // if (replyToBean==null || replyToBean.getValue()==null){
+ // if (acksTo==null)
+ // acksToEPR = new EndpointReference (Constants.WSA.NS_URI_ANONYMOUS);
+ // }else {
+ // acksToEPR = (EndpointReference) replyToBean.getValue();
+ // }
+
+ if (acksTo == null || "".equals(acksTo))
acksTo = Constants.WSA.NS_URI_ANONYMOUS;
-
- acksToEPR = new EndpointReference (acksTo);
-
- if (replyToBean!=null && replyToBean.getValue()!=null)
+
+ acksToEPR = new EndpointReference(acksTo);
+
+ if (replyToBean != null && replyToBean.getValue() != null)
replyToEPR = (EndpointReference) replyToBean.getValue();
createSeqRMMsg.setTo(toEPR);
-
+
//ReplyTo will be set only if not null.
- if(replyToEPR!=null)
+ if (replyToEPR != null)
createSeqRMMsg.setReplyTo(replyToEPR);
-
-
+
//FIXME - Give user a seperate way to set acksTo (client side)
createSequencePart.setAcksTo(new AcksTo(new Address(acksToEPR)));
-
+
createSeqRMMsg.setMessagePart(Constants.MessageParts.CREATE_SEQ,
createSequencePart);
@@ -215,7 +198,8 @@
}
createSeqRMMsg.setAction(Constants.WSRM.ACTION_CREATE_SEQ);
- createSeqRMMsg.setSOAPAction("\"" + Constants.WSRM.ACTION_CREATE_SEQ + "\"");
+ createSeqRMMsg.setSOAPAction("\"" + Constants.WSRM.ACTION_CREATE_SEQ
+ + "\"");
createSeqRMMsg.setMessageId(createSeqMsgId);
MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
@@ -229,73 +213,87 @@
return createSeqRMMsg;
}
-
- public static RMMsgContext createTerminateSequenceMessage (RMMsgContext referenceRMMessage, String sequenceId) throws SandeshaException {
- MessageContext referenceMessage = referenceRMMessage.getMessageContext();
- if (referenceMessage==null)
- throw new SandeshaException ("MessageContext is null");
-
- RMMsgContext terminateRMMessage = SandeshaUtil.shallowCopy(referenceRMMessage);
- MessageContext terminateMessage = terminateRMMessage.getMessageContext();
- if (terminateMessage==null)
- throw new SandeshaException ("MessageContext is null");
-
- MessageInformationHeaders newMessageInfoHeaders = new MessageInformationHeaders ();
+
+ public static RMMsgContext createTerminateSequenceMessage(
+ RMMsgContext referenceRMMessage, String sequenceId)
+ throws SandeshaException {
+ MessageContext referenceMessage = referenceRMMessage
+ .getMessageContext();
+ if (referenceMessage == null)
+ throw new SandeshaException("MessageContext is null");
+
+ RMMsgContext terminateRMMessage = SandeshaUtil
+ .shallowCopy(referenceRMMessage);
+ MessageContext terminateMessage = terminateRMMessage
+ .getMessageContext();
+ if (terminateMessage == null)
+ throw new SandeshaException("MessageContext is null");
+
+ MessageInformationHeaders newMessageInfoHeaders = new MessageInformationHeaders();
terminateMessage.setMessageInformationHeaders(newMessageInfoHeaders);
terminateMessage.setMessageID(SandeshaUtil.getUUID());
-
-
+
ConfigurationContext configCtx = referenceMessage.getSystemContext();
- if (configCtx==null)
- throw new SandeshaException ("Configuration Context is null");
-
+ if (configCtx == null)
+ throw new SandeshaException("Configuration Context is null");
+
AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
- AxisServiceGroup serviceGroup = new AxisServiceGroup (axisConfig);
- AxisService service = new AxisService (new QName ("RMClientService")); // This is a dummy service.
- ServiceGroupContext serviceGroupContext = new ServiceGroupContext (configCtx,serviceGroup);
- ServiceContext serviceContext = new ServiceContext (service,serviceGroupContext);
-
+ AxisServiceGroup serviceGroup = new AxisServiceGroup(axisConfig);
+ AxisService service = new AxisService(new QName("RMClientService")); // This
+ // is a
+ // dummy
+ // service.
+ ServiceGroupContext serviceGroupContext = new ServiceGroupContext(
+ configCtx, serviceGroup);
+ ServiceContext serviceContext = new ServiceContext(service,
+ serviceGroupContext);
+
terminateMessage.setAxisServiceGroup(serviceGroup);
terminateMessage.setServiceGroupContext(serviceGroupContext);
terminateMessage.setAxisService(service);
terminateMessage.setServiceContext(serviceContext);
-
+
try {
- AxisOperation terminateOperaiton = AxisOperationFactory.getOperetionDescription(AxisOperationFactory.MEP_URI_IN_ONLY);
- AxisOperation referenceMsgOperation = referenceMessage.getAxisOperation();
- if (referenceMsgOperation!=null) {
+ AxisOperation terminateOperaiton = AxisOperationFactory
+ .getOperetionDescription(AxisOperationFactory.MEP_URI_IN_ONLY);
+ AxisOperation referenceMsgOperation = referenceMessage
+ .getAxisOperation();
+ if (referenceMsgOperation != null) {
ArrayList outPhases = referenceMsgOperation.getPhasesOutFlow();
- if (outPhases!=null) {
+ if (outPhases != null) {
terminateOperaiton.setPhasesOutFlow(outPhases);
terminateOperaiton.setPhasesOutFaultFlow(outPhases);
}
}
-
- OperationContext terminateOpContext = new OperationContext (terminateOperaiton);
+
+ OperationContext terminateOpContext = new OperationContext(
+ terminateOperaiton);
terminateMessage.setAxisOperation(terminateOperaiton);
terminateMessage.setOperationContext(terminateOpContext);
terminateOpContext.addMessageContext(terminateMessage);
terminateMessage.setOperationContext(terminateOpContext);
-
+
} catch (AxisFault e) {
- throw new SandeshaException (e.getMessage());
+ throw new SandeshaException(e.getMessage());
}
-
- SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
+
+ SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
+ Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
terminateRMMessage.setSOAPEnvelop(envelope);
-
- TerminateSequence terminateSequencePart = new TerminateSequence ();
- Identifier identifier = new Identifier ();
+
+ TerminateSequence terminateSequencePart = new TerminateSequence();
+ Identifier identifier = new Identifier();
identifier.setIndentifer(sequenceId);
terminateSequencePart.setIdentifier(identifier);
- terminateRMMessage.setMessagePart(Constants.MessageParts.TERMINATE_SEQ,terminateSequencePart);
-
+ terminateRMMessage.setMessagePart(Constants.MessageParts.TERMINATE_SEQ,
+ terminateSequencePart);
+
return terminateRMMessage;
}
public static RMMsgContext createCreateSeqResponseMsg(
- RMMsgContext createSeqMessage, MessageContext outMessage, String newSequenceID)
- throws AxisFault {
+ RMMsgContext createSeqMessage, MessageContext outMessage,
+ String newSequenceID) throws AxisFault {
IOMRMElement messagePart = createSeqMessage
.getMessagePart(Constants.MessageParts.CREATE_SEQ);
@@ -309,12 +307,12 @@
response.setIdentifier(identifier);
SequenceOffer offer = cs.getSequenceOffer();
- if (offer!=null) {
+ if (offer != null) {
String outSequenceId = offer.getIdentifer().getIdentifier();
-
+
//TODO do a better validation for the offered out sequence id.
- if (outSequenceId!=null && !"".equals(outSequenceId)) {
-
+ if (outSequenceId != null && !"".equals(outSequenceId)) {
+
Accept accept = new Accept();
EndpointReference acksToEPR = createSeqMessage.getTo();
AcksTo acksTo = new AcksTo();
@@ -322,19 +320,17 @@
address.setEpr(acksToEPR);
acksTo.setAddress(address);
accept.setAcksTo(acksTo);
- response.setAccept(accept);
+ response.setAccept(accept);
}
-
-
- }
+ }
SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
Constants.SOAPVersion.DEFAULT).getDefaultEnvelope();
response.toOMElement(envelope.getBody());
outMessage.setWSAAction(Constants.WSRM.NS_URI_CREATE_SEQ_RESPONSE);
outMessage.setSoapAction(Constants.WSRM.NS_URI_CREATE_SEQ_RESPONSE);
-
+
String newMessageId = SandeshaUtil.getUUID();
outMessage.setMessageID(newMessageId);
@@ -368,13 +364,15 @@
ConfigurationContext ctx = applicationMsg.getMessageContext()
.getSystemContext();
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(ctx);
- SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropretyBeanMgr();
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(ctx);
+ SequencePropertyBeanMgr seqPropMgr = storageManager
+ .getSequencePropretyBeanMgr();
SequencePropertyBean seqBean = seqPropMgr.retrieve(sequenceId,
Constants.SequenceProperties.RECEIVED_MESSAGES);
String msgNoList = (String) seqBean.getValue();
-
+
AcknowledgementRange[] ackRangeArr = SandeshaUtil
.getAckRangeArray(msgNoList);
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SOAPAbstractFactory.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SOAPAbstractFactory.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SOAPAbstractFactory.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SOAPAbstractFactory.java Wed Nov 2 17:27:17 2005
@@ -20,7 +20,6 @@
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.soap.SOAPFactory;
import org.apache.sandesha2.Constants;
-import org.apache.sandesha2.Constants.SOAPVersion;
/**
* @author Chamikara
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SandeshaUtil.java Wed Nov 2 17:27:17 2005
@@ -16,33 +16,21 @@
*/
package org.apache.sandesha2.util;
-import java.awt.datatransfer.StringSelection;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
-import java.util.StringTokenizer;
-
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
-
import org.apache.axis2.AxisFault;
-import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.MessageInformationHeaders;
-import org.apache.axis2.addressing.miheaders.RelatesTo;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.engine.AxisEngine;
import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.om.OMElement;
-import org.apache.axis2.om.impl.MIMEOutputUtils;
import org.apache.axis2.om.impl.llom.builder.StAXBuilder;
import org.apache.axis2.om.impl.llom.builder.StAXOMBuilder;
import org.apache.axis2.soap.SOAPEnvelope;
@@ -56,7 +44,6 @@
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.workers.InOrderInvoker;
import org.apache.sandesha2.workers.Sender;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/util/SequenceManager.java Wed Nov 2 17:27:17 2005
@@ -5,32 +5,18 @@
* Window - Preferences - Java - Code Style - Code Templates
*/
package org.apache.sandesha2.util;
-
-import java.util.ArrayList;
-
-import javax.naming.Context;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.AbstractContext;
-import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.ClientProperties;
-import org.apache.sandesha2.Constants.MessageParts;
-import org.apache.sandesha2.Constants.SequenceProperties;
-import org.apache.sandesha2.Constants.WSA;
-import org.apache.sandesha2.handlers.SandeshaInHandler;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beans.NextMsgBean;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
-import org.apache.sandesha2.storage.inmemory.InMemoryNextMsgBeanMgr;
-import org.apache.sandesha2.storage.inmemory.InMemorySequencePropertyBeanMgr;
-import org.apache.sandesha2.wsrm.AcksTo;
import org.apache.sandesha2.wsrm.CreateSequence;
/**
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/workers/InOrderInvoker.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/InOrderInvoker.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/InOrderInvoker.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/InOrderInvoker.java Wed Nov 2 17:27:17 2005
@@ -1,28 +1,24 @@
/*
- * 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.
- *
+ * 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.workers;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
import org.apache.axis2.AxisFault;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
@@ -30,8 +26,6 @@
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.MessageParts;
-import org.apache.sandesha2.Constants.SequenceProperties;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
@@ -39,21 +33,10 @@
import org.apache.sandesha2.storage.beans.NextMsgBean;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
import org.apache.sandesha2.storage.beans.StorageMapBean;
-import org.apache.sandesha2.storage.inmemory.InMemoryNextMsgBeanMgr;
-import org.apache.sandesha2.storage.inmemory.InMemorySequencePropertyBeanMgr;
-import org.apache.sandesha2.storage.inmemory.InMemoryStorageMapBeanMgr;
import org.apache.sandesha2.util.MsgInitializer;
import org.apache.sandesha2.util.SandeshaUtil;
import org.apache.sandesha2.wsrm.Sequence;
-import org.ietf.jgss.MessageProp;
-
-/**
- * @author Chamikara
- * @author Sanka
- * @author Jaliya
- */
-//TODO rename to Invoker
public class InOrderInvoker extends Thread {
boolean invokerStarted = false;
@@ -71,12 +54,12 @@
this.context = context;
}
- public void start (ConfigurationContext context) {
+ public void start(ConfigurationContext context) {
invokerStarted = true;
this.context = context;
super.start();
}
-
+
public void run() {
while (isInvokerStarted()) {
@@ -88,74 +71,95 @@
ex.printStackTrace();
System.out.println("End printing Interrupt...");
}
-
try {
-
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context);
+
+ StorageManager storageManager = SandeshaUtil
+ .getSandeshaStorageManager(context);
NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
- StorageMapBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
-
- SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropretyBeanMgr();
+ StorageMapBeanMgr storageMapMgr = storageManager
+ .getStorageMapBeanMgr();
+
+ SequencePropertyBeanMgr sequencePropMgr = storageManager
+ .getSequencePropretyBeanMgr();
-
-
//Getting the incomingSequenceIdList
- SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) sequencePropMgr.retrieve(Constants.SequenceProperties.ALL_SEQUENCES,Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
- if (sequencePropertyBean==null)
+ SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) sequencePropMgr
+ .retrieve(
+ Constants.SequenceProperties.ALL_SEQUENCES,
+ Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
+ if (sequencePropertyBean == null)
continue;
-
-
- ArrayList seqPropList = (ArrayList) sequencePropertyBean.getValue();
+
+ ArrayList seqPropList = (ArrayList) sequencePropertyBean
+ .getValue();
Iterator seqPropIt = seqPropList.iterator();
-
- while (seqPropIt.hasNext()){
-
+
+ while (seqPropIt.hasNext()) {
+
String sequenceId = (String) seqPropIt.next();
-
+
NextMsgBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
- if (nextMsgBean==null)
- throw new SandeshaException ("Next message not set correctly");
-
+ if (nextMsgBean == null)
+ throw new SandeshaException(
+ "Next message not set correctly");
+
long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
- if (nextMsgno<=0)
- throw new SandeshaException ("Invalid messaage number for the nextMsgNo");
-
- Iterator stMapIt = storageMapMgr.find(new StorageMapBean (null,nextMsgno,sequenceId)).iterator();
-
+ if (nextMsgno <= 0)
+ throw new SandeshaException(
+ "Invalid messaage number for the nextMsgNo");
+
+ Iterator stMapIt = storageMapMgr.find(
+ new StorageMapBean(null, nextMsgno, sequenceId))
+ .iterator();
+
while (stMapIt.hasNext()) {
-
- StorageMapBean stMapBean = (StorageMapBean) stMapIt.next();
+
+ StorageMapBean stMapBean = (StorageMapBean) stMapIt
+ .next();
String key = stMapBean.getKey();
-
- MessageContext msgToInvoke = SandeshaUtil.getStoredMessageContext(key);
-
- RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);
- Sequence seq = (Sequence) rmMsg.getMessagePart(Constants.MessageParts.SEQUENCE);
+
+ MessageContext msgToInvoke = SandeshaUtil
+ .getStoredMessageContext(key);
+
+ RMMsgContext rmMsg = MsgInitializer
+ .initializeMessage(msgToInvoke);
+ Sequence seq = (Sequence) rmMsg
+ .getMessagePart(Constants.MessageParts.SEQUENCE);
long msgNo = seq.getMessageNumber().getMessageNumber();
-
+
try {
//Invoking the message.
- new AxisEngine (msgToInvoke.getSystemContext()).receive(msgToInvoke);
-
- Object debug = context.getProperty(Constants.SANDESHA_DEBUG_MODE);
- if (debug!=null && "on".equals(debug)) {
- System.out.println("DEBUG: Invoker invoking a '" + SandeshaUtil.getMessageTypeString(rmMsg.getMessageType())+ "' message.");
+ new AxisEngine(msgToInvoke.getSystemContext())
+ .receive(msgToInvoke);
+
+ Object debug = context
+ .getProperty(Constants.SANDESHA_DEBUG_MODE);
+ if (debug != null && "on".equals(debug)) {
+ System.out
+ .println("DEBUG: Invoker invoking a '"
+ + SandeshaUtil
+ .getMessageTypeString(rmMsg
+ .getMessageType())
+ + "' message.");
}
-
- //deleting the message entry.
+
+ //deleting the message entry.
storageMapMgr.delete(key);
-
+
} catch (AxisFault e) {
- throw new SandeshaException (e.getMessage());
+ throw new SandeshaException(e.getMessage());
}
-
+
//undating the next mst to invoke
nextMsgno++;
- stMapIt = storageMapMgr.find(new StorageMapBean (null,nextMsgno,sequenceId)).iterator();
+ stMapIt = storageMapMgr
+ .find(
+ new StorageMapBean(null, nextMsgno,
+ sequenceId)).iterator();
}
-
+
nextMsgBean.setNextMsgNoToProcess(nextMsgno);
nextMsgMgr.update(nextMsgBean);
}
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/workers/Sender.java Wed Nov 2 17:27:17 2005
@@ -16,49 +16,21 @@
*/
package org.apache.sandesha2.workers;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-
import org.apache.axis2.AxisFault;
-import org.apache.axis2.clientapi.Call;
-import org.apache.axis2.clientapi.InOutMEPClient;
-import org.apache.axis2.clientapi.MessageSender;
-import org.apache.axis2.clientapi.TwoWayTransportBasedSender;
-import org.apache.axis2.context.AbstractContext;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
import org.apache.axis2.engine.AxisEngine;
-import org.apache.axis2.i18n.Messages;
-import org.apache.axis2.om.OMException;
import org.apache.axis2.soap.SOAPEnvelope;
-import org.apache.axis2.transport.TransportUtils;
-import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.SandeshaException;
-import org.apache.sandesha2.Constants.MessageTypes;
-import org.apache.sandesha2.client.SandeshaMepClient;
-import org.apache.sandesha2.msgreceivers.RMMessageReceiver;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.RetransmitterBeanMgr;
import org.apache.sandesha2.storage.beans.RetransmitterBean;
-import org.apache.sandesha2.storage.inmemory.InMemoryRetransmitterBeanMgr;
import org.apache.sandesha2.util.MsgInitializer;
import org.apache.sandesha2.util.SandeshaUtil;
-import org.apache.sandesha2.wsrm.Sequence;
-
-/**
- * @author Chamikara
- * @author Sanka
- */
public class Sender extends Thread {
@@ -81,65 +53,62 @@
if (context == null)
throw new SandeshaException(
"Can't continue the Sender. Context is null");
- } catch (SandeshaException e) {
- e.printStackTrace();
- return;
- }
- StorageManager storageManager = null;
-
- try {
- storageManager = SandeshaUtil
+ StorageManager storageManager = SandeshaUtil
.getSandeshaStorageManager(context);
- } catch (SandeshaException e4) {
- e4.printStackTrace();
- return;
- }
- RetransmitterBeanMgr mgr = storageManager.getRetransmitterBeanMgr();
- Collection coll = mgr.findMsgsToSend();
- Iterator iter = coll.iterator();
- while (iter.hasNext()) {
- RetransmitterBean bean = (RetransmitterBean) iter.next();
- String key = (String) bean.getKey();
- MessageContext msgCtx = SandeshaUtil
- .getStoredMessageContext(key);
-
- try {
- RMMsgContext rmMsgCtx = MsgInitializer
- .initializeMessage(msgCtx);
- updateMessage(msgCtx);
-
- Object debug = context
- .getProperty(Constants.SANDESHA_DEBUG_MODE);
- if (debug != null && "on".equals(debug)) {
- System.out.println("DEBUG: Sender is sending a '"
- + SandeshaUtil.getMessageTypeString(rmMsgCtx
- .getMessageType()) + "' message.");
+ RetransmitterBeanMgr mgr = storageManager
+ .getRetransmitterBeanMgr();
+ Collection coll = mgr.findMsgsToSend();
+ Iterator iter = coll.iterator();
+ while (iter.hasNext()) {
+ RetransmitterBean bean = (RetransmitterBean) iter.next();
+ String key = (String) bean.getKey();
+ MessageContext msgCtx = SandeshaUtil
+ .getStoredMessageContext(key);
+
+ try {
+ RMMsgContext rmMsgCtx = MsgInitializer
+ .initializeMessage(msgCtx);
+ updateMessage(msgCtx);
+
+ Object debug = context
+ .getProperty(Constants.SANDESHA_DEBUG_MODE);
+ if (debug != null && "on".equals(debug)) {
+ System.out.println("DEBUG: Sender is sending a '"
+ + SandeshaUtil
+ .getMessageTypeString(rmMsgCtx
+ .getMessageType())
+ + "' message.");
+ }
+
+ new AxisEngine(context).send(msgCtx);
+
+ //if (!msgCtx.isServerSide())
+ checkForSyncResponses(msgCtx);
+
+ } catch (AxisFault e1) {
+ e1.printStackTrace();
+ } catch (Exception e3) {
+ e3.printStackTrace();
}
- new AxisEngine(context).send(msgCtx);
-
- //if (!msgCtx.isServerSide())
- checkForSyncResponses(msgCtx);
+ //changing the values of the sent bean.
+ bean.setLastSentTime(System.currentTimeMillis());
+ bean.setSentCount(bean.getSentCount() + 1);
+
+ //update if resend=true otherwise delete. (reSend=false
+ // means
+ // send only once).
+ if (bean.isReSend())
+ mgr.update(bean);
+ else
+ mgr.delete(bean.getMessageId());
- } catch (AxisFault e1) {
- e1.printStackTrace();
- } catch (Exception e3) {
- e3.printStackTrace();
}
-
- //changing the values of the sent bean.
- bean.setLastSentTime(System.currentTimeMillis());
- bean.setSentCount(bean.getSentCount() + 1);
-
- //update if resend=true otherwise delete. (reSend=false means
- // send only once).
- if (bean.isReSend())
- mgr.update(bean);
- else
- mgr.delete(bean.getMessageId());
-
+ } catch (SandeshaException e) {
+ e.printStackTrace();
+ return;
}
try {
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Accept.java Wed Nov 2 17:27:17 2005
@@ -17,15 +17,9 @@
package org.apache.sandesha2.wsrm;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.util.SOAPAbstractFactory;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AckRequested.java Wed Nov 2 17:27:17 2005
@@ -18,7 +18,6 @@
import javax.xml.namespace.QName;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcknowledgementRange.java Wed Nov 2 17:27:17 2005
@@ -16,22 +16,12 @@
*/
package org.apache.sandesha2.wsrm;
-import java.util.Iterator;
-
import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMAttribute;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
-import org.apache.axis2.om.OMFactory;
import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.util.SOAPAbstractFactory;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/AcksTo.java Wed Nov 2 17:27:17 2005
@@ -16,20 +16,11 @@
*/
package org.apache.sandesha2.wsrm;
-import java.util.Iterator;
-
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
-import org.apache.axis2.om.OMNode;
-import org.apache.axis2.soap.SOAPEnvelope;
import org.apache.sandesha2.Constants;
import org.apache.sandesha2.util.SOAPAbstractFactory;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/Address.java Wed Nov 2 17:27:17 2005
@@ -7,11 +7,8 @@
package org.apache.sandesha2.wsrm;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
Modified: webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java
URL: http://svn.apache.org/viewcvs/webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java?rev=330406&r1=330405&r2=330406&view=diff
==============================================================================
--- webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java (original)
+++ webservices/sandesha/trunk/src/org/apache/sandesha2/wsrm/CreateSequence.java Wed Nov 2 17:27:17 2005
@@ -17,11 +17,7 @@
package org.apache.sandesha2.wsrm;
import javax.xml.namespace.QName;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.om.OMElement;
import org.apache.axis2.om.OMException;
import org.apache.axis2.om.OMNamespace;
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org