FileDocCategorySizeDatePackage
SequenceConfig.javaAPI DocExample14346Tue May 29 16:56:42 BST 2007com.sun.xml.ws.rm.jaxws.runtime

SequenceConfig

public class SequenceConfig extends com.sun.xml.ws.api.rm.SequenceSettings
SequenceConfig stores settings read from a WS-RM Policy Assertion in a Web Service's metadata and is used enable/disable and configure reliable messaging on bindings to which the policy assertion is attached. (Placeholder for now pending WS-Policy implementation)

Fields Summary
Constructors Summary
public SequenceConfig()
Constructor initializes with default values.

        
        //Use anonymous URI for acksTo.  Its value depends on 
        //WS-Addressing version being used

        if (constants == null) {
            //hardcoding W3C as default
            constants = RMConstants.getRMConstants(AddressingVersion.W3C);
        }
        acksTo = constants.getAnonymousURI().toString();
        
        ordered = false;
        allowDuplicates = false;
        inactivityTimeout = 600000;
        flowControl = false;
        bufferSize = 32;
        soapVersion = SOAPVersion.SOAP_12;
             
        ackRequestInterval = 0;
        resendInterval = 0;
        
        closeTimeout = 0; //infinite
    
public SequenceConfig(com.sun.xml.ws.api.model.wsdl.WSDLPort port, com.sun.xml.ws.api.WSBinding wsbinding)

        
        this();
        if (port != null) {
            WSDLBoundPortType binding = port.getBinding();
            WSDLModel model = binding.getOwner();
            PolicyMap policyMap = model.getExtension(WSDLPolicyMapWrapper.class)
                                            .getPolicyMap();
            this.constants = RMConstants.getRMConstants(wsbinding.getAddressingVersion());
            try {
                init(port, policyMap);
            } catch (RMException e) {
                throw new WebServiceException(e);
            }
        } 
    
public SequenceConfig(com.sun.xml.ws.api.rm.SequenceSettings toCopy)
Copies the members of a specified SequenceSettings

        
        this.ackRequestInterval = toCopy.ackRequestInterval;
        this.acksTo = toCopy.acksTo;
        this.allowDuplicates = toCopy.allowDuplicates;
        this.bufferSize = toCopy.bufferSize;
        this.closeTimeout = toCopy.closeTimeout;
        this.constants = toCopy.constants;
        this.flowControl = toCopy.flowControl;
        this.inactivityTimeout = toCopy.inactivityTimeout;
        this.ordered = toCopy.ordered;
        this.resendInterval = toCopy.resendInterval;
        this.soapVersion = toCopy.soapVersion;
  
    
Methods Summary
public longgetAckRequestInterval()
Accessor for ackRequestIterval field

return
The value of the field.

        return ackRequestInterval;
    
public java.lang.StringgetAcksTo()
Accessor for the acksTo property.

return
The value of the property.

        return acksTo;
    
public intgetBufferSize()
Accessor for bufferSize property.

return
The value of the property.

        return bufferSize;
    
public longgetCloseTimeout()
Accessor for the closeTimeout property.

return
The value of the property.

        return closeTimeout;
    
public RMConstantsgetConstants()

        return constants;
    
public booleangetFlowControl()
Accessor for flow control field

return
The value of the field.

        return flowControl;
    
public longgetInactivityTimeout()
Accessor for inactivityTimeout property.

return
The value of the property.

        return inactivityTimeout;
    
public booleangetOrdered()
Accessor for ordered property.

return
The value of the property.

        return ordered;
    
public RMConstantsgetRMConstants()
Returns the RMConstants based on the AddressingVersion

return
RMConstants

        return constants;
    
public longgetResendInterval()
Accessor for resendIterval field

return
The value of the field.

        return resendInterval;
    
public com.sun.xml.ws.api.SOAPVersiongetSoapVersion()
Returns the SOAPVersion obtained from the WSBinding Defaulting to SOAP_12

return
SOAPVersion should not be null

        if (soapVersion != null)
            return soapVersion;
        //TODO check if this defaulting is ok
        else return SOAPVersion.SOAP_12;
    
private voidhandleFlowAssertion(PolicyAssertion flowAssertion)

       
        flowControl = true;
        
        Iterator<PolicyAssertion> it = flowAssertion.getNestedAssertionsIterator();
        while (it != null && it.hasNext()) { 
             PolicyAssertion assertion = it.next();
            if (assertion.getName().equals(constants.getMaxReceiveBufferSizeQName())) {
                bufferSize = Integer.parseInt(assertion.getValue());            
                break;
            }
       }
    
