public InvocationResponse invoke()

in modules/core/src/main/java/org/apache/sandesha2/handlers/SandeshaGlobalInHandler.java [73:158]


	public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {

		if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
			log.debug("Enter: SandeshaGlobalInHandler::invoke, " + msgContext.getEnvelope().getHeader());

		// look at the service to see if RM is totally disabled. This allows the user to disable RM using
		// a property on the service, even when Sandesha is engaged.
		if (msgContext.getAxisService() != null) {
			Parameter unreliableParam = msgContext.getAxisService().getParameter(SandeshaClientConstants.UNRELIABLE_MESSAGE);
			if (null != unreliableParam && "true".equals(unreliableParam.getValue())) {
				if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
					log.debug("Exit: SandeshaGlobalInHandler::invoke, Service has disabled RM " + InvocationResponse.CONTINUE);
				return InvocationResponse.CONTINUE;
			}
		} else if (msgContext.getConfigurationContext().getAxisConfiguration().getParameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN) == null) {
			if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
				log.debug("Exit: SandeshaGlobalInHandler::invoke, No Property Bean found " + InvocationResponse.CONTINUE);
			
			return InvocationResponse.CONTINUE;						
		}

		// The only work that this handler needs to do is identify messages which
		// follow the WSRM 1.0 convention for sending 'LastMessage' when the sender
		// doesn't have a reliable message to piggyback the last message marker onto.
		// Normally they will identify this scenario with an action marker, but if
		// there is no action at all then we have to check the soap body.
		// Either way, all that this handler need do is set the action back onto
		// the message, so that the dispatchers can allow it to continue. The real
		// processing will be done in the SequenceProcessor.
		String soapAction = msgContext.getSoapAction();
		String wsaAction = msgContext.getWSAAction();
		if(soapAction == null && wsaAction == null) {
			// Look for a WSRM 1.0 sequence header with the lastMessage marker
			SOAPEnvelope env = msgContext.getEnvelope();
			if(env != null) {
				boolean lastMessageHeader = false;
				try {
					SOAPHeader header = env.getHeader();
					if(header != null) {
						SOAPHeaderBlock shb = (SOAPHeaderBlock) header.getFirstChildWithName(Sandesha2Constants.SPEC_2005_02.QNames.Sequence);
						Sequence sequence = new Sequence(Sandesha2Constants.SPEC_2005_02.NS_URI);
						sequence.fromHeaderBlock(shb);
						lastMessageHeader = sequence.getLastMessage();
					}
				} catch(Exception e) {
					// Do nothing, we failed to find a Sequence header
					if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
						log.debug("Exception encountered accessing Sequence Header ", e);
				}
				if(lastMessageHeader) {
					SOAPBody body = env.getBody();
					if(body != null && body.getFirstElement() == null) {
						// There is an empty body so we know this is the kind of message
						// that we are looking for.
						if(LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled()) log.debug("Setting SOAP Action for a WSRM 1.0 last message");
						msgContext.setSoapAction(Sandesha2Constants.SPEC_2005_02.Actions.SOAP_ACTION_LAST_MESSAGE);
					}
				}
			}
		}
    
    // Check if this is an application message and if it is a duplicate
    RMMsgContext rmMsgCtx = MsgInitializer.initializeMessage(msgContext);

    // Set the RMMMessageContext as a property on the message so we can retrieve it later
    msgContext.setProperty(Sandesha2Constants.MessageContextProperties.RM_MESSAGE_CONTEXT, rmMsgCtx);

    
    StorageManager storageManager = 
      SandeshaUtil.getSandeshaStorageManager(rmMsgCtx.getConfigurationContext(), 
          rmMsgCtx.getConfigurationContext().getAxisConfiguration());
    
		//processing any incoming faults.     
    //This is responsible for Sandesha2 specific 
    InvocationResponse response = FaultManager.processMessagesForFaults(rmMsgCtx, storageManager);

    //both application msgs and lastMsg msgs will be processed in the same way here.
    if (rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.APPLICATION ||
    		rmMsgCtx.getMessageType() == Sandesha2Constants.MessageTypes.LAST_MESSAGE) {
      processApplicationMessage(rmMsgCtx);
    }
    
		if (LoggingControl.isAnyTracingEnabled() && log.isDebugEnabled())
			log.debug("Exit: SandeshaGlobalInHandler::invoke " + response);
		return response;
	}