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 mc...@apache.org on 2008/06/23 14:28:53 UTC
svn commit: r670538 - in
/webservices/sandesha/trunk/java/modules/core/src/main:
java/org/apache/sandesha2/client/ java/org/apache/sandesha2/i18n/
java/org/apache/sandesha2/msgprocessors/ java/org/apache/sandesha2/util/
resources/org/apache/sandesha2/i...
Author: mckierna
Date: Mon Jun 23 05:28:53 2008
New Revision: 670538
URL: http://svn.apache.org/viewvc?rev=670538&view=rev
Log:
forbid mixed EPR types on a sequence https://issues.apache.org/jira/browse/SANDESHA2-160
Modified:
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClientConstants.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClientConstants.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClientConstants.java?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClientConstants.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/client/SandeshaClientConstants.java Mon Jun 23 05:28:53 2008
@@ -38,4 +38,5 @@
public static final String OFFERED_ENDPOINT = "OfferedEndpoint";
public static final String AVOID_AUTO_TERMINATION = "AviodAutoTermination";
public static final String AUTO_START_NEW_SEQUENCE = "AutoStartNewSequence";
+ public static final String FORBID_MIXED_EPRS_ON_SEQUENCE = "ForbidMixedEPRsOnSequence";//if true means a sequence will not disallow both sync and async clients
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/i18n/SandeshaMessageKeys.java Mon Jun 23 05:28:53 2008
@@ -49,6 +49,7 @@
public static final String cannotSendMsgAsSequenceClosed="cannotSendMsgAsSequenceClosed";
public static final String cannotSendMsgAsSequenceTerminated="cannotSendMsgAsSequenceTerminated";
public static final String cannotSendMsgAsSequenceTimedout="cannotSendMsgAsSequenceTimedout";
+ public static final String cannotSendMsgAsEPRWrong = "cannotSendMsgAsEPRWrong";
public static final String noValidSyncResponse="noValidSyncResponse";
public static final String classLoaderNotFound="classLoaderNotFound";
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/msgprocessors/ApplicationMsgProcessor.java Mon Jun 23 05:28:53 2008
@@ -23,6 +23,7 @@
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axis2.addressing.AddressingHelper;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.context.ConfigurationContext;
@@ -169,12 +170,17 @@
* side - a derivation of wsaTo & SeequenceKey
*/
String internalSequenceId = getSequenceID(rmMsgCtx, serverSide, false); //get a sequenceID, possibly pre-existing
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::internalSequenceId = " + internalSequenceId);
boolean lastMessage = false;
if(!serverSide){
String lastAppMessage = (String) msgContext.getProperty(SandeshaClientConstants.LAST_MESSAGE);
- if (lastAppMessage != null && "true".equals(lastAppMessage))
+ if (lastAppMessage != null && "true".equals(lastAppMessage)){
lastMessage = true;
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor: last message");
+ }
}
if (internalSequenceId!=null)
@@ -208,23 +214,44 @@
RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(storageManager, internalSequenceId);
- //see if the sequence is closed
- if(rmsBean != null &&
- (rmsBean.isSequenceClosedClient() || rmsBean.isTerminateAdded() || rmsBean.isTimedOut())){
- if(SandeshaUtil.isAutoStartNewSequence(msgContext)){
- internalSequenceId = getSequenceID(rmMsgCtx, serverSide, true); //require a new sequence
- rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceId);
- }
- else if(rmsBean.isSequenceClosedClient()){
- throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceClosed, internalSequenceId));
- }
- else if(rmsBean.isTerminateAdded()){
- throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTerminated, internalSequenceId));
- }
- else if(rmsBean.isTimedOut()){
- throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTimedout, internalSequenceId));
+ //if this is an existing sequence then we need to do some checks first
+ if(rmsBean != null)
+ {
+ //see if the sequence is closed
+ if(rmsBean.isSequenceClosedClient() || rmsBean.isTerminateAdded() || rmsBean.isTimedOut()){
+ if(SandeshaUtil.isAutoStartNewSequence(msgContext)){
+ internalSequenceId = getSequenceID(rmMsgCtx, serverSide, true); //require a new sequence
+ rmMsgCtx.setProperty(Sandesha2Constants.MessageContextProperties.INTERNAL_SEQUENCE_ID,internalSequenceId);
+ }
+ else if(rmsBean.isSequenceClosedClient()){
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceClosed, internalSequenceId));
+ }
+ else if(rmsBean.isTerminateAdded()){
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTerminated, internalSequenceId));
+ }
+ else if(rmsBean.isTimedOut()){
+ throw new SandeshaException(SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsSequenceTimedout, internalSequenceId));
+ }
+ }
+ else if(!msgContext.isServerSide())
+ {
+ //we need to check that any outgoing request msg is not using a different MEP than the sequence was established with
+ //The easiest way to check this is to ensure that the request and the replyTo of the RMS bean do not
+ //differ between non-anonymous and anonymous (either MC anonymous or WS-A anonymous)
+ boolean msgIsAnon = !AddressingHelper.isReplyRedirected(msgContext);
+ boolean isSequenceAnon = rmsBean.getReplyToEndpointReference() ==null ||
+ rmsBean.getReplyToEndpointReference().getAddress() ==null ||
+ rmsBean.getReplyToEndpointReference().hasAnonymousAddress();
+ if(msgIsAnon != isSequenceAnon && SandeshaUtil.isForbidMixedEPRsOnSequence(msgContext))
+ {
+ String msg = SandeshaMessageHelper.getMessage(SandeshaMessageKeys.cannotSendMsgAsEPRWrong, msgContext.toString(), rmsBean.getSequenceID());
+ log.warn(msg);
+ throw new SandeshaException(msg);
+ }
}
}
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor:: initial sequence checks pass");
// If the call application is a 2-way MEP, and uses a anonymous replyTo, and the
// RM 1.1 spec level, then we must have MakeConnection enabled. We check that here,
@@ -276,6 +303,8 @@
if (rmsBean == null) {
// SENDING THE CREATE SEQUENCE.
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor:: sending createSequence");
while (rmsBean == null) {
// There is a timing window where 2 sending threads can hit this point
// at the same time and both will create an RMSBean to the same endpoint
@@ -329,6 +358,9 @@
} else { // This is the first message (systemMessageNumber = -1)
messageNumber = 1;
}
+
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::message number=" + messageNumber);
if (serverSide) {
// Deciding whether this is the last message. We assume it is if it relates to
@@ -357,6 +389,8 @@
// saving the used message number, and the expected reply count
boolean startPolling = false;
if (!dummyMessage) {
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor:: not a dummy msg");
rmsBean.setNextMessageNumber(messageNumber);
// Identify the MEP associated with the message.
@@ -457,6 +491,8 @@
if (toEPR != null) {
// setting default actions.
+ if (log.isDebugEnabled())
+ log.debug("Enter: ApplicationMsgProcessor::setting default actions");
String to = toEPR.getAddress();
String operationName = msgContext.getOperationContext().getAxisOperation().getName().getLocalPart();
if (msgContext.getWSAAction() == null) {
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SandeshaUtil.java Mon Jun 23 05:28:53 2008
@@ -1131,6 +1131,33 @@
return newEPR;
}
+ public static boolean isForbidMixedEPRsOnSequence(MessageContext mc)
+ {
+ if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Entry: SandeshaUtil::isForbidMixedEPRsOnSequence");
+ boolean result = false;
+
+ //look at the msg ctx first
+ String auto = (String) mc.getProperty(SandeshaClientConstants.FORBID_MIXED_EPRS_ON_SEQUENCE);
+ if ("true".equals(auto)) {
+ if (log.isDebugEnabled()) log.debug("Mixed EPRs forbidden on message context");
+ result = true;
+ }
+
+ if(!result) {
+ //look at the operation
+ if (mc.getAxisOperation() != null) {
+ Parameter mixedParam = mc.getAxisOperation().getParameter(SandeshaClientConstants.FORBID_MIXED_EPRS_ON_SEQUENCE);
+ if (null != mixedParam && "true".equals(mixedParam.getValue())) {
+ if (log.isDebugEnabled()) log.debug("mixed EPRs forbidden on operation");
+ result = true;
+ }
+ }
+ }
+
+ if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Exit: SandeshaUtil::isForbidMixedEPRsOnSequence, " + result);
+ return result;
+ }
+
public static boolean isAutoStartNewSequence(MessageContext mc){
if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Entry: SandeshaUtil::isAutoStartNewSequence");
boolean result = false;
Modified: webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/java/org/apache/sandesha2/util/SequenceManager.java Mon Jun 23 05:28:53 2008
@@ -176,6 +176,8 @@
inboundSequence = (String) firstAplicationMsgCtx.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_SEQUENCE_ID);
if(inboundSequence != null) {
inboundBean = SandeshaUtil.getRMDBeanFromSequenceId(storageManager, inboundSequence);
+ if (log.isDebugEnabled())
+ log.debug("SequenceManager:: server side app msg: inboundBean=" + inboundBean);
}
}
Modified: webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties?rev=670538&r1=670537&r2=670538&view=diff
==============================================================================
--- webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties (original)
+++ webservices/sandesha/trunk/java/modules/core/src/main/resources/org/apache/sandesha2/i18n/resource.properties Mon Jun 23 05:28:53 2008
@@ -64,6 +64,7 @@
cannotSendMsgAsSequenceClosed=Sandesha2 could not send the message on sequence {0} as the sequence has been closed.
cannotSendMsgAsSequenceTerminated=Sandesha2 could not send the message on sequence {0} as the sequence has been terminated.
cannotSendMsgAsSequenceTimedout=Sandesha2 could not send the message on sequence {0} as the sequence has timed out.
+cannotSendMsgAsEPRWrong=Sandesha2 could not send the message {0} on sequence {1} as the message exchange pattern does not match that of the sequence: a sequence supports either synchronous use or asynchronous use, not both.
noValidSyncResponse=Sandesha2 sender thread has not received a valid synchronous response.
classLoaderNotFound=Module class loader not found.
---------------------------------------------------------------------
To unsubscribe, e-mail: sandesha-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: sandesha-dev-help@ws.apache.org