FileDocCategorySizeDatePackage
Message.javaAPI DocExample11265Tue May 29 16:56:40 BST 2007com.sun.xml.ws.rm

Message

public class Message extends Object
Message is an abstraction of messages that can be added to WS-RM Sequences. Each instance wraps a JAX-WS message.

Fields Summary
protected com.sun.xml.ws.api.message.Message
message
The JAX-WS Message wrapped by this instance.
protected Sequence
sequence
The Sequence to which the message belongs.
protected int
messageNumber
The messageNumber of the Message in its Sequence.
protected boolean
isWaiting
Flag which is true if and only if the message is waiting for a notification.
protected boolean
isComplete
Flag indicating whether message is delivered/acked. The meaning differs according to the type of sequence to which the message belongs. The value must only be changed using the complete() method, which should only be invoked by the Sequence containing the message.
protected Message
relatedMessage
For messages belonging to 2-way MEPS, the corresponding message.
protected com.sun.xml.ws.rm.protocol.SequenceElement
sequenceElement
Sequence stored when the corresponding com.sun.xml.ws.api.message.Header is added to the message.
protected com.sun.xml.ws.rm.protocol.SequenceAcknowledgementElement
sequenceAcknowledgementElement
SequenceElement stored when the corresponding com.sun.xml.ws.api.message.Header is added to the message.
protected com.sun.xml.ws.rm.protocol.AckRequestedElement
ackRequestedElement
SequenceElement stored when the corresponding com.sun.xml.ws.api.message.Header is added to the message.
public boolean
isTwoWayRequest
When true, indicates that the message is a request message for a two-way operation. ClientOutboundSequence with anonymous AcksTo has to handle Acknowledgements differently in this case.
public boolean
isOneWayResponse
Set in empty message used to piggyback response headers on a one-way response.
public static final String
namespaceURI
Namespace URI corresponding to RM version.
Constructors Summary
public Message(com.sun.xml.ws.api.message.Message message)
Public ctor takes wrapped JAX-WS message as its argument.

    
    
                  
       
        this.message = message;
    
Methods Summary
public voidaddHeader(com.sun.xml.ws.api.message.Header header)
Add the specified RM Header element to the underlying JAX-WS message's HeaderList.

param
header The Header to add to the HeaderList.

        message.getHeaders().add(header);
    
public synchronized voidblock()
Block the current thread using the monitor of this Message.

     
        isWaiting = true;
        try {
            while (!isComplete && isWaiting) {
                wait();
            }
        } catch (InterruptedException e) {}
    
public voidcomplete()
Sets the isComplete field to true, indicating that the message has been acked. Also discards the stored com.sun.xml.api.message.Message.

        //release reference to JAX-WS message.
        synchronized(sequence) {
            message = null;
            isComplete = true;
        }
    
public voidcopyContents()
Returns a com.sun.ws.rm.Message whose inner com.sun.xml.ws.api.message.Message is replaced by a copy of the original one. This message is stored in the relatedMessage field of ClientInboundSequence messages. A copy needs to be retained rather than the original since the original will already have been consumed at such time the relatedMessage needs to be resent.

        if (message != null) {
            com.sun.xml.ws.api.message.Message newmessage = message.copy();
            message = newmessage;
        }
    
public com.sun.xml.ws.rm.protocol.AckRequestedElementgetAckRequestedElement()

        return ackRequestedElement;
    
public com.sun.xml.ws.api.message.MessagegetCopy()
Returns a copy of the wrapped com.sun.xml.ws.api.message.Message.

        return message == null ? null : message.copy();
    
public com.sun.xml.ws.api.message.HeadergetHeader(java.lang.String name)
Get the RM Header Element with the specified name from the underlying JAX-WS message's HeaderList

param
name The name of the Header to find.

        if (message == null || !message.hasHeaders()) {
            return null;
        }
        
        return message.getHeaders().get(namespaceURI, name, true);     
    
public intgetMessageNumber()
Returns the value of the messageNumber field

return
The message number.

        return messageNumber;
    
public com.sun.xml.ws.rm.MessagegetRelatedMessage()
Accessor for the relatedMessage field.

return
The response corresponding to a request and vice-versa.

        return relatedMessage;
    
public SequencegetSequence()
Gets the Sequence to which the Message belongs.

return
The sequence.

        return sequence;
    
public com.sun.xml.ws.rm.protocol.SequenceAcknowledgementElementgetSequenceAcknowledgementElement()

        return sequenceAcknowledgementElement;
    
public com.sun.xml.ws.rm.protocol.SequenceElementgetSequenceElement()

        return sequenceElement;
    
public booleanisComplete()
Determines whether this message is delivered/acked

return
The value of the isComplete flag

        //synchronized block is redundant.
        synchronized(sequence) {
            return isComplete;
        }
    
public synchronized booleanisWaiting()

        return isWaiting;
    
public synchronized voidresume()
Wake up the current thread which is waiting on this Message's monitor.

            isWaiting = false;
            notify();
    
public voidsetAckRequestedElement(com.sun.xml.ws.rm.protocol.AckRequestedElement el)

        ackRequestedElement = el;
    
public voidsetMessageNumber(int messageNumber)
Sets the value of the messageNumber field. Used by Sequence methods when adding message to the sequence.

param
messageNumber The message number.

        this.messageNumber = messageNumber;
    
public voidsetRelatedMessage(com.sun.xml.ws.rm.Message mess)
Mutator for the relatedMessage field.

param
mess

        //store the message with a copy of the "inner" com.sun.xml.ws.api.message.Message
        //since the original one will be consumed
        mess.copyContents();
        relatedMessage = mess;
    
public voidsetSequence(Sequence sequence)
Sets the value of the sequence field. Used by Sequence methods when adding message to the sequence.

param
sequence The sequence.

        this.sequence = sequence;
    
public voidsetSequenceAcknowledgementElement(com.sun.xml.ws.rm.protocol.SequenceAcknowledgementElement el)

        sequenceAcknowledgementElement = el;
    
public voidsetSequenceElement(com.sun.xml.ws.rm.protocol.SequenceElement el)

        sequenceElement = el;
    
public java.lang.StringtoString()

        
         
        String ret = Messages.MESSAGE_NUMBER_STRING.format(messageNumber);
        ret += Messages.SEQUENCE_STRING.format(getSequence() != null ?
                                                getSequence().getId() :
                                                "null");
        
        SequenceElement sel;
        SequenceAcknowledgementElement sael;
        AckRequestedElement ael;
        if ( null != (sel = getSequenceElement())) {
            ret += sel.toString();
        }
        
        if ( null != (sael = getSequenceAcknowledgementElement())) {
            ret += sael.toString();
        }
        
        if ( null != (ael = getAckRequestedElement())) {
            ret += ael.toString();
        }
        
        return ret;