Search in sources :

Example 1 with SelectOptimalEncodingFeature

use of com.sun.xml.ws.api.client.SelectOptimalEncodingFeature in project metro-jax-ws by eclipse-ee4j.

the class SelectOptimalEncodingFeatureConfigurator method getFeatures.

/**
 * Process SelectOptimalEncoding policy assertions.
 *
 * @param key Key that identifies the endpoint scope.
 * @param policyMap The policy map.
 * @throws PolicyException If retrieving the policy triggered an exception.
 */
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
    final Collection<WebServiceFeature> features = new LinkedList<>();
    if ((key != null) && (policyMap != null)) {
        Policy policy = policyMap.getEndpointEffectivePolicy(key);
        if (null != policy && policy.contains(EncodingConstants.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 (EncodingConstants.SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())) {
                        String value = assertion.getAttributeValue(enabled);
                        boolean isSelectOptimalEncodingEnabled = value == null || Boolean.parseBoolean(value.trim());
                        features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled));
                    }
                }
            }
        }
    }
    return features;
}
Also used : Policy(com.sun.xml.ws.policy.Policy) PolicyAssertion(com.sun.xml.ws.policy.PolicyAssertion) WebServiceFeature(jakarta.xml.ws.WebServiceFeature) AssertionSet(com.sun.xml.ws.policy.AssertionSet) SelectOptimalEncodingFeature(com.sun.xml.ws.api.client.SelectOptimalEncodingFeature) LinkedList(java.util.LinkedList)

Aggregations

SelectOptimalEncodingFeature (com.sun.xml.ws.api.client.SelectOptimalEncodingFeature)1 AssertionSet (com.sun.xml.ws.policy.AssertionSet)1 Policy (com.sun.xml.ws.policy.Policy)1 PolicyAssertion (com.sun.xml.ws.policy.PolicyAssertion)1 WebServiceFeature (jakarta.xml.ws.WebServiceFeature)1 LinkedList (java.util.LinkedList)1