cgl.narada.wsinfra.wsrm.impl
Class WsrmSourceNodeHelper

java.lang.Object
  extended by cgl.narada.wsinfra.WsProcessor
      extended by cgl.narada.wsinfra.wsrm.impl.WsrmSourceNodeHelper

public class WsrmSourceNodeHelper
extends WsProcessor

This is a utility class which performs several functions that are helpful for the processing logic related to the WsrmSourceNode class.


Method Summary
 void checkExchangeType(WsrmExchangeInfo wsrmExchangeInfo, int direction)
           
 void checkForMessageRolloverFault(WsrmSequenceInfo wsrmSequenceInfo, long previousMessageNumber)
          Checks to see if a message number rollver is about to occur.
 void checkForProblems(AddressingHeaders addressingHeaders, SequenceAcknowledgementDocument sequenceAckDocument, long[] acknowledgements)
          This method processes a set of acknowledgements received for a sequence.
 void checkForProblemsInToDocument(AddressingHeaders addressingHeaders)
          This method enforces the rule that the [wsa:To] element should be present within a SOAP header element.
static WsrmSourceNodeHelper getInstance()
           
 WsMessageFlow getMessageFlow()
          Gets the message flow which the processor should use.
 long[] getNegativeAcknowledgements(SequenceAcknowledgementDocument sequenceAckDocument)
          Retrieve the negative acknowledgements that have been specified within the sequence acknowledgement as an array of longs.
 String getRelatesTo(EnvelopeDocument envelopeDocument)
          This method parses the SOAP envelope and retrieves the [wsa:RelatesTo] element within the SOAP header element as a String.
 Calendar getSequenceExpiresAt(EnvelopeDocument envelopeDocument)
          Check to see if an acknowledgement has been requested for this message.
 WsrmSequenceInfo getWsrmSequenceInfo(AddressingHeaders addressingHeaders, String sequenceIdentifier, String relatesTo, String destination, WsrmSequencePolicies wsrmSequencePolicies)
          Creates a WsrmSequenceInfo based on the specified parameters.
 WsrmSequencePolicies getWsrmSequencePolicies(EnvelopeDocument envelopeDocument, String sequenceIdentifier)
          This method locates/retrieves/creates the WsrmSequencePolicies associated with the sequenceIdentifier.
 void initialize(WsrmStorageService wsrmStorageService)
           
 boolean isAckRequested(EnvelopeDocument envelopeDocument)
          Check to see if an acknowledgement has been requested for this message.
 boolean isLastMessageOfSequence(EnvelopeDocument envelopeDocument)
          Check to see if an element which indicates that it is last message is present.
 void manageRetransmissions(String sequenceIdentifier, long[] nacks)
          This method manages retransmissions based on the supplied negative acknowledgements and the sequence identifier.
 boolean processExchange(EnvelopeDocument envelopeDocument, int direction)
          This is the method which all implementations of the various WS specifications will override.
 void processSequenceTermination(String sequenceIdentifier)
          Check to see if the sequence needs to be terminated, and if so, proceed to create and issue the appropriate termination sequence exchange
 void setEndpointReference(EndpointReferenceType endpointReference)
           
 void setMessageFlow(WsMessageFlow wsMessageFlow)
          Sets the message flow which the processor should use
 void throwInvalidAcknowledgementFaultException(AddressingHeaders addressingHeaders, SequenceAcknowledgementDocument seqAckDocument, String additionalReason)
          Throws an Invalid SequenceAcknowledgement Fault exception based on the specified parameters
 void throwInvalidMessageFaultException(String reason, AddressingHeaders addressingHeaders)
          Throws an Invalid MessageFault exception based on the specified parameters
 void throwUnknownSequenceFaultException(AddressingHeaders addressingHeaders, String identifier)
          Throws an UnknownSequence Fault exception based on the specified parameters
 
Methods inherited from class cgl.narada.wsinfra.WsProcessor
enrouteToApplication, enrouteToNetwork, enrouteToNetwork, isFault, manageFaultException, processExchange, processExchange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

initialize

public void initialize(WsrmStorageService wsrmStorageService)
                throws DeploymentException
Throws:
DeploymentException

setEndpointReference

public void setEndpointReference(EndpointReferenceType endpointReference)

processExchange

public boolean processExchange(EnvelopeDocument envelopeDocument,
                               int direction)
                        throws UnknownExchangeException,
                               IncorrectExchangeException,
                               ProcessingException,
                               MessageFlowException
Description copied from class: WsProcessor
This is the method which all implementations of the various WS specifications will override. Note that deployement need only pass the JAVA-WORLD javax.xml.SOAPMessage and all the processing and conversions take place automatically.

Specified by:
processExchange in class WsProcessor
Throws:
UnknownExchangeException
IncorrectExchangeException
ProcessingException
MessageFlowException

setMessageFlow

public void setMessageFlow(WsMessageFlow wsMessageFlow)
                    throws DeploymentException
Sets the message flow which the processor should use

Specified by:
setMessageFlow in class WsProcessor
Throws:
DeploymentException

getMessageFlow

public WsMessageFlow getMessageFlow()
Gets the message flow which the processor should use.

Specified by:
getMessageFlow in class WsProcessor

getInstance

public static WsrmSourceNodeHelper getInstance()

getWsrmSequencePolicies

public WsrmSequencePolicies getWsrmSequencePolicies(EnvelopeDocument envelopeDocument,
                                                    String sequenceIdentifier)
                                             throws WsrmStorageException
