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 [7/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/util/SequenceManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SequenceManager.java Tue Jul 18 19:58:31 2006
@@ -27,6 +27,8 @@
import org.apache.sandesha2.Sandesha2Constants;
import org.apache.sandesha2.SandeshaException;
import org.apache.sandesha2.client.SandeshaClientConstants;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
import org.apache.sandesha2.storage.StorageManager;
import org.apache.sandesha2.storage.beanmanagers.NextMsgBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.SequencePropertyBeanMgr;
@@ -35,21 +37,22 @@
import org.apache.sandesha2.wsrm.CreateSequence;
/**
- * This is used to set up a new sequence, both at the sending side and the receiving side.
+ * This is used to set up a new sequence, both at the sending side and the
+ * receiving side.
*/
public class SequenceManager {
private static Log log = LogFactory.getLog(SequenceManager.class);
-
- public static String setupNewSequence(RMMsgContext createSequenceMsg,StorageManager storageManager)
- throws AxisFault {
-
+
+ public static String setupNewSequence(RMMsgContext createSequenceMsg, StorageManager storageManager)
+ throws AxisFault {
+
String sequenceId = SandeshaUtil.getUUID();
EndpointReference to = createSequenceMsg.getTo();
if (to == null) {
- String message = "To is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new AxisFault(message);
}
@@ -59,94 +62,88 @@
CreateSequence createSequence = (CreateSequence) createSequenceMsg
.getMessagePart(Sandesha2Constants.MessageParts.CREATE_SEQ);
if (createSequence == null) {
- String message = "Create Sequence Part is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.createSeqEntryNotFound);
log.debug(message);
throw new AxisFault(message);
}
- EndpointReference acksTo = createSequence.getAcksTo().getAddress()
- .getEpr();
+ EndpointReference acksTo = createSequence.getAcksTo().getAddress().getEpr();
if (acksTo == null) {
- String message = "AcksTo is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noAcksToPartInCreateSequence);
log.debug(message);
throw new AxisFault(message);
}
- ConfigurationContext configurationContext = createSequenceMsg.getMessageContext()
- .getConfigurationContext();
+ ConfigurationContext configurationContext = createSequenceMsg.getMessageContext().getConfigurationContext();
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
- SequencePropertyBeanMgr seqPropMgr = storageManager
- .getSequencePropertyBeanMgr();
+ SequencePropertyBean receivedMsgBean = new SequencePropertyBean(sequenceId,
+ Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
- SequencePropertyBean receivedMsgBean = new SequencePropertyBean(
- sequenceId, Sandesha2Constants.SequenceProperties.SERVER_COMPLETED_MESSAGES, "");
-
-
- //setting the addressing version
+ // setting the addressing version
String addressingNamespaceValue = createSequenceMsg.getAddressingNamespaceValue();
- SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean (
- sequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,addressingNamespaceValue);
+ SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean(sequenceId,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespaceValue);
seqPropMgr.insert(addressingNamespaceBean);
-
+
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespaceValue);
-
- //If no replyTo value. Send responses as sync.
+
+ // If no replyTo value. Send responses as sync.
SequencePropertyBean toBean = null;
- if (replyTo!=null) {
- toBean = new SequencePropertyBean(sequenceId,
- Sandesha2Constants.SequenceProperties.TO_EPR, replyTo.getAddress());
- }else {
- toBean = new SequencePropertyBean(sequenceId,
- Sandesha2Constants.SequenceProperties.TO_EPR, anonymousURI);
+ if (replyTo != null) {
+ toBean = new SequencePropertyBean(sequenceId, Sandesha2Constants.SequenceProperties.TO_EPR, replyTo
+ .getAddress());
+ } else {
+ toBean = new SequencePropertyBean(sequenceId, Sandesha2Constants.SequenceProperties.TO_EPR, anonymousURI);
}
-
+
SequencePropertyBean replyToBean = new SequencePropertyBean(sequenceId,
Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, to.getAddress());
SequencePropertyBean acksToBean = new SequencePropertyBean(sequenceId,
Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, acksTo.getAddress());
-
seqPropMgr.insert(receivedMsgBean);
seqPropMgr.insert(replyToBean);
seqPropMgr.insert(acksToBean);
-
- if (toBean!=null)
+
+ if (toBean != null)
seqPropMgr.insert(toBean);
NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
- nextMsgMgr.insert(new NextMsgBean(sequenceId, 1)); // 1 will be the next
-
+ nextMsgMgr.insert(new NextMsgBean(sequenceId, 1)); // 1 will be the
+ // next
+
// message to invoke. This will apply for only in-order invocations.
- SandeshaUtil.startSenderForTheSequence(configurationContext,sequenceId);
-
- //stting the RM SPEC version for this sequence.
+ SandeshaUtil.startSenderForTheSequence(configurationContext, sequenceId);
+
+ // stting the RM SPEC version for this sequence.
String createSequenceMsgAction = createSequenceMsg.getWSAAction();
- if (createSequenceMsgAction==null)
- throw new SandeshaException ("Create sequence message does not have the WSA:Action value");
-
+ if (createSequenceMsgAction == null)
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noWSAACtionValue));
+
String messageRMNamespace = createSequence.getNamespaceValue();
-
+
String specVersion = null;
if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(messageRMNamespace)) {
specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_0;
- }else if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(messageRMNamespace)) {
+ } else if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(messageRMNamespace)) {
specVersion = Sandesha2Constants.SPEC_VERSIONS.v1_1;
} else {
- throw new SandeshaException ("Create sequence message does not has a valid RM namespace value. Cant decide the RM version");
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotDecideRMVersion));
}
-
- SequencePropertyBean specVerionBean = new SequencePropertyBean ();
+
+ SequencePropertyBean specVerionBean = new SequencePropertyBean();
specVerionBean.setSequenceID(sequenceId);
specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
specVerionBean.setValue(specVersion);
-
+
seqPropMgr.insert(specVerionBean);
-
- //TODO get the SOAP version from the create seq message.
-
+
+ // TODO get the SOAP version from the create seq message.
+
return sequenceId;
}
@@ -154,47 +151,54 @@
}
- public static void setupNewClientSequence(
- MessageContext firstAplicationMsgCtx, String internalSequenceId, String specVersion,StorageManager storageManager)
- throws SandeshaException {
-
- ConfigurationContext configurationContext = firstAplicationMsgCtx
- .getConfigurationContext();
-
- SequencePropertyBeanMgr seqPropMgr = storageManager
- .getSequencePropertyBeanMgr();
-
- //setting the addressing version
- String addressingNamespace = (String) firstAplicationMsgCtx.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
-
- if (addressingNamespace==null) {
+ public static void setupNewClientSequence(MessageContext firstAplicationMsgCtx, String internalSequenceId,
+ String specVersion, StorageManager storageManager) throws SandeshaException {
+
+ ConfigurationContext configurationContext = firstAplicationMsgCtx.getConfigurationContext();
+
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
+
+ // setting the addressing version
+ String addressingNamespace = (String) firstAplicationMsgCtx
+ .getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+
+ if (addressingNamespace == null) {
OperationContext opCtx = firstAplicationMsgCtx.getOperationContext();
- if (opCtx!=null) {
+ if (opCtx != null) {
try {
MessageContext requestMsg = opCtx.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
- if (requestMsg!=null)
- addressingNamespace = (String) requestMsg.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
+ if (requestMsg != null)
+ addressingNamespace = (String) requestMsg
+ .getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
} catch (AxisFault e) {
- throw new SandeshaException (e);
+ throw new SandeshaException(e);
}
}
}
-
- if (addressingNamespace==null)
- addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE; //defaults to Final. Make sure this is synchronized with addressing.
-
- SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean (
- internalSequenceId,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,addressingNamespace);
+
+ if (addressingNamespace == null)
+ addressingNamespace = AddressingConstants.Final.WSA_NAMESPACE; // defaults
+ // to
+ // Final.
+ // Make
+ // sure
+ // this
+ // is
+ // synchronized
+ // with
+ // addressing.
+
+ SequencePropertyBean addressingNamespaceBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, addressingNamespace);
seqPropMgr.insert(addressingNamespaceBean);
-
+
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
-
+
EndpointReference toEPR = firstAplicationMsgCtx.getTo();
- String acksTo = (String) firstAplicationMsgCtx
- .getProperty(SandeshaClientConstants.AcksTo);
+ String acksTo = (String) firstAplicationMsgCtx.getProperty(SandeshaClientConstants.AcksTo);
if (toEPR == null) {
- String message = "WS-Addressing To is null";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.debug(message);
throw new SandeshaException(message);
}
@@ -203,291 +207,325 @@
Sandesha2Constants.SequenceProperties.TO_EPR, toEPR.getAddress());
SequencePropertyBean replyToBean = null;
SequencePropertyBean acksToBean = null;
-
+
if (firstAplicationMsgCtx.isServerSide()) {
- //setting replyTo value, if this is the server side.
+ // setting replyTo value, if this is the server side.
OperationContext opContext = firstAplicationMsgCtx.getOperationContext();
try {
- MessageContext requestMessage = opContext.getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
- if (requestMessage==null) {
- String message = "Cannot find the request message from the operation context";
+ MessageContext requestMessage = opContext
+ .getMessageContext(OperationContextFactory.MESSAGE_LABEL_IN_VALUE);
+ if (requestMessage == null) {
+ String message = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
log.error(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
- EndpointReference replyToEPR = requestMessage.getTo(); //'replyTo' of the response msg is the 'to' value of the req msg.
- if (replyToEPR!=null) {
- replyToBean = new SequencePropertyBean (internalSequenceId,Sandesha2Constants.SequenceProperties.REPLY_TO_EPR,replyToEPR.getAddress());
- acksToBean = new SequencePropertyBean (internalSequenceId,Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,replyToEPR.getAddress());
+
+ EndpointReference replyToEPR = requestMessage.getTo(); // 'replyTo'
+ // of
+ // the
+ // response
+ // msg
+ // is
+ // the
+ // 'to'
+ // value
+ // of
+ // the
+ // req
+ // msg.
+ if (replyToEPR != null) {
+ replyToBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.REPLY_TO_EPR, replyToEPR.getAddress());
+ acksToBean = new SequencePropertyBean(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.ACKS_TO_EPR, replyToEPR.getAddress());
} else {
- String message = "To EPR is not present in the request message. Need this information to set acksTo & replyTo value of reply messages";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
log.error(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
} catch (AxisFault e) {
- String message = "Cannot get request message from the operation context";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotFindReqMsgFromOpContext);
log.error(message);
log.error(e.getStackTrace());
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
}
- //Default value for acksTo is anonymous (this happens only for the client side)
- if (acksTo==null) {
+ // Default value for acksTo is anonymous (this happens only for the
+ // client side)
+ if (acksTo == null) {
acksTo = anonymousURI;
}
-
- acksToBean = new SequencePropertyBean(
- internalSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
+
+ acksToBean = new SequencePropertyBean(internalSequenceId, Sandesha2Constants.SequenceProperties.ACKS_TO_EPR,
acksTo);
-
- //start the in listner for the client side, if acksTo is not anonymous.
- if (!firstAplicationMsgCtx.isServerSide() && !anonymousURI.equals(acksTo)) {
-
+
+ // start the in listner for the client side, if acksTo is not anonymous.
+ if (!firstAplicationMsgCtx.isServerSide() && !anonymousURI.equals(acksTo)) {
+
String transportInProtocol = firstAplicationMsgCtx.getOptions().getTransportInProtocol();
- if (transportInProtocol==null) {
- throw new SandeshaException ("You must mention the transport in protocol for getting async acknowledgement messages");
- }
-
- try {
- ListenerManager listenerManager =
- firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
- TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext().getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
- //if acksTo is not anonymous start the in-transport
+ if (transportInProtocol == null) {
+ throw new SandeshaException(SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
+ }
+
+ try {
+ ListenerManager listenerManager = firstAplicationMsgCtx.getConfigurationContext().getListenerManager();
+ TransportInDescription transportIn = firstAplicationMsgCtx.getConfigurationContext()
+ .getAxisConfiguration().getTransportIn(new QName(transportInProtocol));
+ // if acksTo is not anonymous start the in-transport
if (!listenerManager.isListenerRunning(transportIn.getName().getLocalPart())) {
listenerManager.addListener(transportIn, false);
}
} catch (AxisFault e) {
- throw new SandeshaException ("Could not stast the transport listner",e);
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString()), e);
}
-
-
+
}
-
+
SequencePropertyBean msgsBean = new SequencePropertyBean();
msgsBean.setSequenceID(internalSequenceId);
msgsBean.setName(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES);
msgsBean.setValue("");
-
+
seqPropMgr.insert(msgsBean);
-
+
seqPropMgr.insert(toBean);
- if (acksToBean!=null)
+ if (acksToBean != null)
seqPropMgr.insert(acksToBean);
- if (replyToBean!=null)
+ if (replyToBean != null)
seqPropMgr.insert(replyToBean);
-
- //saving transportTo value;
+
+ // saving transportTo value;
String transportTo = (String) firstAplicationMsgCtx.getProperty(MessageContextConstants.TRANSPORT_URL);
- if (transportTo!=null) {
- SequencePropertyBean transportToBean = new SequencePropertyBean ();
+ if (transportTo != null) {
+ SequencePropertyBean transportToBean = new SequencePropertyBean();
transportToBean.setSequenceID(internalSequenceId);
transportToBean.setName(Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
transportToBean.setValue(transportTo);
-
+
seqPropMgr.insert(transportToBean);
}
-
- //setting the spec version for the client side.
- SequencePropertyBean specVerionBean = new SequencePropertyBean ();
+ // setting the spec version for the client side.
+ SequencePropertyBean specVerionBean = new SequencePropertyBean();
specVerionBean.setSequenceID(internalSequenceId);
specVerionBean.setName(Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION);
specVerionBean.setValue(specVersion);
seqPropMgr.insert(specVerionBean);
-
- //updating the last activated time.
- updateLastActivatedTime(internalSequenceId,storageManager);
-
- SandeshaUtil.startSenderForTheSequence(configurationContext,internalSequenceId);
-
-
-
- updateClientSideListnerIfNeeded (firstAplicationMsgCtx,anonymousURI);
-
+
+ // updating the last activated time.
+ updateLastActivatedTime(internalSequenceId, storageManager);
+
+ SandeshaUtil.startSenderForTheSequence(configurationContext, internalSequenceId);
+
+ updateClientSideListnerIfNeeded(firstAplicationMsgCtx, anonymousURI);
+
}
-
- private static void updateClientSideListnerIfNeeded (MessageContext messageContext, String addressingAnonymousURI) throws SandeshaException {
+
+ private static void updateClientSideListnerIfNeeded(MessageContext messageContext, String addressingAnonymousURI)
+ throws SandeshaException {
if (messageContext.isServerSide())
- return; //listners are updated only for the client side.
-
+ return; // listners are updated only for the client side.
+
String transportInProtocol = messageContext.getOptions().getTransportInProtocol();
-
+
String acksTo = (String) messageContext.getProperty(SandeshaClientConstants.AcksTo);
String mep = messageContext.getAxisOperation().getMessageExchangePattern();
-
+
boolean startListnerForAsyncAcks = false;
- boolean startListnerForAsyncControlMsgs = false; //For async createSerRes & terminateSeq.
-
- if (acksTo!=null && !addressingAnonymousURI.equals(acksTo)) {
- //starting listner for async acks.
+ boolean startListnerForAsyncControlMsgs = false; // For async
+ // createSerRes &
+ // terminateSeq.
+
+ if (acksTo != null && !addressingAnonymousURI.equals(acksTo)) {
+ // starting listner for async acks.
startListnerForAsyncAcks = true;
}
-
- if (mep!=null && !WSDL20_2004Constants.MEP_URI_OUT_ONLY.equals(mep)) {
- //starting listner for the async createSeqResponse & terminateSer messages.
+
+ if (mep != null && !WSDL20_2004Constants.MEP_URI_OUT_ONLY.equals(mep)) {
+ // starting listner for the async createSeqResponse & terminateSer
+ // messages.
startListnerForAsyncControlMsgs = true;
}
-
+
try {
- if ((startListnerForAsyncAcks || startListnerForAsyncControlMsgs) && transportInProtocol==null)
- throw new SandeshaException ("Cant start the listner since the TransportInProtocol is not set.");
-
+ if ((startListnerForAsyncAcks || startListnerForAsyncControlMsgs) && transportInProtocol == null)
+ throw new SandeshaException(SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.cannotStartListenerForIncommingMsgs));
+
} catch (AxisFault e) {
- String message = "Cant start the listner for incoming messages";
+ String message = SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.cannotStartTransportListenerDueToError, e.toString());
log.error(e.getStackTrace());
- throw new SandeshaException (message,e);
+ throw new SandeshaException(message, e);
}
-
+
}
-
+
/**
* Takes the internalSeqID as the param. Not the sequenceID.
+ *
* @param internalSequenceID
* @param configContext
* @throws SandeshaException
*/
- public static void updateLastActivatedTime (String propertyKey, StorageManager storageManager) throws SandeshaException {
- //Transaction lastActivatedTransaction = storageManager.getTransaction();
+ public static void updateLastActivatedTime(String propertyKey, StorageManager storageManager)
+ throws SandeshaException {
+ // Transaction lastActivatedTransaction =
+ // storageManager.getTransaction();
SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean lastActivatedBean = sequencePropertyBeanMgr.retrieve(propertyKey, Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
-
+
+ SequencePropertyBean lastActivatedBean = sequencePropertyBeanMgr.retrieve(propertyKey,
+ Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
+
boolean added = false;
-
- if (lastActivatedBean==null) {
+
+ if (lastActivatedBean == null) {
added = true;
- lastActivatedBean = new SequencePropertyBean ();
+ lastActivatedBean = new SequencePropertyBean();
lastActivatedBean.setSequenceID(propertyKey);
lastActivatedBean.setName(Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
}
-
+
long currentTime = System.currentTimeMillis();
lastActivatedBean.setValue(Long.toString(currentTime));
-
+
if (added)
sequencePropertyBeanMgr.insert(lastActivatedBean);
else
sequencePropertyBeanMgr.update(lastActivatedBean);
-
+
}
-
-
- public static long getLastActivatedTime (String propertyKey, StorageManager storageManager) throws SandeshaException {
-
+
+ public static long getLastActivatedTime(String propertyKey, StorageManager storageManager) throws SandeshaException {
+
SequencePropertyBeanMgr seqPropBeanMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean lastActivatedBean = seqPropBeanMgr.retrieve(propertyKey,Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
-
+
+ SequencePropertyBean lastActivatedBean = seqPropBeanMgr.retrieve(propertyKey,
+ Sandesha2Constants.SequenceProperties.LAST_ACTIVATED_TIME);
+
long lastActivatedTime = -1;
-
- if (lastActivatedBean!=null) {
+
+ if (lastActivatedBean != null) {
lastActivatedTime = Long.parseLong(lastActivatedBean.getValue());
}
-
+
return lastActivatedTime;
}
-
- public static boolean hasSequenceTimedOut (String propertyKey, RMMsgContext rmMsgCtx,StorageManager storageManager) throws SandeshaException {
-
- //operation is the lowest level, Sandesha2 could be engaged.
- SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(rmMsgCtx.getMessageContext().getAxisOperation());
-
- if (propertyBean.getInactiveTimeoutInterval()<=0)
+
+ public static boolean hasSequenceTimedOut(String propertyKey, RMMsgContext rmMsgCtx, StorageManager storageManager)
+ throws SandeshaException {
+
+ // operation is the lowest level, Sandesha2 could be engaged.
+ SandeshaPropertyBean propertyBean = SandeshaUtil.getPropertyBean(rmMsgCtx.getMessageContext()
+ .getAxisOperation());
+
+ if (propertyBean.getInactiveTimeoutInterval() <= 0)
return false;
boolean sequenceTimedOut = false;
-
- long lastActivatedTime = getLastActivatedTime(propertyKey,storageManager);
+
+ long lastActivatedTime = getLastActivatedTime(propertyKey, storageManager);
long timeNow = System.currentTimeMillis();
- if (lastActivatedTime>0 && (lastActivatedTime+propertyBean.getInactiveTimeoutInterval()<timeNow))
+ if (lastActivatedTime > 0 && (lastActivatedTime + propertyBean.getInactiveTimeoutInterval() < timeNow))
sequenceTimedOut = true;
-
+
return sequenceTimedOut;
}
-
- public static long getOutGoingSequenceAckedMessageCount (String internalSequenceID,StorageManager storageManager) throws SandeshaException {
-/// Transaction transaction = storageManager.getTransaction();
+
+ public static long getOutGoingSequenceAckedMessageCount(String internalSequenceID, StorageManager storageManager)
+ throws SandeshaException {
+ // / Transaction transaction = storageManager.getTransaction();
SequencePropertyBeanMgr seqPropBeanMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean findSeqIDBean = new SequencePropertyBean ();
+
+ SequencePropertyBean findSeqIDBean = new SequencePropertyBean();
findSeqIDBean.setValue(internalSequenceID);
findSeqIDBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
Collection seqIDBeans = seqPropBeanMgr.find(findSeqIDBean);
-
- if (seqIDBeans.size()==0) {
- String message = "A sequence with give data has not been created";
+
+ if (seqIDBeans.size() == 0) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noSequenceEstablished,
+ internalSequenceID);
log.debug(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
- if (seqIDBeans.size()>1) {
- String message = "Sequence data is not unique. Cant generate report";
+
+ if (seqIDBeans.size() > 1) {
+ String message = SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.cannotGenerateReportNonUniqueSequence, internalSequenceID);
log.debug(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
+
SequencePropertyBean seqIDBean = (SequencePropertyBean) seqIDBeans.iterator().next();
String sequenceID = seqIDBean.getSequenceID();
- SequencePropertyBean ackedMsgBean = seqPropBeanMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.NO_OF_OUTGOING_MSGS_ACKED);
- if (ackedMsgBean==null)
- return 0; //No acknowledgement has been received yet.
-
+ SequencePropertyBean ackedMsgBean = seqPropBeanMgr.retrieve(sequenceID,
+ Sandesha2Constants.SequenceProperties.NO_OF_OUTGOING_MSGS_ACKED);
+ if (ackedMsgBean == null)
+ return 0; // No acknowledgement has been received yet.
+
long noOfMessagesAcked = Long.parseLong(ackedMsgBean.getValue());
-/// transaction.commit();
-
+ // / transaction.commit();
+
return noOfMessagesAcked;
}
-
- public static boolean isOutGoingSequenceCompleted (String internalSequenceID,StorageManager storageManager) throws SandeshaException {
-/// Transaction transaction = storageManager.getTransaction();
+
+ public static boolean isOutGoingSequenceCompleted(String internalSequenceID, StorageManager storageManager)
+ throws SandeshaException {
+ // / Transaction transaction = storageManager.getTransaction();
SequencePropertyBeanMgr seqPropBeanMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean findSeqIDBean = new SequencePropertyBean ();
+
+ SequencePropertyBean findSeqIDBean = new SequencePropertyBean();
findSeqIDBean.setValue(internalSequenceID);
findSeqIDBean.setName(Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID);
Collection seqIDBeans = seqPropBeanMgr.find(findSeqIDBean);
-
- if (seqIDBeans.size()==0) {
- String message = "A sequence with give data has not been created";
+
+ if (seqIDBeans.size() == 0) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.noSequenceEstablished);
log.debug(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
- if (seqIDBeans.size()>1) {
- String message = "Sequence data is not unique. Cant generate report";
+
+ if (seqIDBeans.size() > 1) {
+ String message = SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.cannotGenerateReportNonUniqueSequence, internalSequenceID);
log.debug(message);
- throw new SandeshaException (message);
+ throw new SandeshaException(message);
}
-
+
SequencePropertyBean seqIDBean = (SequencePropertyBean) seqIDBeans.iterator().next();
String sequenceID = seqIDBean.getSequenceID();
-
- SequencePropertyBean terminateAddedBean = seqPropBeanMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
- if (terminateAddedBean==null)
+
+ SequencePropertyBean terminateAddedBean = seqPropBeanMgr.retrieve(sequenceID,
+ Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
+ if (terminateAddedBean == null)
return false;
-
+
if ("true".equals(terminateAddedBean.getValue()))
return true;
-/// transaction.commit();
+ // / transaction.commit();
return false;
}
-
- public static boolean isIncomingSequenceCompleted (String sequenceID, StorageManager storageManager) throws SandeshaException {
-
-/// Transaction transaction = storageManager.getTransaction();
+
+ public static boolean isIncomingSequenceCompleted(String sequenceID, StorageManager storageManager)
+ throws SandeshaException {
+
+ // / Transaction transaction = storageManager.getTransaction();
SequencePropertyBeanMgr seqPropBeanMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean terminateReceivedBean = seqPropBeanMgr.retrieve(sequenceID,Sandesha2Constants.SequenceProperties.TERMINATE_RECEIVED);
+
+ SequencePropertyBean terminateReceivedBean = seqPropBeanMgr.retrieve(sequenceID,
+ Sandesha2Constants.SequenceProperties.TERMINATE_RECEIVED);
boolean complete = false;
-
- if (terminateReceivedBean!=null && "true".equals(terminateReceivedBean.getValue()))
+
+ if (terminateReceivedBean != null && "true".equals(terminateReceivedBean.getValue()))
complete = true;
-
-/// transaction.commit();
+
+ // / transaction.commit();
return complete;
}
-
-
+
}
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SpecSpecificConstants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SpecSpecificConstants.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SpecSpecificConstants.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/SpecSpecificConstants.java Tue Jul 18 19:58:31 2006
@@ -17,9 +17,13 @@
package org.apache.sandesha2.util;
+import java.net.UnknownServiceException;
+
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.sandesha2.Sandesha2Constants;
import org.apache.sandesha2.SandeshaException;
+import org.apache.sandesha2.i18n.SandeshaMessageHelper;
+import org.apache.sandesha2.i18n.SandeshaMessageKeys;
/**
* To get values which are different in the RM specs in a convenient manner.
@@ -27,7 +31,6 @@
public class SpecSpecificConstants {
- private static String unknownSpecErrorMessage = "Unknown specification version";
public static String getSpecVersionString (String namespaceValue) throws SandeshaException {
if (Sandesha2Constants.SPEC_2005_02.NS_URI.equals(namespaceValue))
@@ -35,7 +38,9 @@
else if (Sandesha2Constants.SPEC_2005_10.NS_URI.equals(namespaceValue))
return Sandesha2Constants.SPEC_VERSIONS.v1_1;
else
- throw new SandeshaException ("Unknows rm namespace value");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ namespaceValue));
}
public static String getRMNamespaceValue (String specVersion) throws SandeshaException {
@@ -44,7 +49,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.NS_URI;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getCreateSequenceAction (String specVersion) throws SandeshaException {
@@ -53,7 +60,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CREATE_SEQUENCE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getCreateSequenceResponseAction (String specVersion) throws SandeshaException {
@@ -62,7 +71,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CREATE_SEQUENCE_RESPONSE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getTerminateSequenceAction (String specVersion) throws SandeshaException {
@@ -71,41 +82,56 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_TERMINATE_SEQUENCE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getTerminateSequenceResponseAction (String specVersion) throws SandeshaException {
if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_TERMINATE_SEQUENCE_RESPONSE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec));
}
public static String getCloseSequenceAction (String specVersion) throws SandeshaException {
if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(specVersion))
- throw new SandeshaException ("This rm spec version does not define a sequenceClose action");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.closeSequenceSpecLevel,
+ specVersion));
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CLOSE_SEQUENCE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getCloseSequenceResponseAction (String specVersion) throws SandeshaException {
if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(specVersion))
- throw new SandeshaException ("This rm spec version does not define a sequenceClose action");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.closeSequenceSpecLevel,
+ specVersion));
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_CLOSE_SEQUENCE_RESPONSE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getAckRequestAction (String specVersion) throws SandeshaException {
if (Sandesha2Constants.SPEC_VERSIONS.v1_0.equals(specVersion))
- throw new SandeshaException ("this spec version does not define a ackRequest action");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.emptyAckRequestSpecLevel,
+ specVersion));
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_ACK_REQUEST;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getSequenceAcknowledgementAction (String specVersion) throws SandeshaException {
@@ -114,7 +140,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.ACTION_SEQUENCE_ACKNOWLEDGEMENT;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getCreateSequenceSOAPAction (String specVersion) throws SandeshaException {
@@ -123,7 +151,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_CREATE_SEQUENCE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getCreateSequenceResponseSOAPAction (String specVersion) throws SandeshaException {
@@ -132,7 +162,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_CREATE_SEQUENCE_RESPONSE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getTerminateSequenceSOAPAction (String specVersion) throws SandeshaException {
@@ -141,14 +173,18 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_TERMINATE_SEQUENCE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getTerminateSequenceResponseSOAPAction (String specVersion) throws SandeshaException {
if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_TERMINATE_SEQUENCE_RESPONSE;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getAckRequestSOAPAction (String specVersion) throws SandeshaException {
@@ -157,7 +193,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_ACK_REQUEST;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getSequenceAcknowledgementSOAPAction (String specVersion) throws SandeshaException {
@@ -166,7 +204,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return Sandesha2Constants.SPEC_2005_10.Actions.SOAP_ACTION_SEQUENCE_ACKNOWLEDGEMENT;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static boolean isTerminateSequenceResponseRequired (String specVersion) throws SandeshaException {
@@ -175,7 +215,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return true;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static boolean isLastMessageIndicatorRequired (String specVersion) throws SandeshaException {
@@ -184,7 +226,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return false;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static boolean isAckFinalAllowed (String specVersion) throws SandeshaException {
@@ -193,7 +237,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return true;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static boolean isAckNoneAllowed (String specVersion) throws SandeshaException {
@@ -202,7 +248,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return true;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static boolean isSequenceClosingAllowed (String specVersion) throws SandeshaException {
@@ -211,7 +259,9 @@
else if (Sandesha2Constants.SPEC_VERSIONS.v1_1.equals(specVersion))
return true;
else
- throw new SandeshaException (unknownSpecErrorMessage);
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownSpec,
+ specVersion));
}
public static String getDefaultSpecVersion () {
@@ -224,7 +274,9 @@
else if (AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNSURI))
return AddressingConstants.Final.WSA_ANONYMOUS_URL;
else
- throw new SandeshaException ("Unknown addressing version");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownWSAVersion,
+ addressingNSURI));
}
public static String getAddressingFaultAction (String addressingNSURI) throws SandeshaException {
@@ -233,7 +285,9 @@
else if (AddressingConstants.Final.WSA_NAMESPACE.equals(addressingNSURI))
return AddressingConstants.Final.WSA_FAULT_ACTION;
else
- throw new SandeshaException ("Unknown addressing version");
+ throw new SandeshaException (SandeshaMessageHelper.getMessage(
+ SandeshaMessageKeys.unknownWSAVersion,
+ addressingNSURI));
}
}
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/util/TerminateManager.java Tue Jul 18 19:58:31 2006
@@ -34,6 +34,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.CreateSeqBeanMgr;
import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
@@ -48,59 +50,65 @@
import org.apache.sandesha2.transport.Sandesha2TransportOutDesc;
/**
- * Contains logic to remove all the storad data of a sequence.
- * Methods of this are called by sending side and the receiving side when appropriate
+ * Contains logic to remove all the storad data of a sequence. Methods of this
+ * are called by sending side and the receiving side when appropriate
*/
public class TerminateManager {
private static Log log = LogFactory.getLog(TerminateManager.class);
-
+
private static String CLEANED_ON_TERMINATE_MSG = "CleanedOnTerminateMsg";
+
private static String CLEANED_AFTER_INVOCATION = "CleanedAfterInvocation";
-
- public static HashMap receivingSideCleanMap = new HashMap ();
+
+ public static HashMap receivingSideCleanMap = new HashMap();
+
/**
- * Called by the receiving side to remove data related to a sequence.
- * e.g. After sending the TerminateSequence message. Calling this methods will complete all
- * the data if InOrder invocation is not sequired.
+ * Called by the receiving side to remove data related to a sequence. e.g.
+ * After sending the TerminateSequence message. Calling this methods will
+ * complete all the data if InOrder invocation is not sequired.
*
* @param configContext
* @param sequenceID
* @throws SandeshaException
*/
- public static void cleanReceivingSideOnTerminateMessage (ConfigurationContext configContext, String sequenceID,StorageManager storageManager) throws SandeshaException {
- //clean senderMap
-
- //Currently in-order invocation is done for default values.
- boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(configContext.getAxisConfiguration()).isInOrder();
-
- if(!inOrderInvocation) {
- //there is no invoking by Sandesha2. So clean invocations storages.
- cleanReceivingSideAfterInvocation(configContext,sequenceID,storageManager);
+ public static void cleanReceivingSideOnTerminateMessage(ConfigurationContext configContext, String sequenceID,
+ StorageManager storageManager) throws SandeshaException {
+ // clean senderMap
+
+ // Currently in-order invocation is done for default values.
+ boolean inOrderInvocation = SandeshaUtil.getDefaultPropertyBean(configContext.getAxisConfiguration())
+ .isInOrder();
+
+ if (!inOrderInvocation) {
+ // there is no invoking by Sandesha2. So clean invocations storages.
+ cleanReceivingSideAfterInvocation(configContext, sequenceID, storageManager);
}
String cleanStatus = (String) receivingSideCleanMap.get(sequenceID);
- if (cleanStatus!=null && CLEANED_AFTER_INVOCATION.equals(cleanStatus))
- completeTerminationOfReceivingSide(configContext,sequenceID,storageManager);
+ if (cleanStatus != null && CLEANED_AFTER_INVOCATION.equals(cleanStatus))
+ completeTerminationOfReceivingSide(configContext, sequenceID, storageManager);
else {
- receivingSideCleanMap.put(sequenceID,CLEANED_ON_TERMINATE_MSG);
+ receivingSideCleanMap.put(sequenceID, CLEANED_ON_TERMINATE_MSG);
}
}
-
+
/**
- * When InOrder invocation is anabled this had to be called to clean the data left by the
- * above method. This had to be called after the Invocation of the Last Message.
+ * When InOrder invocation is anabled this had to be called to clean the
+ * data left by the above method. This had to be called after the Invocation
+ * of the Last Message.
*
* @param configContext
* @param sequenceID
* @throws SandeshaException
*/
- public static void cleanReceivingSideAfterInvocation (ConfigurationContext configContext, String sequenceID,StorageManager storageManager) throws SandeshaException {
+ public static void cleanReceivingSideAfterInvocation(ConfigurationContext configContext, String sequenceID,
+ StorageManager storageManager) throws SandeshaException {
InvokerBeanMgr storageMapBeanMgr = storageManager.getStorageMapBeanMgr();
-
- //removing storageMap entries
- InvokerBean findStorageMapBean = new InvokerBean ();
+
+ // removing storageMap entries
+ InvokerBean findStorageMapBean = new InvokerBean();
findStorageMapBean.setSequenceID(sequenceID);
findStorageMapBean.setInvoked(true);
Collection collection = storageMapBeanMgr.find(findStorageMapBean);
@@ -108,76 +116,83 @@
while (iterator.hasNext()) {
InvokerBean storageMapBean = (InvokerBean) iterator.next();
storageMapBeanMgr.delete(storageMapBean.getMessageContextRefKey());
-
- //removing the respective message context from the message store. If this is an in-only message.
- //In-out message will be deleted when a ack is retrieved for the out message.
+
+ // removing the respective message context from the message store.
+ // If this is an in-only message.
+ // In-out message will be deleted when a ack is retrieved for the
+ // out message.
String messageStoreKey = storageMapBean.getMessageContextRefKey();
storageManager.removeMessageContext(messageStoreKey);
-
+
}
-
+
String cleanStatus = (String) receivingSideCleanMap.get(sequenceID);
- if (cleanStatus!=null && CLEANED_ON_TERMINATE_MSG.equals(cleanStatus))
- completeTerminationOfReceivingSide(configContext,sequenceID,storageManager);
+ if (cleanStatus != null && CLEANED_ON_TERMINATE_MSG.equals(cleanStatus))
+ completeTerminationOfReceivingSide(configContext, sequenceID, storageManager);
else {
- receivingSideCleanMap.put(sequenceID,CLEANED_AFTER_INVOCATION);
+ receivingSideCleanMap.put(sequenceID, CLEANED_AFTER_INVOCATION);
}
}
-
+
/**
- * This has to be called by the lastly invocated one of the above two methods.
- *
+ * This has to be called by the lastly invocated one of the above two
+ * methods.
+ *
*/
- private static void completeTerminationOfReceivingSide (ConfigurationContext configContext, String sequenceID,StorageManager storageManager) throws SandeshaException {
+ private static void completeTerminationOfReceivingSide(ConfigurationContext configContext, String sequenceID,
+ StorageManager storageManager) throws SandeshaException {
InvokerBeanMgr storageMapBeanMgr = storageManager.getStorageMapBeanMgr();
NextMsgBeanMgr nextMsgBeanMgr = storageManager.getNextMsgBeanMgr();
-
- //removing nextMsgMgr entries
- NextMsgBean findNextMsgBean = new NextMsgBean ();
+
+ // removing nextMsgMgr entries
+ NextMsgBean findNextMsgBean = new NextMsgBean();
findNextMsgBean.setSequenceID(sequenceID);
Collection collection = nextMsgBeanMgr.find(findNextMsgBean);
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
NextMsgBean nextMsgBean = (NextMsgBean) iterator.next();
-// nextMsgBeanMgr.delete(nextMsgBean.getSequenceID());
+ // nextMsgBeanMgr.delete(nextMsgBean.getSequenceID());
}
-
- //removing the HighestInMessage entry.
- String highestInMessageKey = SandeshaUtil.getSequenceProperty(sequenceID,Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY,storageManager);
- if (highestInMessageKey!=null) {
+
+ // removing the HighestInMessage entry.
+ String highestInMessageKey = SandeshaUtil.getSequenceProperty(sequenceID,
+ Sandesha2Constants.SequenceProperties.HIGHEST_IN_MSG_KEY, storageManager);
+ if (highestInMessageKey != null) {
storageManager.removeMessageContext(highestInMessageKey);
}
-
- removeReceivingSideProperties(configContext,sequenceID,storageManager);
+
+ removeReceivingSideProperties(configContext, sequenceID, storageManager);
}
- private static void removeReceivingSideProperties (ConfigurationContext configContext, String sequenceID,StorageManager storageManager) throws SandeshaException {
+ private static void removeReceivingSideProperties(ConfigurationContext configContext, String sequenceID,
+ StorageManager storageManager) throws SandeshaException {
SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
- SequencePropertyBean allSequenceBean = sequencePropertyBeanMgr.retrieve(Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
-
- if (allSequenceBean!=null) {
+ SequencePropertyBean allSequenceBean = sequencePropertyBeanMgr.retrieve(
+ Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
+ Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
+
+ if (allSequenceBean != null) {
log.debug("AllSequence bean is null");
-
+
ArrayList allSequenceList = SandeshaUtil.getArrayListFromString(allSequenceBean.getValue());
allSequenceList.remove(sequenceID);
-
- //updating
+
+ // updating
allSequenceBean.setValue(allSequenceList.toString());
sequencePropertyBeanMgr.update(allSequenceBean);
}
}
-
- private static boolean isRequiredForResponseSide (String name) {
- if (name==null && name.equals(Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO))
+
+ private static boolean isRequiredForResponseSide(String name) {
+ if (name == null && name.equals(Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO))
return false;
-
+
if (name.equals(Sandesha2Constants.SequenceProperties.LAST_OUT_MESSAGE_NO))
return false;
-
+
return false;
}
-
-
+
/**
* This is called by the sending side to clean data related to a sequence.
* e.g. after sending the TerminateSequence message.
@@ -186,124 +201,136 @@
* @param sequenceID
* @throws SandeshaException
*/
- public static void terminateSendingSide (ConfigurationContext configContext, String internalSequenceID,boolean serverSide,StorageManager storageManager) throws SandeshaException {
-
+ public static void terminateSendingSide(ConfigurationContext configContext, String internalSequenceID,
+ boolean serverSide, StorageManager storageManager) throws SandeshaException {
+
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
-
- SequencePropertyBean seqTerminatedBean = new SequencePropertyBean (internalSequenceID,Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED,Sandesha2Constants.VALUE_TRUE);
+
+ SequencePropertyBean seqTerminatedBean = new SequencePropertyBean(internalSequenceID,
+ Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED, Sandesha2Constants.VALUE_TRUE);
seqPropMgr.insert(seqTerminatedBean);
-
- cleanSendingSideData(configContext,internalSequenceID,serverSide,storageManager);
+
+ cleanSendingSideData(configContext, internalSequenceID, serverSide, storageManager);
}
-
- private static void doUpdatesIfNeeded (String sequenceID, SequencePropertyBean propertyBean, SequencePropertyBeanMgr seqPropMgr) throws SandeshaException {
-
+
+ private static void doUpdatesIfNeeded(String sequenceID, SequencePropertyBean propertyBean,
+ SequencePropertyBeanMgr seqPropMgr) throws SandeshaException {
+
boolean addEntryWithSequenceID = false;
-
+
if (propertyBean.getName().equals(Sandesha2Constants.SequenceProperties.CLIENT_COMPLETED_MESSAGES)) {
addEntryWithSequenceID = true;
}
-
+
if (propertyBean.getName().equals(Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED)) {
addEntryWithSequenceID = true;
}
-
+
if (propertyBean.getName().equals(Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED)) {
addEntryWithSequenceID = true;
}
-
+
if (propertyBean.getName().equals(Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT)) {
addEntryWithSequenceID = true;
}
-
- if (addEntryWithSequenceID && sequenceID!=null) {
- //this value cannot be completely deleted since this data will be needed by SequenceReports
- //so saving it with the sequenceID value being the out sequenceID.
-
- SequencePropertyBean newBean = new SequencePropertyBean ();
+
+ if (addEntryWithSequenceID && sequenceID != null) {
+ // this value cannot be completely deleted since this data will be
+ // needed by SequenceReports
+ // so saving it with the sequenceID value being the out sequenceID.
+
+ SequencePropertyBean newBean = new SequencePropertyBean();
newBean.setSequenceID(sequenceID);
newBean.setName(propertyBean.getName());
newBean.setValue(propertyBean.getValue());
seqPropMgr.insert(newBean);
- //TODO amazingly this property does not seem to get deleted without following - in the hibernate impl
- //(even though the lines efter current methodcall do this).
- seqPropMgr.delete (propertyBean.getSequenceID(),propertyBean.getName());
- }
+ // TODO amazingly this property does not seem to get deleted without
+ // following - in the hibernate impl
+ // (even though the lines efter current methodcall do this).
+ seqPropMgr.delete(propertyBean.getSequenceID(), propertyBean.getName());
+ }
}
-
- private static boolean isPropertyDeletable (String name) {
+
+ private static boolean isPropertyDeletable(String name) {
boolean deleatable = true;
-
+
if (Sandesha2Constants.SequenceProperties.TERMINATE_ADDED.equals(name))
deleatable = false;
-
+
if (Sandesha2Constants.SequenceProperties.NO_OF_OUTGOING_MSGS_ACKED.equals(name))
deleatable = false;
-
+
if (Sandesha2Constants.SequenceProperties.INTERNAL_SEQUENCE_ID.equals(name))
deleatable = false;
-
-// if (Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION.equals(name))
-// deleatable = false;
-
+
+ // if
+ // (Sandesha2Constants.SequenceProperties.RM_SPEC_VERSION.equals(name))
+ // deleatable = false;
+
if (Sandesha2Constants.SequenceProperties.SEQUENCE_TERMINATED.equals(name))
deleatable = false;
-
+
if (Sandesha2Constants.SequenceProperties.SEQUENCE_CLOSED.equals(name))
deleatable = false;
-
+
if (Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT.equals(name))
deleatable = false;
-
+
return deleatable;
}
-
- public static void timeOutSendingSideSequence (ConfigurationContext context,String internalSequenceID, boolean serverside,StorageManager storageManager) throws SandeshaException {
-
+
+ public static void timeOutSendingSideSequence(ConfigurationContext context, String internalSequenceID,
+ boolean serverside, StorageManager storageManager) throws SandeshaException {
+
SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
- SequencePropertyBean seqTerminatedBean = new SequencePropertyBean (internalSequenceID,Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT,Sandesha2Constants.VALUE_TRUE);
+ SequencePropertyBean seqTerminatedBean = new SequencePropertyBean(internalSequenceID,
+ Sandesha2Constants.SequenceProperties.SEQUENCE_TIMED_OUT, Sandesha2Constants.VALUE_TRUE);
seqPropMgr.insert(seqTerminatedBean);
-
- cleanSendingSideData(context,internalSequenceID,serverside,storageManager);
+
+ cleanSendingSideData(context, internalSequenceID, serverside, storageManager);
}
-
- private static void cleanSendingSideData (ConfigurationContext configContext,String internalSequenceID, boolean serverSide,StorageManager storageManager) throws SandeshaException {
-
+
+ private static void cleanSendingSideData(ConfigurationContext configContext, String internalSequenceID,
+ boolean serverSide, StorageManager storageManager) throws SandeshaException {
+
SequencePropertyBeanMgr sequencePropertyBeanMgr = storageManager.getSequencePropertyBeanMgr();
SenderBeanMgr retransmitterBeanMgr = storageManager.getRetransmitterBeanMgr();
CreateSeqBeanMgr createSeqBeanMgr = storageManager.getCreateSeqBeanMgr();
-
- String outSequenceID = SandeshaUtil.getSequenceProperty(internalSequenceID,Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID,storageManager);
-
+
+ String outSequenceID = SandeshaUtil.getSequenceProperty(internalSequenceID,
+ Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);
+
if (!serverSide) {
boolean stopListnerForAsyncAcks = false;
- SequencePropertyBean acksToBean = sequencePropertyBeanMgr.retrieve(internalSequenceID,Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
-
- String addressingNamespace = SandeshaUtil.getSequenceProperty(internalSequenceID,Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE,storageManager);
+ SequencePropertyBean acksToBean = sequencePropertyBeanMgr.retrieve(internalSequenceID,
+ Sandesha2Constants.SequenceProperties.ACKS_TO_EPR);
+
+ String addressingNamespace = SandeshaUtil.getSequenceProperty(internalSequenceID,
+ Sandesha2Constants.SequenceProperties.ADDRESSING_NAMESPACE_VALUE, storageManager);
String anonymousURI = SpecSpecificConstants.getAddressingAnonymousURI(addressingNamespace);
-
- if (acksToBean!=null) {
+
+ if (acksToBean != null) {
String acksTo = acksToBean.getValue();
- if (acksTo!=null && !anonymousURI.equals(acksTo)) {
+ if (acksTo != null && !anonymousURI.equals(acksTo)) {
stopListnerForAsyncAcks = true;
}
}
}
-
- //removing retransmitterMgr entries and corresponding message contexts.
+
+ // removing retransmitterMgr entries and corresponding message contexts.
Collection collection = retransmitterBeanMgr.find(internalSequenceID);
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
SenderBean retransmitterBean = (SenderBean) iterator.next();
retransmitterBeanMgr.delete(retransmitterBean.getMessageID());
-
+
String messageStoreKey = retransmitterBean.getMessageContextRefKey();
storageManager.removeMessageContext(messageStoreKey);
}
-
- //removing the createSeqMgrEntry
- CreateSeqBean findCreateSequenceBean = new CreateSeqBean ();
+
+ // removing the createSeqMgrEntry
+ CreateSeqBean findCreateSequenceBean = new CreateSeqBean();
findCreateSequenceBean.setInternalSequenceID(internalSequenceID);
collection = createSeqBeanMgr.find(findCreateSequenceBean);
iterator = collection.iterator();
@@ -311,73 +338,74 @@
CreateSeqBean createSeqBean = (CreateSeqBean) iterator.next();
createSeqBeanMgr.delete(createSeqBean.getCreateSeqMsgID());
}
-
- //removing sequence properties
- SequencePropertyBean findSequencePropertyBean1 = new SequencePropertyBean ();
+
+ // removing sequence properties
+ SequencePropertyBean findSequencePropertyBean1 = new SequencePropertyBean();
findSequencePropertyBean1.setSequenceID(internalSequenceID);
collection = sequencePropertyBeanMgr.find(findSequencePropertyBean1);
iterator = collection.iterator();
while (iterator.hasNext()) {
SequencePropertyBean sequencePropertyBean = (SequencePropertyBean) iterator.next();
- doUpdatesIfNeeded (outSequenceID,sequencePropertyBean,sequencePropertyBeanMgr);
-
- //TODO all properties which hv the temm:Seq:id as the key should be deletable.
+ doUpdatesIfNeeded(outSequenceID, sequencePropertyBean, sequencePropertyBeanMgr);
+
+ // TODO all properties which hv the temm:Seq:id as the key should be
+ // deletable.
if (isPropertyDeletable(sequencePropertyBean.getName())) {
- sequencePropertyBeanMgr.delete(sequencePropertyBean.getSequenceID(),sequencePropertyBean.getName());
+ sequencePropertyBeanMgr.delete(sequencePropertyBean.getSequenceID(), sequencePropertyBean.getName());
}
}
}
-
- public static void addTerminateSequenceMessage(RMMsgContext referenceMessage,
- String outSequenceId, String internalSequenceId,StorageManager storageManager)
- throws SandeshaException {
+
+ public static void addTerminateSequenceMessage(RMMsgContext referenceMessage, String outSequenceId,
+ String internalSequenceId, StorageManager storageManager) throws SandeshaException {
ConfigurationContext configurationContext = referenceMessage.getMessageContext().getConfigurationContext();
-/// Transaction addTerminateSeqTransaction = storageManager.getTransaction();
-
- SequencePropertyBeanMgr seqPropMgr = storageManager
- .getSequencePropertyBeanMgr();
+ // / Transaction addTerminateSeqTransaction =
+ // storageManager.getTransaction();
+
+ SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();
SequencePropertyBean terminated = seqPropMgr.retrieve(outSequenceId,
Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
- if (terminated != null && terminated.getValue() != null
- && "true".equals(terminated.getValue())) {
+ if (terminated != null && terminated.getValue() != null && "true".equals(terminated.getValue())) {
String message = "Terminate was added previously.";
- log.debug (message);
+ log.debug(message);
}
- RMMsgContext terminateRMMessage = RMMsgCreator
- .createTerminateSequenceMessage(referenceMessage, outSequenceId,internalSequenceId,storageManager);
+ RMMsgContext terminateRMMessage = RMMsgCreator.createTerminateSequenceMessage(referenceMessage, outSequenceId,
+ internalSequenceId, storageManager);
terminateRMMessage.setFlow(MessageContext.OUT_FLOW);
- terminateRMMessage.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE,"true");
-
+ terminateRMMessage.setProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE, "true");
+
SequencePropertyBean toBean = seqPropMgr.retrieve(internalSequenceId,
Sandesha2Constants.SequenceProperties.TO_EPR);
- EndpointReference toEPR = new EndpointReference ( toBean.getValue());
+ EndpointReference toEPR = new EndpointReference(toBean.getValue());
if (toEPR == null) {
- String message = "To EPR has an invalid value";
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.toEPRNotValid, null);
throw new SandeshaException(message);
}
terminateRMMessage.setTo(new EndpointReference(toEPR.getAddress()));
-
- 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);
-
- 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.cannotDecideRMVersion));
terminateRMMessage.setWSAAction(SpecSpecificConstants.getTerminateSequenceAction(rmVersion));
terminateRMMessage.setSOAPAction(SpecSpecificConstants.getTerminateSequenceSOAPAction(rmVersion));
- SequencePropertyBean transportToBean = seqPropMgr.retrieve(internalSequenceId,Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
- if (transportToBean!=null) {
- terminateRMMessage.setProperty(MessageContextConstants.TRANSPORT_URL,transportToBean.getValue());
+ SequencePropertyBean transportToBean = seqPropMgr.retrieve(internalSequenceId,
+ Sandesha2Constants.SequenceProperties.TRANSPORT_TO);
+ if (transportToBean != null) {
+ terminateRMMessage.setProperty(MessageContextConstants.TRANSPORT_URL, transportToBean.getValue());
}
-
+
try {
terminateRMMessage.addSOAPEnvelope();
} catch (AxisFault e) {
@@ -385,55 +413,53 @@
}
String key = SandeshaUtil.getUUID();
-
+
SenderBean terminateBean = new SenderBean();
terminateBean.setMessageContextRefKey(key);
-
- storageManager.storeMessageContext(key,terminateRMMessage.getMessageContext());
-
- //Set a retransmitter lastSentTime so that terminate will be send with
+ storageManager.storeMessageContext(key, terminateRMMessage.getMessageContext());
+
+ // Set a retransmitter lastSentTime so that terminate will be send with
// some delay.
- //Otherwise this get send before return of the current request (ack).
- //TODO: refine the terminate delay.
- terminateBean.setTimeToSend(System.currentTimeMillis()
- + Sandesha2Constants.TERMINATE_DELAY);
+ // Otherwise this get send before return of the current request (ack).
+ // TODO: refine the terminate delay.
+ terminateBean.setTimeToSend(System.currentTimeMillis() + Sandesha2Constants.TERMINATE_DELAY);
terminateBean.setMessageID(terminateRMMessage.getMessageId());
-
- //this will be set to true at the sender.
+
+ // this will be set to true at the sender.
terminateBean.setSend(true);
-
+
terminateRMMessage.getMessageContext().setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING,
Sandesha2Constants.VALUE_FALSE);
-
+
terminateBean.setReSend(false);
SenderBeanMgr retramsmitterMgr = storageManager.getRetransmitterBeanMgr();
retramsmitterMgr.insert(terminateBean);
-
+
SequencePropertyBean terminateAdded = new SequencePropertyBean();
terminateAdded.setName(Sandesha2Constants.SequenceProperties.TERMINATE_ADDED);
terminateAdded.setSequenceID(outSequenceId);
terminateAdded.setValue("true");
seqPropMgr.insert(terminateAdded);
-
- //This should be dumped to the storage by the sender
+
+ // This should be dumped to the storage by the sender
TransportOutDescription transportOut = terminateRMMessage.getMessageContext().getTransportOut();
- terminateRMMessage.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC,transportOut);
- terminateRMMessage.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY,key);
- terminateRMMessage.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE,Sandesha2Constants.VALUE_TRUE);
- terminateRMMessage.getMessageContext().setTransportOut(new Sandesha2TransportOutDesc ());
-/// addTerminateSeqTransaction.commit();
-
- AxisEngine engine = new AxisEngine (configurationContext);
- try {
+ terminateRMMessage.setProperty(Sandesha2Constants.ORIGINAL_TRANSPORT_OUT_DESC, transportOut);
+ terminateRMMessage.setProperty(Sandesha2Constants.MESSAGE_STORE_KEY, key);
+ terminateRMMessage.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
+ terminateRMMessage.getMessageContext().setTransportOut(new Sandesha2TransportOutDesc());
+ // / addTerminateSeqTransaction.commit();
+
+ AxisEngine engine = new AxisEngine(configurationContext);
+ try {
engine.send(terminateRMMessage.getMessageContext());
} catch (AxisFault e) {
- throw new SandeshaException (e.getMessage());
+ throw new SandeshaException(e.getMessage());
}
}
-
+
}
Modified: webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InOrderInvoker.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InOrderInvoker.java?rev=423350&r1=423349&r2=423350&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InOrderInvoker.java (original)
+++ webservices/sandesha/trunk/java/src/org/apache/sandesha2/workers/InOrderInvoker.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.Transaction;
import org.apache.sandesha2.storage.beanmanagers.InvokerBeanMgr;
@@ -43,111 +45,112 @@
import org.apache.sandesha2.wsrm.Sequence;
/**
- * This is used when InOrder invocation is required. This is a seperated Thread that keep running
- * all the time. At each iteration it checks the InvokerTable to find weather there are any messages to
- * me invoked.
+ * This is used when InOrder invocation is required. This is a seperated Thread
+ * that keep running all the time. At each iteration it checks the InvokerTable
+ * to find weather there are any messages to me invoked.
*/
public class InOrderInvoker extends Thread {
-
+
private boolean runInvoker = false;
+
private ArrayList workingSequences = new ArrayList();
+
private ConfigurationContext context = null;
+
private static final Log log = LogFactory.getLog(InOrderInvoker.class);
+
private boolean hasStopped = false;
-
+
public synchronized void stopInvokerForTheSequence(String sequenceID) {
- if (log.isDebugEnabled())
- log.debug("Enter: InOrderInvoker::stopInvokerForTheSequence, "+sequenceID);
+ if (log.isDebugEnabled())
+ log.debug("Enter: InOrderInvoker::stopInvokerForTheSequence, " + sequenceID);
workingSequences.remove(sequenceID);
- if (workingSequences.size()==0) {
+ if (workingSequences.size() == 0) {
runInvoker = false;
}
-
- if (log.isDebugEnabled())
- log.debug("Exit: InOrderInvoker::stopInvokerForTheSequence");
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: InOrderInvoker::stopInvokerForTheSequence");
}
-
- public synchronized void stopInvoking () {
- if (log.isDebugEnabled())
- log.debug("Enter: InOrderInvoker::stopInvoking");
-
- if(isInvokerStarted()){
- //the invoker is started so stop it
+
+ public synchronized void stopInvoking() {
+ if (log.isDebugEnabled())
+ log.debug("Enter: InOrderInvoker::stopInvoking");
+
+ if (isInvokerStarted()) {
+ // the invoker is started so stop it
runInvoker = false;
- //wait for it to finish
- while(!hasStoppedInvoking()){
+ // wait for it to finish
+ while (!hasStoppedInvoking()) {
try {
wait(Sandesha2Constants.INVOKER_SLEEP_TIME);
- }
- catch (InterruptedException e1) {
- log.debug(e1.getMessage());
+ } catch (InterruptedException e1) {
+ log.debug(e1.getMessage());
}
}
}
-
- if (log.isDebugEnabled())
- log.debug("Exit: InOrderInvoker::stopInvoking");
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: InOrderInvoker::stopInvoking");
}
public synchronized boolean isInvokerStarted() {
- if (log.isDebugEnabled())
- {
- log.debug("Enter: InOrderInvoker::isInvokerStarted");
- log.debug("Exit: InOrderInvoker::isInvokerStarted, " + runInvoker);
- }
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: InOrderInvoker::isInvokerStarted");
+ log.debug("Exit: InOrderInvoker::isInvokerStarted, " + runInvoker);
+ }
return runInvoker;
}
public synchronized void runInvokerForTheSequence(ConfigurationContext context, String sequenceID) {
- if (log.isDebugEnabled())
- log.debug("Enter: InOrderInvoker::runInvokerForTheSequence");
-
+ if (log.isDebugEnabled())
+ log.debug("Enter: InOrderInvoker::runInvokerForTheSequence");
+
if (!workingSequences.contains(sequenceID))
workingSequences.add(sequenceID);
if (!isInvokerStarted()) {
this.context = context;
- runInvoker = true; //so that isSenderStarted()=true.
+ runInvoker = true; // so that isSenderStarted()=true.
super.start();
}
- if (log.isDebugEnabled())
- log.debug("Exit: InOrderInvoker::runInvokerForTheSequence");
+ if (log.isDebugEnabled())
+ log.debug("Exit: InOrderInvoker::runInvokerForTheSequence");
}
-
- private synchronized boolean hasStoppedInvoking(){
- if (log.isDebugEnabled())
- {
- log.debug("Enter: InOrderInvoker::hasStoppedInvoking");
- log.debug("Exit: InOrderInvoker::hasStoppedInvoking, " + hasStopped);
- }
+
+ private synchronized boolean hasStoppedInvoking() {
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: InOrderInvoker::hasStoppedInvoking");
+ log.debug("Exit: InOrderInvoker::hasStoppedInvoking, " + hasStopped);
+ }
return hasStopped;
}
- public void run(){
- if (log.isDebugEnabled())
- log.debug("Enter: InOrderInvoker::run");
-
- try{
- internalRun();
- }
- finally{
- //flag that we have exited the run loop and notify any waiting threads
- synchronized(this){
- hasStopped = true;
- notify();
- }
- }
-
- if (log.isDebugEnabled())
- log.debug("Exit: InOrderInvoker::run");
+ public void run() {
+ if (log.isDebugEnabled())
+ log.debug("Enter: InOrderInvoker::run");
+
+ try {
+ internalRun();
+ } finally {
+ // flag that we have exited the run loop and notify any waiting
+ // threads
+ synchronized (this) {
+ hasStopped = true;
+ notify();
+ }
+ }
+
+ if (log.isDebugEnabled())
+ log.debug("Exit: InOrderInvoker::run");
}
-
+
private void internalRun() {
- if (log.isDebugEnabled())
- log.debug("Enter: InOrderInvoker::internalRun");
-
+ if (log.isDebugEnabled())
+ log.debug("Enter: InOrderInvoker::internalRun");
+
while (isInvokerStarted()) {
try {
@@ -159,135 +162,142 @@
Transaction transaction = null;
boolean rolebacked = false;
-
+
try {
- StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context,context.getAxisConfiguration());
+ StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(context, context
+ .getAxisConfiguration());
NextMsgBeanMgr nextMsgMgr = storageManager.getNextMsgBeanMgr();
InvokerBeanMgr storageMapMgr = storageManager.getStorageMapBeanMgr();
- SequencePropertyBeanMgr sequencePropMgr = storageManager
- .getSequencePropertyBeanMgr();
+ SequencePropertyBeanMgr sequencePropMgr = storageManager.getSequencePropertyBeanMgr();
transaction = storageManager.getTransaction();
-
- //Getting the incomingSequenceIdList
- SequencePropertyBean allSequencesBean = sequencePropMgr
- .retrieve(
- Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
- Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
-
+
+ // Getting the incomingSequenceIdList
+ SequencePropertyBean allSequencesBean = sequencePropMgr.retrieve(
+ Sandesha2Constants.SequenceProperties.ALL_SEQUENCES,
+ Sandesha2Constants.SequenceProperties.INCOMING_SEQUENCE_LIST);
+
if (allSequencesBean == null) {
- if (log.isDebugEnabled())
- log.debug("AllSequencesBean not found");
+ if (log.isDebugEnabled())
+ log.debug("AllSequencesBean not found");
continue;
}
- ArrayList allSequencesList = SandeshaUtil.getArrayListFromString (allSequencesBean.getValue());
-
+ ArrayList allSequencesList = SandeshaUtil.getArrayListFromString(allSequencesBean.getValue());
+
Iterator allSequencesItr = allSequencesList.iterator();
-
+
currentIteration: while (allSequencesItr.hasNext()) {
String sequenceId = (String) allSequencesItr.next();
-
- //commiting the old transaction
+
+ // commiting the old transaction
transaction.commit();
-
- //starting a new transaction for the new iteration.
+
+ // starting a new transaction for the new iteration.
transaction = storageManager.getTransaction();
-
+
NextMsgBean nextMsgBean = nextMsgMgr.retrieve(sequenceId);
if (nextMsgBean == null) {
String message = "Next message not set correctly. Removing invalid entry.";
log.debug(message);
allSequencesItr.remove();
-
- //cleaning the invalid data of the all sequences.
+
+ // cleaning the invalid data of the all sequences.
allSequencesBean.setValue(allSequencesList.toString());
- sequencePropMgr.update(allSequencesBean);
+ sequencePropMgr.update(allSequencesBean);
continue;
}
long nextMsgno = nextMsgBean.getNextMsgNoToProcess();
- if (nextMsgno <= 0) {
- if (log.isDebugEnabled())
- log.debug("Invalid Next Message Number " + nextMsgno);
- String message = "Invalid message number as the Next Message Number.";
+ if (nextMsgno <= 0) {
+ if (log.isDebugEnabled())
+ log.debug("Invalid Next Message Number " + nextMsgno);
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invalidMsgNumber, Long
+ .toString(nextMsgno));
throw new SandeshaException(message);
}
- Iterator stMapIt = storageMapMgr.find(
- new InvokerBean(null, nextMsgno, sequenceId))
- .iterator();
-
+ Iterator stMapIt = storageMapMgr.find(new InvokerBean(null, nextMsgno, sequenceId)).iterator();
+
boolean invoked = false;
-
+
while (stMapIt.hasNext()) {
InvokerBean stMapBean = (InvokerBean) stMapIt.next();
String key = stMapBean.getMessageContextRefKey();
- MessageContext msgToInvoke = storageManager.retrieveMessageContext(key,context);
+ MessageContext msgToInvoke = storageManager.retrieveMessageContext(key, context);
RMMsgContext rmMsg = MsgInitializer.initializeMessage(msgToInvoke);
- //have to commit the transaction before invoking. This may get changed when WS-AT is available.
+ // have to commit the transaction before invoking. This
+ // may get changed when WS-AT is available.
transaction.commit();
-
+
try {
- //Invoking the message.
- msgToInvoke.setProperty(Sandesha2Constants.WITHIN_TRANSACTION,Sandesha2Constants.VALUE_TRUE);
-
+ // Invoking the message.
+ msgToInvoke.setProperty(Sandesha2Constants.WITHIN_TRANSACTION,
+ Sandesha2Constants.VALUE_TRUE);
+
boolean postFailureInvocation = false;
-
- //StorageManagers should st following property to true, to indicate that the message received comes after a failure.
- String postFaulureProperty = (String) msgToInvoke.getProperty(Sandesha2Constants.POST_FAILURE_MESSAGE);
- if (postFaulureProperty!=null && Sandesha2Constants.VALUE_TRUE.equals(postFaulureProperty))
- postFailureInvocation = true;
-
- AxisEngine engine = new AxisEngine (context);
+
+ // StorageManagers should st following property to
+ // true, to indicate that the message received comes
+ // after a failure.
+ String postFaulureProperty = (String) msgToInvoke
+ .getProperty(Sandesha2Constants.POST_FAILURE_MESSAGE);
+ if (postFaulureProperty != null
+ && Sandesha2Constants.VALUE_TRUE.equals(postFaulureProperty))
+ postFailureInvocation = true;
+
+ AxisEngine engine = new AxisEngine(context);
if (postFailureInvocation) {
- makeMessageReadyForReinjection (msgToInvoke);
+ makeMessageReadyForReinjection(msgToInvoke);
if (log.isDebugEnabled())
- log.debug("Receiving message, key=" + key +", msgCtx=" + msgToInvoke.getEnvelope().getHeader());
+ log.debug("Receiving message, key=" + key + ", msgCtx="
+ + msgToInvoke.getEnvelope().getHeader());
engine.receive(msgToInvoke);
} else {
if (log.isDebugEnabled())
- log.debug("Resuming message, key=" + key +", msgCtx=" + msgToInvoke.getEnvelope().getHeader());
+ log.debug("Resuming message, key=" + key + ", msgCtx="
+ + msgToInvoke.getEnvelope().getHeader());
msgToInvoke.setPaused(false);
engine.resumeReceive(msgToInvoke);
}
-
+
invoked = true;
} catch (Exception e) {
- if (log.isDebugEnabled())
- log.debug("Exception :", e);
-
- handleFault(msgToInvoke,e);
-
-// throw new SandeshaException(e);
+ if (log.isDebugEnabled())
+ log.debug("Exception :", e);
+
+ handleFault(msgToInvoke, e);
+
+ // throw new SandeshaException(e);
} finally {
transaction = storageManager.getTransaction();
}
-
- //Service will be invoked only once. I.e. even if an exception get thrown in invocation
- //the service will not be invoked again.
+
+ // Service will be invoked only once. I.e. even if an
+ // exception get thrown in invocation
+ // the service will not be invoked again.
storageMapMgr.delete(key);
-
- //removing the corresponding message context as well.
- MessageContext msgCtx = storageManager.retrieveMessageContext(key,context);
- if (msgCtx!=null) {
+
+ // removing the corresponding message context as well.
+ MessageContext msgCtx = storageManager.retrieveMessageContext(key, context);
+ if (msgCtx != null) {
storageManager.removeMessageContext(key);
}
-
-
- //undating the next msg to invoke
+
+ // undating the next msg to invoke
if (rmMsg.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION) {
Sequence sequence = (Sequence) rmMsg
.getMessagePart(Sandesha2Constants.MessageParts.SEQUENCE);
if (sequence.getLastMessage() != null) {
- TerminateManager.cleanReceivingSideAfterInvocation(context, sequenceId,storageManager);
- //exit from current iteration. (since an entry was removed)
+ TerminateManager.cleanReceivingSideAfterInvocation(context, sequenceId, storageManager);
+ // exit from current iteration. (since an entry
+ // was removed)
break currentIteration;
}
}
@@ -297,49 +307,51 @@
nextMsgno++;
nextMsgBean.setNextMsgNoToProcess(nextMsgno);
nextMsgMgr.update(nextMsgBean);
- }
+ }
}
-
- } catch (Exception e) {
- if (transaction!=null) {
+
+ } catch (Exception e) {
+ if (transaction != null) {
try {
transaction.rollback();
rolebacked = true;
} catch (Exception e1) {
- String message = "Exception thrown when trying to roleback the transaction.";
- log.debug(message,e1);
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.rollbackError, e1
+ .toString());
+ log.debug(message, e1);
}
}
- String message = "Sandesha2 got an exception when trying to invoke the message";
- log.debug(message,e);
- } finally {
- if (!rolebacked && transaction!=null) {
+ String message = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.invokeMsgError);
+ log.debug(message, e);
+ } finally {
+ if (!rolebacked && transaction != null) {
try {
transaction.commit();
} catch (Exception e) {
- String message = "Exception thrown when trying to commit the transaction.";
- log.debug(message,e);
+ String message = SandeshaMessageHelper
+ .getMessage(SandeshaMessageKeys.commitError, e.toString());
+ log.debug(message, e);
}
}
}
}
- if (log.isDebugEnabled())
- log.debug("Exit: InOrderInvoker::internalRun");
+ if (log.isDebugEnabled())
+ log.debug("Exit: InOrderInvoker::internalRun");
}
-
- private void makeMessageReadyForReinjection (MessageContext messageContext) {
- messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,null);
+
+ private void makeMessageReadyForReinjection(MessageContext messageContext) {
+ messageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION, null);
messageContext.getOptions().setMessageId(null);
messageContext.getOptions().setTo(null);
messageContext.getOptions().setAction(null);
- messageContext.setProperty(Sandesha2Constants.REINJECTED_MESSAGE,Sandesha2Constants.VALUE_TRUE);
+ messageContext.setProperty(Sandesha2Constants.REINJECTED_MESSAGE, Sandesha2Constants.VALUE_TRUE);
}
-
- private void handleFault(MessageContext inMsgContext,Exception e) throws Exception {
- // msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
+
+ private void handleFault(MessageContext inMsgContext, Exception e) throws Exception {
+ // msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);
AxisEngine engine = new AxisEngine(inMsgContext.getConfigurationContext());
MessageContext faultContext = engine.createFaultMessageContext(inMsgContext, e);
engine.sendFault(faultContext);
}
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org