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 2006/07/19 04:58:35 UTC
svn commit: r423350 [3/8] - in /webservices/sandesha/trunk/java: ./
src/org/apache/sandesha2/ src/org/apache/sandesha2/client/
src/org/apache/sandesha2/handlers/ src/org/apache/sandesha2/i18n/
src/org/apache/sandesha2/msgprocessors/ src/org/apache/sand...
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Tue Jul 18 19:58:31 2006
@@ -41,6 +41,8 @@
import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
@@ -78,184 +80,189 @@
private boolean letInvoke = false;
- private static final Log log = LogFactory.getLog(ApplicationMsgProcessor.class );
-
+ private static final Log log = LogFactory.getLog(ApplicationMsgProcessor.class);
+
public void processInMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::processInMessage");
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::processInMessage");
- //Processing for ack if any
+ // Processing for ack if any
SequenceAcknowledgement sequenceAck = (SequenceAcknowledgement) rmMsgCtx
.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
if (sequenceAck != null) {
AcknowledgementProcessor ackProcessor = new AcknowledgementProcessor();
-
- //setting message type temporarily as ack message. so that the ack processor would not be confused
+
+ // setting message type temporarily as ack message. so that the ack
+ // processor would not be confused
int messageType = rmMsgCtx.getMessageType();
rmMsgCtx.setMessageType(Sandesha2Constants.MessageTypes.ACK);
-
+
ackProcessor.processInMessage(rmMsgCtx);
-
- //resetting the correct message type.
+
+ // resetting the correct message type.
rmMsgCtx.setMessageType(messageType);
}
-
- //TODO process embedded ack requests
+
+ // TODO process embedded ack requests
AckRequested ackRequested = (AckRequested) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
- if (ackRequested!=null) {
+ if (ackRequested != null) {
ackRequested.setMustUnderstand(false);
rmMsgCtx.addSOAPEnvelope();
}
- //Processing the application message.
+ // Processing the application message.
MessageContext msgCtx = rmMsgCtx.getMessageContext();
if (msgCtx == null) {
- String message = "Message context is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgContextNotSetInbound);
log.debug(message);
throw new SandeshaException(message);
}
- if (rmMsgCtx
- .getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE) != null
- && rmMsgCtx.getProperty(
- Sandesha2Constants.APPLICATION_PROCESSING_DONE).equals(
- "true")) {
+ if (rmMsgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE) != null
+ && rmMsgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE).equals("true")) {
return;
}
- //RM will not send sync responses. If sync acks are there this will be
+ // RM will not send sync responses. If sync acks are there this will be
// made true again later.
if (rmMsgCtx.getMessageContext().getOperationContext() != null) {
- rmMsgCtx.getMessageContext().getOperationContext().setProperty(
- Constants.RESPONSE_WRITTEN, Constants.VALUE_FALSE);
+ rmMsgCtx.getMessageContext().getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_FALSE);
}
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getConfigurationContext(),msgCtx.getConfigurationContext().getAxisConfiguration());
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(msgCtx.getConfigurationContext(), msgCtx
+ .getConfigurationContext().getAxisConfiguration());
FaultManager faultManager = new FaultManager();
- RMMsgContext faultMessageContext = faultManager.checkForLastMsgNumberExceeded(rmMsgCtx,storageManager);
+ RMMsgContext faultMessageContext = faultManager.checkForLastMsgNumberExceeded(rmMsgCtx, storageManager);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
-
+
try {
engine.sendFault(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException ("Could not send the fault message",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendFault, e
+ .toString()));
}
-
+
msgCtx.pause();
return;
}
-
+
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-
- //setting acked msg no range
- Sequence sequence = (Sequence) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+
+ // setting acked msg no range
+ Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
String sequenceId = sequence.getIdentifier().getIdentifier();
- ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
- .getConfigurationContext();
+ ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
if (configCtx == null) {
- String message = "Configuration Context is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet);
log.debug(message);
throw new SandeshaException(message);
}
- faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,sequenceId,storageManager);
+ faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx, sequenceId, storageManager);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
-
+
try {
engine.send(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException ("Could not send the fault message",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendFault, e
+ .toString()));
}
-
+
msgCtx.pause();
return;
}
-
- //setting mustUnderstand to false.
+
+ // setting mustUnderstand to false.
sequence.setMustUnderstand(false);
rmMsgCtx.addSOAPEnvelope();
-
- //throwing a fault if the sequence is closed.
- faultMessageContext = faultManager. checkForSequenceClosed(rmMsgCtx,sequenceId,storageManager);
+
+ // throwing a fault if the sequence is closed.
+ faultMessageContext = faultManager.checkForSequenceClosed(rmMsgCtx, sequenceId, storageManager);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
-
+
try {
engine.sendFault(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException ("Could not send the fault message",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendFault, e
+ .toString()));
}
-
+
return;
}
- //updating the last activated time of the sequence.
- SequenceManager.updateLastActivatedTime(sequenceId,storageManager);
-
+ // updating the last activated time of the sequence.
+ SequenceManager.updateLastActivatedTime(sequenceId, storageManager);
+
SequencePropertyBean msgsBean = seqPropMgr.retrieve(sequenceId,
Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
long msgNo = sequence.getMessageNumber().getMessageNumber();
if (msgNo == 0) {
- String message = "Wrong message number";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invalidMsgNumber, Long
+ .toString(msgNo));
log.debug(message);
throw new SandeshaException(message);
}
-
- String key = SandeshaUtil.getUUID(); //key to store the message.
-
- //updating the Highest_In_Msg_No property which gives the highest message number retrieved from this sequence.
- String highetsInMsgNoStr = SandeshaUtil.getSequenceProperty(sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER,storageManager);
- String highetsInMsgKey = SandeshaUtil.getSequenceProperty(sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY,storageManager);
- if (highetsInMsgKey==null)
+
+ String key = SandeshaUtil.getUUID(); // key to store the message.
+
+ // updating the Highest_In_Msg_No property which gives the highest
+ // message number retrieved from this sequence.
+ String highetsInMsgNoStr = SandeshaUtil.getSequenceProperty(sequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, storageManager);
+ String highetsInMsgKey = SandeshaUtil.getSequenceProperty(sequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
+ if (highetsInMsgKey == null)
highetsInMsgKey = SandeshaUtil.getUUID();
-
- long highestInMsgNo=0;
- if (highetsInMsgNoStr!=null) {
+
+ long highestInMsgNo = 0;
+ if (highetsInMsgNoStr != null) {
highestInMsgNo = Long.parseLong(highetsInMsgNoStr);
}
-
- if (msgNo>highestInMsgNo) {
+
+ if (msgNo > highestInMsgNo) {
highestInMsgNo = msgNo;
-
+
String str = new Long(msgNo).toString();
- SequencePropertyBean highestMsgNoBean = new SequencePropertyBean (sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER,str);
- SequencePropertyBean highestMsgKeyBean = new SequencePropertyBean (sequenceId,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY,highetsInMsgKey);
-
- //storing the new message as the highest in message.
+ SequencePropertyBean highestMsgNoBean = new SequencePropertyBean(sequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_NUMBER, str);
+ SequencePropertyBean highestMsgKeyBean = new SequencePropertyBean(sequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, highetsInMsgKey);
+
+ // storing the new message as the highest in message.
storageManager.removeMessageContext(highetsInMsgKey);
- storageManager.storeMessageContext(highetsInMsgKey,msgCtx);
-
- if (highetsInMsgNoStr!=null) {
+ storageManager.storeMessageContext(highetsInMsgKey, msgCtx);
+
+ if (highetsInMsgNoStr != null) {
seqPropMgr.update(highestMsgNoBean);
seqPropMgr.update(highestMsgKeyBean);
- }else{
+ } else {
seqPropMgr.insert(highestMsgNoBean);
seqPropMgr.insert(highestMsgKeyBean);
}
}
-
+
String messagesStr = "";
- if (msgsBean!=null)
+ if (msgsBean != null)
messagesStr = (String) msgsBean.getValue();
else {
- msgsBean = new SequencePropertyBean ();
+ msgsBean = new SequencePropertyBean();
msgsBean.setSequenceID(sequenceId);
msgsBean.setName(Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES);
msgsBean.setValue(messagesStr);
}
-
if (msgNoPresentInList(messagesStr, msgNo)
&& (Sandesha2Constants.QOS.InvocationType.DEFAULT_INVOCATION_TYPE == Sandesha2Constants.QOS.InvocationType.EXACTLY_ONCE)) {
- //this is a duplicate message and the invocation type is
+ // this is a duplicate message and the invocation type is
// EXACTLY_ONCE.
rmMsgCtx.pause();
}
@@ -268,87 +275,79 @@
msgsBean.setValue(messagesStr);
seqPropMgr.update(msgsBean);
- // Pause the messages bean if not the right message to invoke.
+ // Pause the messages bean if not the right message to invoke.
NextMsgBeanMgr mgr = storageManager.getNextMsgBeanMgr();
NextMsgBean bean = mgr.retrieve(sequenceId);
if (bean == null) {
- throw new SandeshaException("Error- The sequence does not exist");
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindSequence,
+ sequenceId));
}
InvokerBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
-
- //inorder invocation is still a global property
- boolean inOrderInvocation = SandeshaUtil.getPropertyBean(msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
-
+
+ // inorder invocation is still a global property
+ boolean inOrderInvocation = SandeshaUtil.getPropertyBean(
+ msgCtx.getConfigurationContext().getAxisConfiguration()).isInOrder();
+
if (inOrderInvocation) {
-
-
- SequencePropertyBean incomingSequenceListBean = (SequencePropertyBean) seqPropMgr
- .retrieve(
- Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
- Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
+
+ SequencePropertyBean incomingSequenceListBean = (SequencePropertyBean) seqPropMgr.retrieve(
+ Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
+ Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
if (incomingSequenceListBean == null) {
ArrayList incomingSequenceList = new ArrayList();
incomingSequenceListBean = new SequencePropertyBean();
- incomingSequenceListBean
- .setSequenceID(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES);
- incomingSequenceListBean
- .setName(Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
- incomingSequenceListBean.setValue(incomingSequenceList
- .toString());
+ incomingSequenceListBean.setSequenceID(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES);
+ incomingSequenceListBean.setName(Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
+ incomingSequenceListBean.setValue(incomingSequenceList.toString());
- //this get inserted before
+ // this get inserted before
seqPropMgr.insert(incomingSequenceListBean);
}
- ArrayList incomingSequenceList = SandeshaUtil
- .getArrayListFromString(incomingSequenceListBean.getValue());
+ ArrayList incomingSequenceList = SandeshaUtil.getArrayListFromString(incomingSequenceListBean.getValue());
- //Adding current sequence to the incoming sequence List.
+ // Adding current sequence to the incoming sequence List.
if (!incomingSequenceList.contains(sequenceId)) {
incomingSequenceList.add(sequenceId);
- //saving the property.
- incomingSequenceListBean.setValue(incomingSequenceList
- .toString());
+ // saving the property.
+ incomingSequenceListBean.setValue(incomingSequenceList.toString());
seqPropMgr.update(incomingSequenceListBean);
}
- //saving the message.
+ // saving the message.
try {
- storageManager.storeMessageContext(key,rmMsgCtx
- .getMessageContext());
+ storageManager.storeMessageContext(key, rmMsgCtx.getMessageContext());
storageMapMgr.insert(new InvokerBean(key, msgNo, sequenceId));
- //This will avoid performing application processing more
+ // This will avoid performing application processing more
// than
// once.
- rmMsgCtx.setProperty(
- Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
+ rmMsgCtx.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
} catch (Exception ex) {
throw new SandeshaException(ex.getMessage());
}
-
- //pause the message
+
+ // pause the message
rmMsgCtx.pause();
- //Starting the invoker if stopped.
- SandeshaUtil
- .startInvokerForTheSequence(msgCtx.getConfigurationContext(),sequenceId);
+ // Starting the invoker if stopped.
+ SandeshaUtil.startInvokerForTheSequence(msgCtx.getConfigurationContext(), sequenceId);
}
- //Sending acknowledgements
- sendAckIfNeeded(rmMsgCtx, messagesStr,storageManager);
+ // Sending acknowledgements
+ sendAckIfNeeded(rmMsgCtx, messagesStr, storageManager);
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::processInMessage");
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::processInMessage");
}
- //TODO convert following from INT to LONG
+ // TODO convert following from INT to LONG
private boolean msgNoPresentInList(String list, long no) {
String[] msgStrs = list.split(",");
@@ -365,118 +364,122 @@
public void sendAckIfNeeded(RMMsgContext rmMsgCtx, String messagesStr, StorageManager storageManager)
throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::sendAckIfNeeded");
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::sendAckIfNeeded");
MessageContext msgCtx = rmMsgCtx.getMessageContext();
- SequencePropertyBeanMgr seqPropMgr = storageManager
- .getSequencePropertyBeanMgr();
-
- Sequence sequence = (Sequence) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
+
+ Sequence sequence = (Sequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
String sequenceId = sequence.getIdentifier().getIdentifier();
- ConfigurationContext configCtx = rmMsgCtx.getMessageContext()
- .getConfigurationContext();
+ ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
if (configCtx == null)
- throw new SandeshaException("Configuration Context is null");
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.configContextNotSet));
+
+ AckRequested ackRequested = (AckRequested) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
- AckRequested ackRequested = (AckRequested) rmMsgCtx
- .getMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST);
-
- if (ackRequested!=null) {
- //setting mustundestand=false for the ackRequested header block.
+ if (ackRequested != null) {
+ // setting mustundestand=false for the ackRequested header block.
ackRequested.setMustUnderstand(false);
rmMsgCtx.addSOAPEnvelope();
}
-
- RMMsgContext ackRMMessage = AcknowledgementManager.generateAckMessage(rmMsgCtx,sequenceId,storageManager);
-
-
- AxisEngine engine = new AxisEngine (configCtx);
-
- try {
+
+ RMMsgContext ackRMMessage = AcknowledgementManager.generateAckMessage(rmMsgCtx, sequenceId, storageManager);
+
+ AxisEngine engine = new AxisEngine(configCtx);
+
+ try {
engine.send(ackRMMessage.getMessageContext());
} catch (AxisFault e) {
- String message = "Exception thrown while trying to send the ack message";
- throw new SandeshaException (message,e);
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendAck, sequenceId, e
+ .toString());
+ throw new SandeshaException(message, e);
}
-
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::sendAckIfNeeded");
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::sendAckIfNeeded");
}
-
- public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::processOutMessage");
-
+
+ public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::processOutMessage");
+
MessageContext msgContext = rmMsgCtx.getMessageContext();
- ConfigurationContext configContext = msgContext .getConfigurationContext();
-
- //setting the Fault callback
- SandeshaListener faultCallback = (SandeshaListener) msgContext.getOptions().getProperty(SandeshaClientConstants.SANDESHA_LISTENER);
- if (faultCallback!=null) {
+ ConfigurationContext configContext = msgContext.getConfigurationContext();
+
+ // setting the Fault callback
+ SandeshaListener faultCallback = (SandeshaListener) msgContext.getOptions().getProperty(
+ SandeshaClientConstants.SANDESHA_LISTENER);
+ if (faultCallback != null) {
OperationContext operationContext = msgContext.getOperationContext();
- if (operationContext!=null) {
- operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER,faultCallback);
+ if (operationContext != null) {
+ operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, faultCallback);
}
}
-
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext,configContext.getAxisConfiguration());
+
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, configContext
+ .getAxisConfiguration());
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
- boolean serverSide = msgContext.isServerSide();
+ boolean serverSide = msgContext.isServerSide();
// setting message Id if null
- if (msgContext.getMessageID() == null)
+ if (msgContext.getMessageID() == null)
msgContext.setMessageID(SandeshaUtil.getUUID());
// find internal sequence id
String internalSequenceId = null;
-
- String storageKey = SandeshaUtil.getUUID(); //the key which will be used to store this message.
-
- /* Internal sequence id is the one used to refer to the sequence (since
- actual sequence id is not available when first msg arrives)
- server side - a derivation of the sequenceId of the incoming sequence
- client side - a derivation of wsaTo & SeequenceKey */
+ String storageKey = SandeshaUtil.getUUID(); // the key which will be
+ // used to store this
+ // message.
+
+ /*
+ * Internal sequence id is the one used to refer to the sequence (since
+ * actual sequence id is not available when first msg arrives) server
+ * side - a derivation of the sequenceId of the incoming sequence client
+ * side - a derivation of wsaTo & SeequenceKey
+ */
boolean lastMessage = false;
if (serverSide) {
// getting the request message and rmMessage.
MessageContext reqMsgCtx;
try {
- reqMsgCtx = msgContext.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ reqMsgCtx = msgContext.getOperationContext().getMessageContext(
+ OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(reqMsgCtx);
Sequence reqSequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
if (reqSequence == null) {
- String message = "Sequence part is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.seqPartIsNull);
log.debug(message);
throw new SandeshaException(message);
}
String incomingSeqId = reqSequence.getIdentifier().getIdentifier();
if (incomingSeqId == null || incomingSeqId == "") {
- String message = "Invalid seqence Id";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.incomingSequenceNotValidID, "''"
+ + incomingSeqId + "''");
log.debug(message);
throw new SandeshaException(message);
}
long requestMsgNo = reqSequence.getMessageNumber().getMessageNumber();
-
+
internalSequenceId = SandeshaUtil.getOutgoingSideInternalSequenceID(incomingSeqId);
-
- //deciding weather the last message.
- String requestLastMsgNoStr = SandeshaUtil.getSequenceProperty(incomingSeqId,Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO,storageManager);
- if (requestLastMsgNoStr!=null) {
+
+ // deciding weather the last message.
+ String requestLastMsgNoStr = SandeshaUtil.getSequenceProperty(incomingSeqId,
+ Sandesha2Constants.SequenceProperties.LAST_IN_MESSAGE_NO, storageManager);
+ if (requestLastMsgNoStr != null) {
long requestLastMsgNo = Long.parseLong(requestLastMsgNoStr);
- if (requestLastMsgNo==requestMsgNo)
+ if (requestLastMsgNo == requestMsgNo)
lastMessage = true;
}
@@ -484,102 +487,100 @@
// set the internal sequence id for the client side.
EndpointReference toEPR = msgContext.getTo();
if (toEPR == null || toEPR.getAddress() == null || "".equals(toEPR.getAddress())) {
- String message = "TO End Point Reference is not set correctly. This is a must for the sandesha client side.";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
String to = toEPR.getAddress();
String sequenceKey = (String) msgContext.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
- internalSequenceId = SandeshaUtil.getInternalSequenceID(to,sequenceKey);
-
+ internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
+
String lastAppMessage = (String) msgContext.getProperty(SandeshaClientConstants.LAST_MESSAGE);
- if (lastAppMessage!=null && "true".equals(lastAppMessage))
+ if (lastAppMessage != null && "true".equals(lastAppMessage))
lastMessage = true;
}
- /* checking weather the user has given the messageNumber (most of the cases this will not be the case where
- the system will generate the message numbers */
+ /*
+ * checking weather the user has given the messageNumber (most of the
+ * cases this will not be the case where the system will generate the
+ * message numbers
+ */
- //User should set it as a long object.
+ // User should set it as a long object.
Long messageNumberLng = (Long) msgContext.getProperty(SandeshaClientConstants.MESSAGE_NUMBER);
-
+
long givenMessageNumber = -1;
- if (messageNumberLng!=null) {
+ if (messageNumberLng != null) {
givenMessageNumber = messageNumberLng.longValue();
- if (givenMessageNumber<=0) {
- throw new SandeshaException ("The givem message number value is invalid (has to be larger than zero)");
+ if (givenMessageNumber <= 0) {
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.msgNumberMustBeLargerThanZero, Long.toString(givenMessageNumber)));
}
}
-
- //the message number that was last used.
- long systemMessageNumber = getPreviousMsgNo(configContext, internalSequenceId,storageManager);
-
- //The number given by the user has to be larger than the last stored number.
- if (givenMessageNumber>0 && givenMessageNumber<=systemMessageNumber) {
- String message = "The given message number is not larger than value of the last sent message.";
- throw new SandeshaException (message);
+
+ // the message number that was last used.
+ long systemMessageNumber = getPreviousMsgNo(configContext, internalSequenceId, storageManager);
+
+ // The number given by the user has to be larger than the last stored
+ // number.
+ if (givenMessageNumber > 0 && givenMessageNumber <= systemMessageNumber) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgNumberNotLargerThanLastMsg, Long
+ .toString(givenMessageNumber));
+ throw new SandeshaException(message);
}
-
- //Finding the correct message number.
+
+ // Finding the correct message number.
long messageNumber = -1;
- if (givenMessageNumber>0) // if given message number is valid use it. (this is larger than the last stored due to the last check)
+ if (givenMessageNumber > 0) // if given message number is valid use it.
+ // (this is larger than the last stored due
+ // to the last check)
messageNumber = givenMessageNumber;
- else if (systemMessageNumber>0) { //if system message number is valid use it.
- messageNumber = systemMessageNumber+1;
- } else { //This is the fist message (systemMessageNumber = -1)
+ else if (systemMessageNumber > 0) { // if system message number is valid
+ // use it.
+ messageNumber = systemMessageNumber + 1;
+ } else { // This is the fist message (systemMessageNumber = -1)
messageNumber = 1;
}
-
- //A dummy message is a one which will not be processed as a actual application message.
- //The RM handlers will simply let these go.
+
+ // A dummy message is a one which will not be processed as a actual
+ // application message.
+ // The RM handlers will simply let these go.
String dummyMessageString = (String) msgContext.getOptions().getProperty(SandeshaClientConstants.DUMMY_MESSAGE);
boolean dummyMessage = false;
- if (dummyMessageString!=null && Sandesha2Constants.VALUE_TRUE.equals(dummyMessageString))
+ if (dummyMessageString != null && Sandesha2Constants.VALUE_TRUE.equals(dummyMessageString))
dummyMessage = true;
-
- //saving the used message number
+
+ // saving the used message number
if (!dummyMessage)
- setNextMsgNo(configContext,internalSequenceId,messageNumber,storageManager);
-
- //set this as the response highest message.
- SequencePropertyBean responseHighestMsgBean = new SequencePropertyBean (
- internalSequenceId,
- Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER,
- new Long (messageNumber).toString()
- );
+ setNextMsgNo(configContext, internalSequenceId, messageNumber, storageManager);
+
+ // set this as the response highest message.
+ SequencePropertyBean responseHighestMsgBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_NUMBER, new Long(messageNumber).toString());
seqPropMgr.insert(responseHighestMsgBean);
-
+
if (lastMessage) {
-
- SequencePropertyBean responseHighestMsgKeyBean = new SequencePropertyBean (
- internalSequenceId,
- Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_KEY,
- storageKey
- );
-
- SequencePropertyBean responseLastMsgKeyBean = new SequencePropertyBean (
- internalSequenceId,
- Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO,
- new Long (messageNumber).toString()
- );
-
+
+ SequencePropertyBean responseHighestMsgKeyBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.HIGHEST_OUT_MSG_KEY, storageKey);
+
+ SequencePropertyBean responseLastMsgKeyBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO, new Long(messageNumber).toString());
+
seqPropMgr.insert(responseHighestMsgKeyBean);
seqPropMgr.insert(responseLastMsgKeyBean);
}
-
+
boolean sendCreateSequence = false;
- SequencePropertyBean outSeqBean = seqPropMgr.retrieve(
- internalSequenceId,
+ SequencePropertyBean outSeqBean = seqPropMgr.retrieve(internalSequenceId,
Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
// setting async ack endpoint for the server side. (if present)
if (serverSide) {
- String incomingSequenceID = SandeshaUtil
- .getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
- SequencePropertyBean incomingToBean = seqPropMgr.retrieve(
- incomingSequenceID,
+ String incomingSequenceID = SandeshaUtil.getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
+ SequencePropertyBean incomingToBean = seqPropMgr.retrieve(incomingSequenceID,
Sandesha2Constants.SequenceProperties.TO_EPR);
if (incomingToBean != null) {
String incomingTo = incomingToBean.getValue();
@@ -587,63 +588,76 @@
}
}
-
- //FINDING THE SPEC VERSION
+ // FINDING THE SPEC VERSION
String specVersion = null;
if (msgContext.isServerSide()) {
- //in the server side, get the RM version from the request sequence.
+ // in the server side, get the RM version from the request sequence.
MessageContext requestMessageContext;
try {
- requestMessageContext = msgContext.getOperationContext().getMessageContext(AxisOperationFactory.MESSAGE_LABEL_IN_VALUE);
+ requestMessageContext = msgContext.getOperationContext().getMessageContext(
+ AxisOperationFactory.MESSAGE_LABEL_IN_VALUE);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
-
- if (requestMessageContext==null) {
- throw new SandeshaException ("Request message context is null, cant find out the request side sequenceID");
+
+ if (requestMessageContext == null) {
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestMsgContextNull));
}
-
+
RMMsgContext requestRMMsgCtx = MsgInitializer.initializeMessage(requestMessageContext);
Sequence sequence = (Sequence) requestRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
-
+
String requestSequenceID = sequence.getIdentifier().getIdentifier();
- SequencePropertyBean specVersionBean = seqPropMgr.retrieve(requestSequenceID,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
- if (specVersionBean==null) {
- throw new SandeshaException ("SpecVersion sequence property bean is not available for the incoming sequence. Cant find the RM version for outgoing side");
+ SequencePropertyBean specVersionBean = seqPropMgr.retrieve(requestSequenceID,
+ Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
+ if (specVersionBean == null) {
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.specVersionPropertyNotAvailable, requestSequenceID));
}
-
+
specVersion = specVersionBean.getValue();
} else {
- //in the client side, user will set the RM version.
+ // in the client side, user will set the RM version.
specVersion = (String) msgContext.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
}
-
- if (specVersion==null)
- specVersion = SpecSpecificConstants.getDefaultSpecVersion(); //TODO change the default to v1_1.
-
+
+ if (specVersion == null)
+ specVersion = SpecSpecificConstants.getDefaultSpecVersion(); // TODO
+ // change
+ // the
+ // default
+ // to
+ // v1_1.
+
if (messageNumber == 1) {
- if (outSeqBean == null) { // out sequence will be set for the server side, in the case of an offer.
- sendCreateSequence = true; // message number being one and not having an out sequence, implies that a create sequence has to be send.
+ if (outSeqBean == null) { // out sequence will be set for the
+ // server side, in the case of an offer.
+ sendCreateSequence = true; // message number being one and not
+ // having an out sequence, implies
+ // that a create sequence has to be
+ // send.
}
- // if fist message - setup the sending side sequence - both for the server and the client sides
- SequenceManager.setupNewClientSequence(msgContext, internalSequenceId,specVersion,storageManager);
+ // if fist message - setup the sending side sequence - both for the
+ // server and the client sides
+ SequenceManager.setupNewClientSequence(msgContext, internalSequenceId, specVersion, storageManager);
}
ServiceContext serviceContext = msgContext.getServiceContext();
OperationContext operationContext = msgContext.getOperationContext();
-
- //SENDING THE CREATE SEQUENCE.
- if (sendCreateSequence) {
- SequencePropertyBean responseCreateSeqAdded = seqPropMgr
- .retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT);
- String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,storageManager);
+ // SENDING THE CREATE SEQUENCE.
+ if (sendCreateSequence) {
+ SequencePropertyBean responseCreateSeqAdded = seqPropMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT);
+
+ String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
-
+
if (responseCreateSeqAdded == null) {
- responseCreateSeqAdded = new SequencePropertyBean(
- internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT,"true");
+ responseCreateSeqAdded = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.OUT_CREATE_SEQUENCE_SENT, "true");
seqPropMgr.insert(responseCreateSeqAdded);
String acksTo = null;
@@ -655,13 +669,14 @@
// sequence is send from the server.
MessageContext requestMessage;
try {
- requestMessage = operationContext.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ requestMessage = operationContext
+ .getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
-
+
if (requestMessage == null) {
- String message = "Request message is not present";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestMsgNotPresent);
log.debug(message);
throw new SandeshaException(message);
}
@@ -673,14 +688,15 @@
}
if (!anonymousURI.equals(acksTo) && !serverSide) {
- String transportIn = (String) configContext //TODO verify
+ String transportIn = (String) configContext // TODO verify
.getProperty(MessageContext.TRANSPORT_IN);
if (transportIn == null)
transportIn = org.apache.axis2.Constants.TRANSPORT_HTTP;
} else if (acksTo == null && serverSide) {
- String incomingSequencId = SandeshaUtil.getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
- SequencePropertyBean bean = seqPropMgr.retrieve(
- incomingSequencId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
+ String incomingSequencId = SandeshaUtil
+ .getServerSideIncomingSeqIdFromInternalSeqId(internalSequenceId);
+ SequencePropertyBean bean = seqPropMgr.retrieve(incomingSequencId,
+ Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
if (bean != null) {
EndpointReference acksToEPR = new EndpointReference(bean.getValue());
if (acksToEPR != null)
@@ -690,23 +706,23 @@
// set transport in.
Object trIn = msgContext.getProperty(MessageContext.TRANSPORT_IN);
if (trIn == null) {
- //TODO
+ // TODO
}
}
- addCreateSequenceMessage(rmMsgCtx, internalSequenceId, acksTo,storageManager);
+ addCreateSequenceMessage(rmMsgCtx, internalSequenceId, acksTo, storageManager);
}
}
SOAPEnvelope env = rmMsgCtx.getSOAPEnvelope();
if (env == null) {
- SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(
- SandeshaUtil.getSOAPVersion(env)).getDefaultEnvelope();
+ SOAPEnvelope envelope = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(env))
+ .getDefaultEnvelope();
rmMsgCtx.setSOAPEnvelop(envelope);
}
SOAPBody soapBody = rmMsgCtx.getSOAPEnvelope().getBody();
if (soapBody == null) {
- String message = "Invalid SOAP message. Body is not present";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.soapBodyNotPresent);
log.debug(message);
throw new SandeshaException(message);
}
@@ -716,31 +732,31 @@
rmMsgCtx.setMessageId(messageId1);
}
-
if (serverSide) {
// let the request end with 202 if a ack has not been
// written in the incoming thread.
-
+
MessageContext reqMsgCtx = null;
try {
- reqMsgCtx = msgContext.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ reqMsgCtx = msgContext.getOperationContext().getMessageContext(
+ OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
if (reqMsgCtx.getProperty(Sandesha2Constants.ACK_WRITTEN) == null
|| !"true".equals(reqMsgCtx.getProperty(Sandesha2Constants.ACK_WRITTEN)))
reqMsgCtx.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "false");
}
-
+
EndpointReference toEPR = msgContext.getTo();
if (toEPR == null) {
- String message = "To EPR is not found";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
-
- //setting default actions.
+
+ // setting default actions.
String to = toEPR.getAddress();
String operationName = msgContext.getOperationContext().getAxisOperation().getName().getLocalPart();
if (msgContext.getWSAAction() == null) {
@@ -749,36 +765,38 @@
if (msgContext.getSoapAction() == null) {
msgContext.setSoapAction("\"" + to + "/" + operationName + "\"");
}
-
+
// processing the response if not an dummy.
if (!dummyMessage)
- processResponseMessage(rmMsgCtx, internalSequenceId, messageNumber,storageKey,storageManager);
-
- msgContext.pause(); // the execution will be stopped.
-
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::processOutMessage");
+ processResponseMessage(rmMsgCtx, internalSequenceId, messageNumber, storageKey, storageManager);
+
+ msgContext.pause(); // the execution will be stopped.
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::processOutMessage");
}
-
- private void addCreateSequenceMessage(RMMsgContext applicationRMMsg,
- String internalSequenceId, String acksTo, StorageManager storageManager) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::addCreateSequenceMessage, " + internalSequenceId);
+ private void addCreateSequenceMessage(RMMsgContext applicationRMMsg, String internalSequenceId, String acksTo,
+ StorageManager storageManager) throws SandeshaException {
+
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::addCreateSequenceMessage, " + internalSequenceId);
MessageContext applicationMsg = applicationRMMsg.getMessageContext();
ConfigurationContext configCtx = applicationMsg.getConfigurationContext();
-
- //generating a new create sequeuce message.
- RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(applicationRMMsg, internalSequenceId, acksTo,storageManager);
-
+
+ // generating a new create sequeuce message.
+ RMMsgContext createSeqRMMessage = RMMsgCreator.createCreateSeqMsg(applicationRMMsg, internalSequenceId, acksTo,
+ storageManager);
+
createSeqRMMessage.setFlow(MessageContext.OUT_FLOW);
- CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
+ CreateSequence createSequencePart = (CreateSequence) createSeqRMMessage
+ .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
SenderBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();
-
+
SequenceOffer offer = createSequencePart.getSequenceOffer();
if (offer != null) {
String offeredSequenceId = offer.getIdentifer().getIdentifier();
@@ -792,18 +810,21 @@
}
MessageContext createSeqMsg = createSeqRMMessage.getMessageContext();
- createSeqMsg.setRelationships(null); // create seq msg does not relateTo anything
+ createSeqMsg.setRelationships(null); // create seq msg does not
+ // relateTo anything
- CreateSeqBean createSeqBean = new CreateSeqBean(internalSequenceId,createSeqMsg.getMessageID(), null);
+ CreateSeqBean createSeqBean = new CreateSeqBean(internalSequenceId, createSeqMsg.getMessageID(), null);
createSeqMgr.insert(createSeqBean);
- String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,storageManager);
+ String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
-
+
if (createSeqMsg.getReplyTo() == null)
createSeqMsg.setReplyTo(new EndpointReference(anonymousURI));
- String key = SandeshaUtil.getUUID(); //the key used to store the create sequence message.
+ String key = SandeshaUtil.getUUID(); // the key used to store the
+ // create sequence message.
SenderBean createSeqEntry = new SenderBean();
createSeqEntry.setMessageContextRefKey(key);
@@ -813,40 +834,41 @@
// this will be set to true in the sender
createSeqEntry.setSend(true);
- createSeqMsg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,Sandesha2Constants.VALUE_FALSE);
+ createSeqMsg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
createSeqEntry.setMessageType(Sandesha2Constants.MessageTypes.CREATE_SEQ);
retransmitterMgr.insert(createSeqEntry);
-
- storageManager.storeMessageContext(key,createSeqMsg); //storing the message.
- // message will be stored in the Sandesha2TransportSender
+ storageManager.storeMessageContext(key, createSeqMsg); // storing the
+ // message.
+
+ // message will be stored in the Sandesha2TransportSender
createSeqMsg.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY, key);
-
+
TransportOutDescription transportOut = createSeqMsg.getTransportOut();
-
- createSeqMsg.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC,transportOut);
- createSeqMsg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE,Sandesha2Constants.VALUE_TRUE);
+
+ createSeqMsg.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC, transportOut);
+ createSeqMsg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
createSeqMsg.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY, key);
-
- Sandesha2TransportOutDesc sandesha2TransportOutDesc = new Sandesha2TransportOutDesc ();
+
+ Sandesha2TransportOutDesc sandesha2TransportOutDesc = new Sandesha2TransportOutDesc();
createSeqMsg.setTransportOut(sandesha2TransportOutDesc);
// sending the message once through Sandesha2TransportSender.
AxisEngine engine = new AxisEngine(createSeqMsg.getConfigurationContext());
- try {
- engine.resumeSend(createSeqMsg);
- } catch (AxisFault e) {
- throw new SandeshaException (e.getMessage());
- }
-
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::addCreateSequenceMessage");
+ try {
+ engine.resumeSend(createSeqMsg);
+ } catch (AxisFault e) {
+ throw new SandeshaException(e.getMessage());
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::addCreateSequenceMessage");
}
- private void processResponseMessage(RMMsgContext rmMsg,
- String internalSequenceId, long messageNumber, String storageKey, StorageManager storageManager) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::processResponseMessage, " + internalSequenceId);
+ private void processResponseMessage(RMMsgContext rmMsg, String internalSequenceId, long messageNumber,
+ String storageKey, StorageManager storageManager) throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::processResponseMessage, " + internalSequenceId);
MessageContext msg = rmMsg.getMessageContext();
SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(rmMsg.getSOAPEnvelope()));
@@ -855,30 +877,30 @@
SequencePropertyBeanMgr sequencePropertyMgr = storageManager.getSequencePropertyBeanMgr();
SenderBeanMgr retransmitterMgr = storageManager.getRetransmitterBeanMgr();
- SequencePropertyBean toBean = sequencePropertyMgr.retrieve(
- internalSequenceId,Sandesha2Constants.SequenceProperties.TO_EPR);
- SequencePropertyBean replyToBean = sequencePropertyMgr.retrieve(
- internalSequenceId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
+ SequencePropertyBean toBean = sequencePropertyMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.TO_EPR);
+ SequencePropertyBean replyToBean = sequencePropertyMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.REPLY_TO_EPR);
// again - looks weird in the client side - but consistent
- SequencePropertyBean outSequenceBean = sequencePropertyMgr.retrieve(
- internalSequenceId,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
+ SequencePropertyBean outSequenceBean = sequencePropertyMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
if (toBean == null) {
- String message = "To is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
EndpointReference toEPR = new EndpointReference(toBean.getValue());
-
+
EndpointReference replyToEPR = null;
if (replyToBean != null) {
replyToEPR = new EndpointReference(replyToBean.getValue());
}
if (toEPR == null || toEPR.getAddress() == null || toEPR.getAddress() == "") {
- String message = "To Property has an invalid value";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
@@ -887,7 +909,7 @@
if (msg.isServerSide()) {
try {
MessageContext requestMsg = msg.getOperationContext().getMessageContext(
- OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
if (requestMsg != null) {
newToStr = requestMsg.getReplyTo().getAddress();
}
@@ -904,14 +926,15 @@
if (replyToEPR != null)
rmMsg.setReplyTo(replyToEPR);
- String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId,storageManager);
- if (rmVersion==null)
- throw new SandeshaException ("Cant find the rmVersion of the given message");
-
+ String rmVersion = SandeshaUtil.getRMVersion(internalSequenceId, storageManager);
+ if (rmVersion == null)
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.specVersionPropertyNotAvailable, internalSequenceId));
+
String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmVersion);
-
- Sequence sequence = new Sequence(factory,rmNamespaceValue);
- MessageNumber msgNumber = new MessageNumber(factory,rmNamespaceValue);
+
+ Sequence sequence = new Sequence(factory, rmNamespaceValue);
+ MessageNumber msgNumber = new MessageNumber(factory, rmNamespaceValue);
msgNumber.setMessageNumber(messageNumber);
sequence.setMessageNumber(msgNumber);
@@ -921,7 +944,8 @@
MessageContext requestMsg = null;
try {
- requestMsg = msg.getOperationContext().getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ requestMsg = msg.getOperationContext()
+ .getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
} catch (AxisFault e) {
throw new SandeshaException(e.getMessage());
}
@@ -929,14 +953,14 @@
RMMsgContext reqRMMsgCtx = MsgInitializer.initializeMessage(requestMsg);
Sequence requestSequence = (Sequence) reqRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
if (requestSequence == null) {
- String message = "Request Sequence is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.requestSeqIsNull);
log.debug(message);
throw new SandeshaException(message);
}
if (requestSequence.getLastMessage() != null) {
lastMessage = true;
- sequence.setLastMessage(new LastMessage(factory,rmNamespaceValue));
+ sequence.setLastMessage(new LastMessage(factory, rmNamespaceValue));
}
@@ -948,14 +972,16 @@
Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
if (obj != null && "true".equals(obj)) {
lastMessage = true;
-
- SequencePropertyBean specVersionBean = sequencePropertyMgr.retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
- if (specVersionBean==null)
- throw new SandeshaException ("Spec version bean is not set");
-
+
+ SequencePropertyBean specVersionBean = sequencePropertyMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
+ if (specVersionBean == null)
+ throw new SandeshaException(SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.specVersionNotSet));
+
String specVersion = specVersionBean.getValue();
if (SpecSpecificConstants.isLastMessageIndicatorRequired(specVersion))
- sequence.setLastMessage(new LastMessage(factory,rmNamespaceValue));
+ sequence.setLastMessage(new LastMessage(factory, rmNamespaceValue));
}
}
}
@@ -963,8 +989,9 @@
AckRequested ackRequested = null;
boolean addAckRequested = false;
- //if (!lastMessage)
-// addAckRequested = true; //TODO decide the policy to add the ackRequested tag
+ // if (!lastMessage)
+ // addAckRequested = true; //TODO decide the policy to add the
+ // ackRequested tag
// setting the Sequnece id.
// Set send = true/false depending on the availability of the out
@@ -977,18 +1004,17 @@
identifierStr = (String) outSequenceBean.getValue();
}
- Identifier id1 = new Identifier(factory,rmNamespaceValue);
+ Identifier id1 = new Identifier(factory, rmNamespaceValue);
id1.setIndentifer(identifierStr);
sequence.setIdentifier(id1);
- rmMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE,sequence);
+ rmMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
if (addAckRequested) {
- ackRequested = new AckRequested(factory,rmNamespaceValue);
- Identifier id2 = new Identifier(factory,rmNamespaceValue);
+ ackRequested = new AckRequested(factory, rmNamespaceValue);
+ Identifier id2 = new Identifier(factory, rmNamespaceValue);
id2.setIndentifer(identifierStr);
ackRequested.setIdentifier(id2);
- rmMsg.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST,
- ackRequested);
+ rmMsg.setMessagePart(Sandesha2Constants.MessageParts.ACK_REQUEST, ackRequested);
}
try {
@@ -997,9 +1023,9 @@
throw new SandeshaException(e1.getMessage());
}
- //Retransmitter bean entry for the application message
+ // Retransmitter bean entry for the application message
SenderBean appMsgEntry = new SenderBean();
-
+
appMsgEntry.setMessageContextRefKey(storageKey);
appMsgEntry.setTimeToSend(System.currentTimeMillis());
@@ -1011,79 +1037,80 @@
} else {
appMsgEntry.setSend(true);
// Send will be set to true at the sender.
- msg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE,
- Sandesha2Constants.VALUE_TRUE);
+ msg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
}
appMsgEntry.setInternalSequenceID(internalSequenceId);
- storageManager.storeMessageContext(storageKey,msg);
+ storageManager.storeMessageContext(storageKey, msg);
retransmitterMgr.insert(appMsgEntry);
- msg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,Sandesha2Constants.VALUE_FALSE);
+ msg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);
// changing the sender. This will set send to true.
TransportSender sender = msg.getTransportOut().getSender();
if (sender != null) {
- Sandesha2TransportOutDesc sandesha2TransportOutDesc = new Sandesha2TransportOutDesc ();
+ Sandesha2TransportOutDesc sandesha2TransportOutDesc = new Sandesha2TransportOutDesc();
msg.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY, storageKey);
- msg.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC,
- msg.getTransportOut());
+ msg.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC, msg.getTransportOut());
msg.setTransportOut(sandesha2TransportOutDesc);
-
+
}
- //increasing the current handler index, so that the message will not be going throught the SandeshaOutHandler again.
- msg.setCurrentHandlerIndex(msg.getCurrentHandlerIndex()+1);
-
- //sending the message through, other handlers and the Sandesha2TransportSender so that it get dumped to the storage.
- AxisEngine engine = new AxisEngine (msg.getConfigurationContext());
+ // increasing the current handler index, so that the message will not be
+ // going throught the SandeshaOutHandler again.
+ msg.setCurrentHandlerIndex(msg.getCurrentHandlerIndex() + 1);
+
+ // sending the message through, other handlers and the
+ // Sandesha2TransportSender so that it get dumped to the storage.
+ AxisEngine engine = new AxisEngine(msg.getConfigurationContext());
try {
engine.resumeSend(msg);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
-
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::processResponseMessage");
- }
-
- private long getPreviousMsgNo(ConfigurationContext context,
- String internalSequenceId,StorageManager storageManager) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::getPreviousMsgNo, " + internalSequenceId);
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::processResponseMessage");
+ }
+
+ private long getPreviousMsgNo(ConfigurationContext context, String internalSequenceId, StorageManager storageManager)
+ throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::getPreviousMsgNo, " + internalSequenceId);
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
- internalSequenceId,Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
-
+
+ SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
+
long nextMsgNo = -1;
if (nextMsgNoBean != null) {
Long nextMsgNoLng = new Long(nextMsgNoBean.getValue());
nextMsgNo = nextMsgNoLng.longValue();
- }
-
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::getPreviousMsgNo, " + nextMsgNo);
-
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::getPreviousMsgNo, " + nextMsgNo);
+
return nextMsgNo;
}
-
- private void setNextMsgNo(ConfigurationContext context,
- String internalSequenceId, long msgNo,StorageManager storageManager) throws SandeshaException {
-
- if (log.isDebugEnabled())
- log.debug("Enter: ApplicationMsgProcessor::setNextMsgNo, " + internalSequenceId +", "+msgNo);
-
- if (msgNo<=0) {
- String message = "Message number '" + msgNo + "' is invalid. Has to be larger than zero.";
- throw new SandeshaException (message);
+
+ private void setNextMsgNo(ConfigurationContext context, String internalSequenceId, long msgNo,
+ StorageManager storageManager) throws SandeshaException {
+
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::setNextMsgNo, " + internalSequenceId + ", " + msgNo);
+
+ if (msgNo <= 0) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.msgNumberMustBeLargerThanZero, Long
+ .toString(msgNo));
+ throw new SandeshaException(message);
}
-
+
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(
- internalSequenceId,Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
+
+ SequencePropertyBean nextMsgNoBean = seqPropMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.NEXT_MESSAGE_NUMBER);
boolean update = true;
if (nextMsgNoBean == null) {
@@ -1099,7 +1126,7 @@
else
seqPropMgr.insert(nextMsgNoBean);
- if (log.isDebugEnabled())
- log.debug("Exit: ApplicationMsgProcessor::setNextMsgNo");
- }
+ if (log.isDebugEnabled())
+ log.debug("Exit: ApplicationMsgProcessor::setNextMsgNo");
+ }
}
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CloseSequenceProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CloseSequenceProcessor.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CloseSequenceProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CloseSequenceProcessor.java Tue Jul 18 19:58:31 2006
@@ -29,6 +29,8 @@
import org.apache.sandesha2.RMMsgContext;
import org.apache.sandesha2.Sandesha2Constants;
import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
import org.apache.sandesha2.storage.beans.SequencePropertyBean;
@@ -41,119 +43,119 @@
import org.apache.sandesha2.wsrm.SequenceAcknowledgement;
/**
- * Responsible for processing an incoming Close Sequence message.
- * (As introduced by the WSRM 1.1 specification)
+ * Responsible for processing an incoming Close Sequence message. (As introduced
+ * by the WSRM 1.1 specification)
*/
public class CloseSequenceProcessor implements MsgProcessor {
- private static final Log log = LogFactory.getLog(CloseSequenceProcessor.class );
+ private static final Log log = LogFactory.getLog(CloseSequenceProcessor.class);
public void processInMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: CloseSequenceProcessor::processInMessage");
+ if (log.isDebugEnabled())
+ log.debug("Enter: CloseSequenceProcessor::processInMessage");
ConfigurationContext configCtx = rmMsgCtx.getMessageContext().getConfigurationContext();
- CloseSequence closeSequence = (CloseSequence) rmMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
-
+ CloseSequence closeSequence = (CloseSequence) rmMsgCtx
+ .getMessagePart(Sandesha2Constants.MessageParts.CLOSE_SEQUENCE);
+
MessageContext msgCtx = rmMsgCtx.getMessageContext();
-
+
String sequenceID = closeSequence.getIdentifier().getIdentifier();
-
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx,configCtx.getAxisConfiguration());
-
-
+
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configCtx, configCtx
+ .getAxisConfiguration());
+
FaultManager faultManager = new FaultManager();
- RMMsgContext faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx,sequenceID,storageManager);
+ RMMsgContext faultMessageContext = faultManager.checkForUnknownSequence(rmMsgCtx, sequenceID, storageManager);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = msgCtx.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
-
+
try {
engine.sendFault(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException ("Could not send the fault message",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendFault, e
+ .toString()), e);
}
-
+
msgCtx.pause();
return;
}
-
SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropertyBeanMgr();
- SequencePropertyBean sequenceClosedBean = new SequencePropertyBean ();
+ SequencePropertyBean sequenceClosedBean = new SequencePropertyBean();
sequenceClosedBean.setSequenceID(sequenceID);
sequenceClosedBean.setName(Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED);
sequenceClosedBean.setValue(Sandesha2Constants.VALUE_TRUE);
-
+
sequencePropMgr.insert(sequenceClosedBean);
-
- RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx,sequenceID,storageManager);
-
+
+ RMMsgContext ackRMMsgCtx = AcknowledgementManager.generateAckMessage(rmMsgCtx, sequenceID, storageManager);
+
MessageContext ackMsgCtx = ackRMMsgCtx.getMessageContext();
-
+
String rmNamespaceValue = rmMsgCtx.getRMNamespaceValue();
ackRMMsgCtx.setRMNamespaceValue(rmNamespaceValue);
-
SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil
.getSOAPVersion(rmMsgCtx.getSOAPEnvelope()));
-
- //Setting new envelope
+
+ // Setting new envelope
SOAPEnvelope envelope = factory.getDefaultEnvelope();
try {
ackMsgCtx.setEnvelope(envelope);
} catch (AxisFault e3) {
throw new SandeshaException(e3.getMessage());
}
-
- //adding the ack part to the envelope.
- SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMsgCtx.getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
-
+
+ // adding the ack part to the envelope.
+ SequenceAcknowledgement sequenceAcknowledgement = (SequenceAcknowledgement) ackRMMsgCtx
+ .getMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT);
+
MessageContext closeSequenceMsg = rmMsgCtx.getMessageContext();
-
+
MessageContext closeSequenceResponseMsg = null;
-
+
try {
closeSequenceResponseMsg = Utils.createOutMessageContext(closeSequenceMsg);
} catch (AxisFault e1) {
- throw new SandeshaException (e1);
+ throw new SandeshaException(e1);
}
-
- RMMsgContext closeSeqResponseRMMsg = RMMsgCreator
- .createCloseSeqResponseMsg(rmMsgCtx, closeSequenceResponseMsg,storageManager);
-
- closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,sequenceAcknowledgement);
-
+
+ RMMsgContext closeSeqResponseRMMsg = RMMsgCreator.createCloseSeqResponseMsg(rmMsgCtx, closeSequenceResponseMsg,
+ storageManager);
+
+ closeSeqResponseRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT,
+ sequenceAcknowledgement);
+
closeSeqResponseRMMsg.setFlow(MessageContext.OUT_FLOW);
- closeSeqResponseRMMsg.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true");
+ closeSeqResponseRMMsg.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
closeSequenceResponseMsg.setResponseWritten(true);
-
+
closeSeqResponseRMMsg.addSOAPEnvelope();
-
- AxisEngine engine = new AxisEngine (closeSequenceMsg.getConfigurationContext());
-
+
+ AxisEngine engine = new AxisEngine(closeSequenceMsg.getConfigurationContext());
+
try {
engine.send(closeSequenceResponseMsg);
} catch (AxisFault e) {
- String message = "Could not send the terminate sequence response";
- throw new SandeshaException (message,e);
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendTerminateResponse,
+ sequenceID, e.toString());
+ throw new SandeshaException(message, e);
}
-
- if (log.isDebugEnabled())
- log.debug("Exit: CloseSequenceProcessor::processInMessage");
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: CloseSequenceProcessor::processInMessage");
}
-
+
public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- if (log.isDebugEnabled())
- {
- log.debug("Enter: CloseSequenceProcessor::processOutMessage");
- log.debug("Exit: CloseSequenceProcessor::processOutMessage");
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: CloseSequenceProcessor::processOutMessage");
+ log.debug("Exit: CloseSequenceProcessor::processOutMessage");
+ }
}
-
-
}
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/msgprocessors/CreateSeqMsgProcessor.java Tue Jul 18 19:58:31 2006
@@ -33,6 +33,8 @@
import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.client.SandeshaClientConstants;
import org.apache.sandesha2.client.SandeshaListener;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.CreateSeqBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
@@ -55,207 +57,229 @@
public class CreateSeqMsgProcessor implements MsgProcessor {
private static final Log log = LogFactory.getLog(CreateSeqMsgProcessor.class);
-
- public void processInMessage(RMMsgContext createSeqRMMsg)
- throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: CreateSeqMsgProcessor::processInMessage");
-
+
+ public void processInMessage(RMMsgContext createSeqRMMsg) throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: CreateSeqMsgProcessor::processInMessage");
+
MessageContext createSeqMsg = createSeqRMMsg.getMessageContext();
- CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
+ CreateSequence createSeqPart = (CreateSequence) createSeqRMMsg
+ .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
if (createSeqPart == null) {
- String message = "No create sequence part is present in the create sequence message";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noCreateSeqParts);
log.debug(message);
throw new SandeshaException(message);
}
ConfigurationContext context = createSeqMsg.getConfigurationContext();
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
-
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context.getAxisConfiguration());
+
FaultManager faultManager = new FaultManager();
- RMMsgContext faultMessageContext = faultManager.checkForCreateSequenceRefused(createSeqMsg,storageManager);
+ RMMsgContext faultMessageContext = faultManager.checkForCreateSequenceRefused(createSeqMsg, storageManager);
if (faultMessageContext != null) {
ConfigurationContext configurationContext = createSeqMsg.getConfigurationContext();
AxisEngine engine = new AxisEngine(configurationContext);
-
+
try {
engine.sendFault(faultMessageContext.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException ("Could not send the fault message",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.couldNotSendFault), e);
}
-
+
createSeqMsg.pause();
return;
}
MessageContext outMessage = null;
try {
- outMessage = Utils.createOutMessageContext(createSeqMsg); //createing a new response message.
+ outMessage = Utils.createOutMessageContext(createSeqMsg); // createing
+ // a new
+ // response
+ // message.
} catch (AxisFault e1) {
- throw new SandeshaException (e1);
+ throw new SandeshaException(e1);
}
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
try {
- String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg,storageManager); //newly created sequnceID.
-
- RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(
- createSeqRMMsg, outMessage,newSequenceId,storageManager); // converting the blank out message in to a create
- // sequence response.
+ String newSequenceId = SequenceManager.setupNewSequence(createSeqRMMsg, storageManager); // newly
+ // created
+ // sequnceID.
+
+ RMMsgContext createSeqResponse = RMMsgCreator.createCreateSeqResponseMsg(createSeqRMMsg, outMessage,
+ newSequenceId, storageManager); // converting the blank out
+ // message in to a create
+ // sequence response.
createSeqResponse.setFlow(MessageContext.OUT_FLOW);
-
- createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true"); //for making sure that this wont be processed again.
- CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
-
- //OFFER PROCESSING
+ createSeqResponse.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true"); // for
+ // making
+ // sure
+ // that
+ // this
+ // wont
+ // be
+ // processed
+ // again.
+ CreateSequenceResponse createSeqResPart = (CreateSequenceResponse) createSeqResponse
+ .getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ_RESPONSE);
+
+ // OFFER PROCESSING
SequenceOffer offer = createSeqPart.getSequenceOffer();
if (offer != null) {
Accept accept = createSeqResPart.getAccept();
if (accept == null) {
- String message = "An accept part has not been generated for the create seq request with an offer part";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcceptPart);
log.debug(message);
throw new SandeshaException(message);
}
- String offeredSequenceID = offer.getIdentifer().getIdentifier(); //offered seq. id.
-
- boolean offerEcepted = offerAccepted (offeredSequenceID,context,createSeqRMMsg,storageManager);
-
- if (offerEcepted) {
- //Setting the CreateSequence table entry for the outgoing side.
+ String offeredSequenceID = offer.getIdentifer().getIdentifier(); // offered
+ // seq.
+ // id.
+
+ boolean offerEcepted = offerAccepted(offeredSequenceID, context, createSeqRMMsg, storageManager);
+
+ if (offerEcepted) {
+ // Setting the CreateSequence table entry for the outgoing
+ // side.
CreateSeqBean createSeqBean = new CreateSeqBean();
createSeqBean.setSequenceID(offeredSequenceID);
- String outgoingSideInternalSequenceID = SandeshaUtil.getOutgoingSideInternalSequenceID(newSequenceId);
+ String outgoingSideInternalSequenceID = SandeshaUtil
+ .getOutgoingSideInternalSequenceID(newSequenceId);
createSeqBean.setInternalSequenceID(outgoingSideInternalSequenceID);
- createSeqBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); //this is a dummy value.
-
+ createSeqBean.setCreateSeqMsgID(SandeshaUtil.getUUID()); // this
+ // is a
+ // dummy
+ // value.
+
CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
createSeqMgr.insert(createSeqBean);
-
- //Setting sequence properties for the outgoing sequence.
- //Only will be used by the server side response path. Will be wasted properties for the client side.
-
- //setting the out_sequence_id
+
+ // Setting sequence properties for the outgoing sequence.
+ // Only will be used by the server side response path. Will
+ // be wasted properties for the client side.
+
+ // setting the out_sequence_id
SequencePropertyBean outSequenceBean = new SequencePropertyBean();
outSequenceBean.setName(Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID);
outSequenceBean.setValue(offeredSequenceID);
outSequenceBean.setSequenceID(outgoingSideInternalSequenceID);
seqPropMgr.insert(outSequenceBean);
- //setting the internal_sequence_id
+ // setting the internal_sequence_id
SequencePropertyBean internalSequenceBean = new SequencePropertyBean();
internalSequenceBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
internalSequenceBean.setSequenceID(offeredSequenceID);
internalSequenceBean.setValue(outgoingSideInternalSequenceID);
seqPropMgr.insert(internalSequenceBean);
} else {
- //removing the accept part.
+ // removing the accept part.
createSeqResPart.setAccept(null);
createSeqResponse.addSOAPEnvelope();
}
}
EndpointReference acksTo = createSeqPart.getAcksTo().getAddress().getEpr();
- if (acksTo == null || acksTo.getAddress() == null
- || acksTo.getAddress() == "") {
- String message = "Acks to not present in the create sequence message";
+ if (acksTo == null || acksTo.getAddress() == null || acksTo.getAddress() == "") {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
log.debug(message);
throw new AxisFault(message);
}
- SequencePropertyBean acksToBean = new SequencePropertyBean(
- newSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,acksTo.getAddress());
+ SequencePropertyBean acksToBean = new SequencePropertyBean(newSequenceId,
+ Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo.getAddress());
seqPropMgr.insert(acksToBean);
-
+
outMessage.setResponseWritten(true);
- //commiting tr. before sending the response msg.
-
- SequenceManager.updateLastActivatedTime(newSequenceId,storageManager);
-
+ // commiting tr. before sending the response msg.
+
+ SequenceManager.updateLastActivatedTime(newSequenceId, storageManager);
+
AxisEngine engine = new AxisEngine(context);
engine.send(outMessage);
-
- SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,Sandesha2Constants.SequenceProperties.TO_EPR);
- if (toBean==null) {
- String message = "Internal Error: wsa:To value is not set";
+
+ SequencePropertyBean toBean = seqPropMgr.retrieve(newSequenceId,
+ Sandesha2Constants.SequenceProperties.TO_EPR);
+ if (toBean == null) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
- EndpointReference toEPR = new EndpointReference (toBean.getValue());
-
- String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(newSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,storageManager);
+
+ EndpointReference toEPR = new EndpointReference(toBean.getValue());
+
+ String addressingNamespaceURI = SandeshaUtil.getSequenceProperty(newSequenceId,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceURI);
-
+
if (anonymousURI.equals(toEPR.getAddress())) {
createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "true");
} else {
createSeqMsg.getOperationContext().setProperty(org.apache.axis2.Constants.RESPONSE_WRITTEN, "false");
}
-
+
} catch (AxisFault e1) {
throw new SandeshaException(e1);
}
createSeqRMMsg.pause();
-
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::processInMessage");
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::processInMessage");
}
-
- private boolean offerAccepted (String sequenceID, ConfigurationContext configCtx, RMMsgContext createSeqRMMsg,StorageManager storageManager) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: CreateSeqMsgProcessor::offerAccepted, "+sequenceID);
-
- if ("".equals(sequenceID))
- {
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, "+false);
+
+ private boolean offerAccepted(String sequenceID, ConfigurationContext configCtx, RMMsgContext createSeqRMMsg,
+ StorageManager storageManager) throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: CreateSeqMsgProcessor::offerAccepted, " + sequenceID);
+
+ if ("".equals(sequenceID)) {
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
return false;
- }
-
+ }
+
CreateSeqBeanMgr createSeqMgr = storageManager.getCreateSeqBeanMgr();
-
- CreateSeqBean createSeqFindBean = new CreateSeqBean ();
+
+ CreateSeqBean createSeqFindBean = new CreateSeqBean();
createSeqFindBean.setSequenceID(sequenceID);
Collection arr = createSeqMgr.find(createSeqFindBean);
-
- if (arr.size()>0)
- {
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, "+false);
+
+ if (arr.size() > 0) {
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
return false;
- }
- if (sequenceID.length()<=1)
- {
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, "+false);
- return false; //Single character offers are NOT accepted.
- }
-
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, "+true);
+ }
+ if (sequenceID.length() <= 1) {
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + false);
+ return false; // Single character offers are NOT accepted.
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::offerAccepted, " + true);
return true;
}
-
- public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
- if (log.isDebugEnabled())
- log.debug("Enter: CreateSeqMsgProcessor::processOutMessage");
-
- MessageContext msgCtx = rmMsgCtx.getMessageContext();
-
- //adding the SANDESHA_LISTENER
- SandeshaListener faultCallback = (SandeshaListener) msgCtx.getOptions().getProperty(SandeshaClientConstants.SANDESHA_LISTENER);
- if (faultCallback!=null) {
+
+ public void processOutMessage(RMMsgContext rmMsgCtx) throws SandeshaException {
+ if (log.isDebugEnabled())
+ log.debug("Enter: CreateSeqMsgProcessor::processOutMessage");
+
+ MessageContext msgCtx = rmMsgCtx.getMessageContext();
+
+ // adding the SANDESHA_LISTENER
+ SandeshaListener faultCallback = (SandeshaListener) msgCtx.getOptions().getProperty(
+ SandeshaClientConstants.SANDESHA_LISTENER);
+ if (faultCallback != null) {
OperationContext operationContext = msgCtx.getOperationContext();
- if (operationContext!=null) {
- operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER,faultCallback);
+ if (operationContext != null) {
+ operationContext.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, faultCallback);
}
}
- if (log.isDebugEnabled())
- log.debug("Exit: CreateSeqMsgProcessor::processOutMessage");
+ if (log.isDebugEnabled())
+ log.debug("Exit: CreateSeqMsgProcessor::processOutMessage");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org