This method locates/retrieves/creates the WsrmSequencePolicies associated with the sequenceIdentifier. There are Three steps involved here.
Check to see if there is a SequenceRef document. IFF there is one, check to see if the match is wsrm:Exact or wsrm:Prefix. If it is wsrm:Prefix proceed to store the created WsrmSequencePolicies in the policyStorage operations. If a previous entry exists for the SAME PREFIX this should replace it.

If there is no SequenceRef document, check to see if a prefix match exists, if there is one proceed to use the previously stored sequence policies.

If there is NO sequenceRef document and NO matching PREFIX entries proceed to simply use the defaultWsrmSequencePolicies.

Throws:
WsrmStorageException

getWsrmSequenceInfo

public WsrmSequenceInfo getWsrmSequenceInfo(AddressingHeaders addressingHeaders,
                                            String sequenceIdentifier,
                                            String relatesTo,
                                            String destination,
                                            WsrmSequencePolicies wsrmSequencePolicies)
                                     throws WsrmStorageException
Creates a WsrmSequenceInfo based on the specified parameters. If the [wsa:From] is NULL or [wsa:ReplyTo] is NULL proceed to create a new EPR for the sink using the specified destination.

Throws:
WsrmStorageException

checkForProblems

public void checkForProblems(AddressingHeaders addressingHeaders,
                             SequenceAcknowledgementDocument sequenceAckDocument,
                             long[] acknowledgements)
                      throws WsrmStorageException,
                             WsFaultException
This method processes a set of acknowledgements received for a sequence. It checks, and issues faults if problems are encountered, for three distinct conditions.
(a) Is this a known sequence?
(b) If the sequence acknowledgement message numbers a valid one?
(c) Has this sequence expired/terminated?

Throws:
WsrmStorageException
WsFaultException

getNegativeAcknowledgements

public long[] getNegativeAcknowledgements(SequenceAcknowledgementDocument sequenceAckDocument)
Retrieve the negative acknowledgements that have been specified within the sequence acknowledgement as an array of longs. The conversions of the datatypes needs to be handled by the method.


manageRetransmissions

public void manageRetransmissions(String sequenceIdentifier,
                                  long[] nacks)
                           throws WsrmStorageException,
                                  MessageFlowException
This method manages retransmissions based on the supplied negative acknowledgements and the sequence identifier. The sequence identifier is used to determine the message numbers from which the retransmission interval has expired and no acknowledgement has been received.

Throws:
WsrmStorageException
MessageFlowException

processSequenceTermination

public void processSequenceTermination(String sequenceIdentifier)
                                throws WsrmStorageException,
                                       MessageFlowException
Check to see if the sequence needs to be terminated, and if so, proceed to create and issue the appropriate termination sequence exchange

Throws:
WsrmStorageException
MessageFlowException

isLastMessageOfSequence

public boolean isLastMessageOfSequence(EnvelopeDocument envelopeDocument)
Check to see if an element which indicates that it is last message is present. If so return true, else return false.


isAckRequested

public boolean isAckRequested(EnvelopeDocument envelopeDocument)
Check to see if an acknowledgement has been requested for this message. Check to see if the element exists, if it does return true; else return false.


getSequenceExpiresAt

public Calendar getSequenceExpiresAt(EnvelopeDocument envelopeDocument)
Check to see if an acknowledgement has been requested for this message. Check to see if the element exists, if it does return true; else return false.


checkForProblemsInToDocument

public void checkForProblemsInToDocument(AddressingHeaders addressingHeaders)
                                  throws WsFaultException
This method enforces the rule that the [wsa:To] element should be present within a SOAP header element. If this is not present an exception needs to be thrown.

Throws:
WsFaultException

getRelatesTo

public String getRelatesTo(EnvelopeDocument envelopeDocument)
This method parses the SOAP envelope and retrieves the [wsa:RelatesTo] element within the SOAP header element as a String. This method returns a NULL if this element is NOT found.


checkForMessageRolloverFault

public void checkForMessageRolloverFault(WsrmSequenceInfo wsrmSequenceInfo,
                                         long previousMessageNumber)
                                  throws WsFaultException,
                                         WsrmStorageException
Checks to see if a message number rollver is about to occur. That is the message number has a value of Long.MAX_VALUE. If this happens, the sequence needs to be terminated (the corresponding WSRM sequence info being stored) and a WsFault exception needs to be issued.

Throws:
WsFaultException
WsrmStorageException

throwInvalidMessageFaultException

public void throwInvalidMessageFaultException(String reason,
                                              AddressingHeaders addressingHeaders)
                                       throws WsFaultException
Throws an Invalid MessageFault exception based on the specified parameters

Throws:
WsFaultException

throwInvalidAcknowledgementFaultException

public void throwInvalidAcknowledgementFaultException(AddressingHeaders addressingHeaders,
                                                      SequenceAcknowledgementDocument seqAckDocument,
                                                      String additionalReason)
                                               throws WsFaultException
Throws an Invalid SequenceAcknowledgement Fault exception based on the specified parameters

Throws:
WsFaultException

throwUnknownSequenceFaultException

public void throwUnknownSequenceFaultException(AddressingHeaders addressingHeaders,
                                               String identifier)
                                        throws WsFaultException
Throws an UnknownSequence Fault exception based on the specified parameters

Throws:
WsFaultException

checkExchangeType

public void checkExchangeType(WsrmExchangeInfo wsrmExchangeInfo,
                              int direction)
                       throws UnknownExchangeException,
                              IncorrectExchangeException
Throws:
UnknownExchangeException
IncorrectExchangeException


For comments and suggestions please send e-mail to The NaradaBrokering Project