FileDocCategorySizeDatePackage
PolicyServiceInterceptor.javaAPI DocExample7067Tue May 29 16:56:36 BST 2007com.sun.xml.ws.policy.jaxws.client

PolicyServiceInterceptor

public class PolicyServiceInterceptor extends com.sun.xml.ws.api.client.ServiceInterceptor

Fields Summary
private static final com.sun.xml.ws.policy.privateutil.PolicyLogger
LOGGER
Constructors Summary
Methods Summary
private voidaddFeatureListToList(java.util.List list, com.sun.xml.ws.api.WSFeatureList featureList)

        for (WebServiceFeature feature : featureList) {
            list.add(feature);
        }
    
private voidaddFeatures(java.util.List features, com.sun.xml.ws.api.model.wsdl.WSDLModel model, javax.xml.namespace.QName portName)
Add the features in the WSDL model for the given port to the list

        LOGGER.entering(features, model, portName);
        try {
            for (WSDLService service : model.getServices().values()) {
                final WSDLPort port = service.get(portName);
                if (port != null) {
                    addFeatureListToList(features, port.getFeatures());
                    addFeatureListToList(features, port.getBinding().getFeatures());
                    break;
                }
            }
        } finally {
            LOGGER.exiting(features);
        }
    
public java.util.ListpreCreateBinding(com.sun.xml.ws.api.client.WSPortInfo port, java.lang.Class serviceEndpointInterface, com.sun.xml.ws.api.WSFeatureList defaultFeatures)

    
               
        LOGGER.entering(port, serviceEndpointInterface, defaultFeatures);
        final LinkedList<WebServiceFeature> features = new LinkedList<WebServiceFeature>();
        try {
            final WSDLPort wsdlPort = port.getPort();
            // We only need to read the client config if the server WSDL was not parsed
            if (wsdlPort == null) {
                final WSDLModel clientModel;
                try {
                    clientModel = PolicyConfigParser.parseModel(PolicyConstants.CLIENT_CONFIGURATION_IDENTIFIER, null);
                } catch (PolicyException pe) {
                    throw LOGGER.logSevereException(new WebServiceException(LocalizationMessages.WSP_1017_ERROR_WHILE_PROCESSING_CLIENT_CONFIG(), pe));
                }
                
                if (clientModel != null) {
                    final WSDLPolicyMapWrapper policyMapWrapper = clientModel.getExtension(WSDLPolicyMapWrapper.class);
                    if (policyMapWrapper == null) {
                        LOGGER.config(LocalizationMessages.WSP_1022_POLICY_MAP_NOT_IN_MODEL());
                    } else {
                        LOGGER.config(LocalizationMessages.WSP_1024_INVOKING_CLIENT_POLICY_ALTERNATIVE_SELECTION());
                        try {
                            policyMapWrapper.doAlternativeSelection();
                        } catch (PolicyException e) {
                            throw LOGGER.logSevereException(new WebServiceException(LocalizationMessages.WSP_1003_VALID_POLICY_ALTERNATIVE_NOT_FOUND(), e));
                        }
                        
                        final PolicyMap map = policyMapWrapper.getPolicyMap();
                        
                        try {
                            for (ModelConfiguratorProvider configurator : PolicyUtils.ServiceProvider.load(ModelConfiguratorProvider.class)) {
                                configurator.configure(clientModel, map);
                            }
                        } catch (PolicyException e) {
                            throw LOGGER.logSevereException(new WebServiceException(LocalizationMessages.WSP_1023_ERROR_WHILE_CONFIGURING_MODEL(), e));
                        }
                        // We can not read the features directly from port.getPort() because in the
                        // case of dispatch that object may be null.
                        addFeatures(features, clientModel, port.getPortName());
                        features.add(new PolicyFeature(map, clientModel, port));
                    }
                }
            }
            
            return features;
        } finally {
            LOGGER.exiting(features);
        }