Package org.apache.tuscany.sca.policy

Examples of org.apache.tuscany.sca.policy.PolicySetAttachPoint


    }

    private static void determineApplicableImplementationPolicySets(Component component) throws PolicyConfigurationException {
        List<Intent> intentsCopy = null;
        if ( component.getImplementation() instanceof PolicySetAttachPoint ) {
            PolicySetAttachPoint policiedImplementation = (PolicySetAttachPoint)component.getImplementation();
          
            //trim intents specified in operations.  First check for policysets specified on the operation
            //and then in the parent implementation
            if ( component instanceof OperationsConfigurator ) {
                OperationsConfigurator opConfigurator = (OperationsConfigurator)component;
               
                for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
                    intentsCopy = new ArrayList<Intent>(confOp.getRequiredIntents());
                    trimInherentlyProvidedIntents(policiedImplementation.getType(),
                                                  confOp.getRequiredIntents());
                    trimProvidedIntents(confOp.getRequiredIntents(), confOp.getPolicySets());
                    trimProvidedIntents(confOp.getRequiredIntents(), component.getPolicySets());
                   
                    determineApplicableDomainPolicySets(component.getApplicablePolicySets(),
                                                        confOp,
                                                        policiedImplementation.getType());
   
                    if (confOp.getRequiredIntents().size() > 0) {
                        throw new PolicyConfigurationException("The following are unfulfilled intents for operations configured in "
                                + "component implementation - " + component.getName() + "\nUnfulfilled Intents = " +
                                confOp.getRequiredIntents());
                    }
                   
                    //the intents list could have been trimmed when matching for policysets
                    //since the implementation may need the original set of intents we copy that back
                    confOp.getRequiredIntents().clear();
                    confOp.getRequiredIntents().addAll(intentsCopy);
                }
            }
               
            intentsCopy = new ArrayList<Intent>(component.getRequiredIntents());
            trimInherentlyProvidedIntents(policiedImplementation.getType(),
                                          component.getRequiredIntents());
            trimProvidedIntents(component.getRequiredIntents(), component.getPolicySets());
               
            //determine additional policysets that match remaining intents
            //if there are intents that are not provided by any policy set throw a warning
            //TODO: resolved to domain policy registry and attach suitable policy sets to the implementation
            //...for now using the SCA Definitions instead of registry
            //if ( domainPolicySets != null)  {
                determineApplicableDomainPolicySets(component.getApplicablePolicySets(),
                                                    component,
                                                    policiedImplementation.getType());
                                                   
                if (component.getRequiredIntents().size() > 0) {
                    throw new PolicyConfigurationException("The following are unfulfilled intents for component implementation - " + component
                        .getName() + "\nUnfulfilled Intents = " + component.getRequiredIntents());
                }
View Full Code Here


   
    private void createPolicyHandlers() throws IllegalAccessException,
                                               InstantiationException,
                                               ClassNotFoundException {
        if (wsBinding instanceof PolicySetAttachPoint) {
            PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
            PolicyHandler policyHandler = null;
            for (PolicySet policySet : policiedBinding.getPolicySets()) {
                policyHandler =
                    PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames);
                if (policyHandler != null) {
                    policyHandler.setApplicablePolicySet(policySet);
                    policyHandlerList.add(policyHandler);
View Full Code Here

    public static PolicySet getPolicySet(Binding wsBinding, QName intentName) {
        PolicySet returnPolicySet = null;

        if (wsBinding instanceof PolicySetAttachPoint) {
            PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
            for (PolicySet policySet : policiedBinding.getPolicySets()) {
                for (Intent intent : policySet.getProvidedIntents()) {
                    if (intent.getName().equals(intentName)) {
                        returnPolicySet = policySet;
                        break;
                    }
View Full Code Here

        if (component != null && component.getImplementation() instanceof JavaImplementation) {
            JavaImplementation javaImpl = (JavaImplementation)component.getImplementation();
            if (javaImpl instanceof PolicySetAttachPoint) {
                PolicyHandler policyHandler = null;
                List<PolicyHandler> implPolicyHandlers = new ArrayList<PolicyHandler>();
                PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)javaImpl;

                try {
                    //for ( PolicySet policySet : policiedImpl.getPolicySets() ) {
                    for (PolicySet policySet : component.getPolicySets()) {
                        policyHandler =
View Full Code Here

        return null;
    }

    private void createPolicyHandlers() throws IllegalAccessException, InstantiationException, ClassNotFoundException {
        if (wsBinding instanceof PolicySetAttachPoint) {
            PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)wsBinding;
            PolicyHandler policyHandler = null;
            for (PolicySet policySet : policiedBinding.getPolicySets()) {
                policyHandler = PolicyHandlerUtils.findPolicyHandler(policySet, policyHandlerClassnames);
                if (policyHandler != null) {
                    policyHandler.setApplicablePolicySet(policySet);
                    policyHandlerList.add(policyHandler);
                }
View Full Code Here

        writer.writeEndElement();
    }

    public void resolve(EchoBinding echoBinding, ModelResolver resolver) throws ContributionResolveException {
        PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)echoBinding;
        List<Intent> requiredIntents = new ArrayList<Intent>();
        Intent resolvedIntent = null;
        for (Intent intent : policySetAttachPoint.getRequiredIntents()) {
            resolvedIntent = resolver.resolveModel(Intent.class, intent);
            requiredIntents.add(resolvedIntent);
        }
        policySetAttachPoint.getRequiredIntents().clear();
        policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);

        List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
        PolicySet resolvedPolicySet = null;
        for (PolicySet policySet : policySetAttachPoint.getPolicySets()) {
            resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet);
            resolvedPolicySets.add(resolvedPolicySet);
        }
        policySetAttachPoint.getPolicySets().clear();
        policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
    }
View Full Code Here

        this.binding = binding;
    }

    public Invoker createInvoker(Operation operation) {
        if (binding instanceof PolicySetAttachPoint) {
            PolicySetAttachPoint policySetAttachPoint = (PolicySetAttachPoint)binding;
            if (!policySetAttachPoint.getPolicySets().isEmpty()) {
                return new EchoBindingPoliciedInvoker(policySetAttachPoint.getPolicySets());
            }
        }
        return new EchoBindingInvoker(binding.getURI());
    }
View Full Code Here

        String appliesTo = null;
        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
       
        for (Binding binding : bindings) {
            if (binding instanceof PolicySetAttachPoint) {
                PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                IntentAttachPointType bindingType = policiedBinding.getType();

                //validate policysets specified for the binding
                for (PolicySet policySet : policiedBinding.getPolicySets()) {
                    appliesTo = policySet.getAppliesTo();

                    if (!isPolicySetApplicable(parent, appliesTo, bindingType)) {
                        warning("Policy Set '" + policySet.getName()
                            + "' does not apply to binding type  "
                            + bindingType, binding);

                    }
                }
               
                for (PolicySet policySet : inheritedPolicySets) {
                    appliesTo = policySet.getAppliesTo();
                    if (isPolicySetApplicable(parent, appliesTo, bindingType)) {
                        policiedBinding.getPolicySets().add(policySet);
                    }
                }
               
                //get rid of duplicate entries
                for ( PolicySet policySet : policiedBinding.getPolicySets() ) {
                    policySetTable.put(policySet.getName(), policySet);
                }
                policiedBinding.getPolicySets().clear();
                policiedBinding.getPolicySets().addAll(policySetTable.values());
            }
        }
    }
View Full Code Here

                if ( binding instanceof IntentAttachPoint ) {
                    IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                    resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                }
                if ( binding instanceof PolicySetAttachPoint ) {
                    PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                    resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                }
            }

            // Resolve callback bindings
            if (contract.getCallback() != null) {
                resolveIntents(contract.getCallback().getRequiredIntents(), resolver);
                resolvePolicySets(contract.getCallback().getPolicySets(), resolver);
                for (int i = 0, n = contract.getCallback().getBindings().size(); i < n; i++) {
                    Binding binding = contract.getCallback().getBindings().get(i);
                    extensionProcessor.resolve(binding, resolver);
                   
                    if ( binding instanceof IntentAttachPoint ) {
                        IntentAttachPoint policiedBinding = (IntentAttachPoint)binding;
                        resolveIntents(policiedBinding.getRequiredIntents(), resolver);
                    }
                    if ( binding instanceof PolicySetAttachPoint ) {
                        PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
                        resolvePolicySets(policiedBinding.getPolicySets(), resolver);
                    }
                }
            }
           
            resolveIntents(contract.getRequiredIntents(), resolver);
View Full Code Here

                        implementation.setConstrainingType(componentType.getConstrainingType());
                       
                        if (implementation instanceof PolicySetAttachPoint &&
                            componentType instanceof PolicySetAttachPoint )
                        {
                            PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
                            PolicySetAttachPoint policiedCompType = (PolicySetAttachPoint)componentType;
                           
                            if ( policiedImpl.getPolicySets() != null) {
                                policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
                            }
                            if (policiedImpl.getRequiredIntents() != null) {
                                policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents());
                            }
                        }
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.policy.PolicySetAttachPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.