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

MtomMapUpdateProvider

public class MtomMapUpdateProvider extends Object implements com.sun.xml.ws.policy.jaxws.spi.PolicyMapUpdateProvider
Generate an MTOM policy if MTOM was enabled.
author
Jakub Podlesak (japod at sun.com)

Fields Summary
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger
logger
Constructors Summary
Methods Summary
private com.sun.xml.ws.policy.PolicycreateMtomPolicy(javax.xml.namespace.QName bindingName)
Create a policy with an MTOM assertion.

param
model The binding element name. Used to generate a (locally) unique ID for the policy.
return
The policy.

        ArrayList<AssertionSet> assertionSets = new ArrayList<AssertionSet>(1);
        ArrayList<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>(1);
        assertions.add(new MtomAssertion());
        assertionSets.add(AssertionSet.createAssertionSet(assertions));
        return Policy.createPolicy(null, bindingName.getLocalPart() + "_MTOM_Policy", assertionSets);
    
public voidupdate(com.sun.xml.ws.policy.PolicyMapExtender policyMapMutator, com.sun.xml.ws.policy.PolicyMap policyMap, com.sun.xml.ws.api.model.SEIModel model, com.sun.xml.ws.api.WSBinding wsBinding)
Generates an MTOM policy if MTOM is enabled.
  1. If MTOM is enabled
    1. If MTOM policy does not already exist, generate
    2. Otherwise do nothing
  2. Otherwise, do nothing (that implies that we do not remove any MTOM policies if MTOM is disabled)

        logger.entering(policyMapMutator, policyMap, model, wsBinding);
        
        if (policyMap != null) {
            final MTOMFeature mtomFeature = wsBinding.getFeature(MTOMFeature.class);
            if (logger.isLoggable(Level.FINEST)) {
                logger.finest("mtomFeature = " + mtomFeature);
            }
            if ((mtomFeature != null) && mtomFeature.isEnabled()) {
                final PolicyMapKey endpointKey = PolicyMap.createWsdlEndpointScopeKey(model.getServiceQName(), model.getPortName());
                final Policy existingPolicy = policyMap.getEndpointEffectivePolicy(endpointKey);
                if ((existingPolicy == null) || ! existingPolicy.contains(OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
                    final QName bindingName = model.getBoundPortTypeName();
                    final Policy mtomPolicy = createMtomPolicy(bindingName);
                    PolicySubject mtomPolicySubject = new PolicySubject(bindingName, mtomPolicy);
                    PolicyMapKey aKey = PolicyMap.createWsdlEndpointScopeKey(model.getServiceQName(), model.getPortName());
                    policyMapMutator.putEndpointSubject(aKey, mtomPolicySubject);
                    logger.fine("Added MTOM policy with ID \"" + mtomPolicy.getIdOrName() + "\" to binding element \"" + bindingName + "\"");
                } else {
                    logger.fine("MTOM policy exists already, doing nothing");
                }
            }
        } // endif policy map not null
        
        logger.exiting();