FileDocCategorySizeDatePackage
SelectOptimalEncodingModelConfiguratorProvider.javaAPI DocExample4974Tue May 29 16:56:32 BST 2007com.sun.xml.ws.encoding.policy

SelectOptimalEncodingModelConfiguratorProvider

public class SelectOptimalEncodingModelConfiguratorProvider extends Object implements com.sun.xml.ws.policy.jaxws.spi.ModelConfiguratorProvider
A configurator provider for FastInfoset policy assertions.
author
Paul.Sandoz@Sun.Com

Fields Summary
public static final QName
enabled
Constructors Summary
Methods Summary
public voidconfigure(com.sun.xml.ws.api.model.wsdl.WSDLModel model, com.sun.xml.ws.policy.PolicyMap policyMap)
Process SelectOptimalEncoding policy assertions.

param
model the WSDL model.
param
policyMap the policy map.

    
                       
              
        assert model != null;
        assert policyMap != null;
        
        for (WSDLService service:model.getServices().values()) {
            for (WSDLPort port : service.getPorts()) {
                configure(port, policyMap);
            } // end foreach port
        } // end foreach service
    
public voidconfigure(com.sun.xml.ws.api.model.wsdl.WSDLPort port, com.sun.xml.ws.policy.PolicyMap policyMap)

        assert port != null;
        assert policyMap != null;
        
        PolicyMapKey key = PolicyMap.createWsdlEndpointScopeKey(port.getOwner().getName(),port.getName());
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null!=policy && policy.contains(SELECT_OPTIMAL_ENCODING_ASSERTION)) {
            Iterator <AssertionSet> assertions = policy.iterator();
            while(assertions.hasNext()){
                AssertionSet assertionSet = assertions.next();
                Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
                while(policyAssertion.hasNext()){
                    PolicyAssertion assertion = policyAssertion.next();
                    if(SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())){
                        String value = assertion.getAttributeValue(enabled);
                        boolean isSelectOptimalEncodingEnabled = value == null || Boolean.valueOf(value.trim());
                        port.addFeature(
                                new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled));
                    } 
                } 
            } 
        }