private voidhandleRMAssertion(PolicyAssertion rmAssertion)

        
        Iterator<PolicyAssertion> it = rmAssertion.getNestedAssertionsIterator();
        
        while (it != null && it.hasNext()) {
            PolicyAssertion assertion = it.next();
            if (assertion.getName().equals(constants.getInactivityTimeoutQName())) {
                
                String num = assertion.getAttributeValue(new QName("", "Milliseconds"));
               
                if (num != null) {
                    inactivityTimeout = Long.parseLong(num);
                }
            } else if (assertion.getName().equals(constants.getAcknowledgementIntervalQName())) {
                //don't have a member variable for it.  Do we need it?
                 
            }
        }
    
public voidinit(com.sun.xml.ws.api.model.wsdl.WSDLPort port, PolicyMap policyMap)

       
        try {
            
            if (policyMap != null) {
                PolicyMapKey endpointScopeKey = 
                        policyMap.
                            createWsdlEndpointScopeKey(port.getOwner().getName(), 
                                                       port.getName());

                if (endpointScopeKey != null) {
                    
                    AssertionSet policyAssertionSet = null;
                    
                    Policy policy = policyMap.getEndpointEffectivePolicy(endpointScopeKey);
                    if (policy != null) {
                        for (AssertionSet set: policy) {
                            policyAssertionSet = set;
                            break;
                        }
                    }
                    
                    if (policyAssertionSet != null) {
                        
                        PolicyAssertion rmAssertion = null;
                        PolicyAssertion flowAssertion = null;
                        
                        for (PolicyAssertion assertion : policyAssertionSet) {
                            QName qname = assertion.getName();
                          
                            if (qname.equals(constants.getRMAssertionQName())) {
                                rmAssertion = assertion;
                            } else if (qname.equals(constants.getRMFlowControlQName())) {
                                flowAssertion = assertion;
                            } else if (qname.equals(constants.getOrderedQName())) {
                                ordered = true;
                            } else if (qname.equals (constants.getAllowDuplicatesQName())) {
                                allowDuplicates = true;
                            } else if (qname.equals(constants.getAckRequestIntervalQName())) {
                                String num = assertion.getAttributeValue(new QName("", "Milliseconds"));
                                if (num != null) {
                                    ackRequestInterval = Long.parseLong(num);
                                }
                            } else if (qname.equals(constants.getResendIntervalQName())) {
                                String num = assertion.getAttributeValue(new QName("", "Milliseconds"));
                                if (num != null) {
                                    resendInterval = Long.parseLong(num);
                                }
                            } else if (qname.equals(constants.getCloseTimeoutQName())) {
                                String num = assertion.getAttributeValue(new QName("", "Milliseconds"));
                                if (num != null) {
                                    closeTimeout = Long.parseLong(num);
                                }
                            }   else {
                                //TODO handle error condition here
                            }
                        }
                        
                        if (rmAssertion != null) {
                           handleRMAssertion(rmAssertion);
                        } 

                        if (flowAssertion != null)
                           handleFlowAssertion(flowAssertion);
                    }
                }
            }
            
        } catch (PolicyException e) {
            e.printStackTrace();
        }
    
public booleanisAllowDuplicates()

        return allowDuplicates;
    
public voidsetAckRequestInterval(long interval)
Mutator for the ackRequestInterval field

param
The new value

        ackRequestInterval = interval;
    
public voidsetAcksTo(java.lang.String acksTo)
Mutator for the AcksTo property.

param
acksTo The new value of the property.

        this.acksTo = acksTo;
    
public voidsetBufferSize(int bufferSize)
Mutator for the bufferSize property.

param
bufferSize The new value of the property.

        this.bufferSize = bufferSize;
    
public voidsetCloseTimeout(long timeout)
Mutator for the closeTimeout property.

param
The new value.

        closeTimeout = timeout;
    
public voidsetFlowControl(boolean use)
Mutator for the flow control field

param
The new value

        flowControl = use;
    
public voidsetInactivityTimeout(long inactivityTimeout)
Mutator for the inactivityTimeout property.

param
inactivityTimeout The new value of the property.

        this.inactivityTimeout = inactivityTimeout;
    
public voidsetOrdered(boolean ordered)
Mutator for the ordered property.

param
ordered The new value of the property.

        this.ordered = ordered;
    
public voidsetResendInterval(long interval)
Mutator for the flow control field

param
The new value

        resendInterval = interval;
    
public voidsetSoapVersion(com.sun.xml.ws.api.SOAPVersion soapVersion)

        this.soapVersion = soapVersion;