Package org.apache.tuscany.sca.policy

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


                        implementation.getReferences().addAll(componentType.getReferences());
                        implementation.getProperties().addAll(componentType.getProperties());

                        if (implementation instanceof PolicySubject &&
                                componentType instanceof PolicySubject ) {
                            PolicySubject policiedImpl = (PolicySubject)implementation;
                            PolicySubject policiedCompType = (PolicySubject)componentType;

                            if ( policiedImpl.getPolicySets() != null) {
                                policiedImpl.getPolicySets().addAll(policiedCompType.getPolicySets());
                            }
                            if (policiedImpl.getRequiredIntents() != null) {
                                policiedImpl.getRequiredIntents().addAll(policiedCompType.getRequiredIntents());
                            }
                        }
                    }
                }
            }
View Full Code Here


                    }
                   
                    for (int i = 0; i < nodes.getLength(); i++) {
                        Node node = nodes.item(i);
                        String index = getStructuralURI(node);
                        PolicySubject subject = lookup(composite, index);
                        if ( subject != null )
                          subjects.add(subject);
                    }
                }
            }
View Full Code Here

     * @param reader
     */
    private void readIntents(Object subject, Operation operation, XMLStreamReader reader) {
        if (!(subject instanceof PolicySubject))
            return;
        PolicySubject intentAttachPoint = (PolicySubject)subject;
        String value = reader.getAttributeValue(null, REQUIRES);
        if (value != null) {
            List<Intent> requiredIntents = intentAttachPoint.getRequiredIntents();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                Intent intent = policyFactory.createIntent();
                intent.setName(qname);
                if (operation != null) {
View Full Code Here

     */
    private void readPolicySets(Object subject, Operation operation, XMLStreamReader reader) {
        if (!(subject instanceof PolicySubject)) {
            return;
        }
        PolicySubject policySubject = (PolicySubject)subject;
        String value = reader.getAttributeValue(null, POLICY_SETS);
        if (value != null) {
            List<PolicySet> policySets = policySubject.getPolicySets();
            for (StringTokenizer tokens = new StringTokenizer(value); tokens.hasMoreTokens();) {
                QName qname = getQNameValue(reader, tokens.nextToken());
                PolicySet policySet = policyFactory.createPolicySet();
                policySet.setName(qname);
                if (operation != null) {
View Full Code Here

     */
    private XAttr writeIntents(Object subject, Operation operation) {
        if (!(subject instanceof PolicySubject)) {
            return null;
        }
        PolicySubject intentAttachPoint = (PolicySubject)subject;
        List<QName> qnames = new ArrayList<QName>();
        for (Intent intent: intentAttachPoint.getRequiredIntents()) {
            qnames.add(intent.getName());
        }
        return new XAttr(Constants.REQUIRES, qnames);
    }
View Full Code Here

     */
    private XAttr writePolicySets(Object subject, Operation operation) {
        if (!(subject instanceof PolicySubject)) {
            return null;
        }
        PolicySubject policySetAttachPoint = (PolicySubject)subject;
        List<QName> qnames = new ArrayList<QName>();
        for (PolicySet policySet: policySetAttachPoint.getPolicySets()) {
            qnames.add(policySet.getName());
        }
        return new XAttr(Constants.POLICY_SETS, qnames);
    }
View Full Code Here

        return new XAttr(Constants.POLICY_SETS, qnames);
    }
   
    public void resolvePolicies(Object subject, ModelResolver resolver, ProcessorContext context) {
        if ( subject instanceof PolicySubject ) {
            PolicySubject policySetAttachPoint = (PolicySubject)subject;
           
            List<Intent> requiredIntents = new ArrayList<Intent>();
            Intent resolvedIntent = null;
           
            if ( policySetAttachPoint.getRequiredIntents() != null && policySetAttachPoint.getRequiredIntents().size() > 0 ) {
                for ( Intent intent : policySetAttachPoint.getRequiredIntents() ) {
                    resolvedIntent = resolver.resolveModel(Intent.class, intent, context);
                    requiredIntents.add(resolvedIntent);
                }
                policySetAttachPoint.getRequiredIntents().clear();
                policySetAttachPoint.getRequiredIntents().addAll(requiredIntents);
            }
           
            if ( policySetAttachPoint.getPolicySets() != null && policySetAttachPoint.getPolicySets().size() > 0 ) {
                List<PolicySet> resolvedPolicySets = new ArrayList<PolicySet>();
                PolicySet resolvedPolicySet = null;
                for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
                    resolvedPolicySet = resolver.resolveModel(PolicySet.class, policySet, context);
                    resolvedPolicySets.add(resolvedPolicySet);
                }
                policySetAttachPoint.getPolicySets().clear();
                policySetAttachPoint.getPolicySets().addAll(resolvedPolicySets);
            }
        }
    }
View Full Code Here

    @Override
    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
        // Check if a field that is not an SCA reference has any policySet/intent annotations
        JavaElementImpl element = new JavaElementImpl(field);
        if (!type.getReferenceMembers().values().contains(element)) {
            PolicySubject subject = assemblyFactory.createComponent();
            readPolicySetAndIntents(subject, field);
            if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
                return;
            }
            throw new ServiceRuntimeException(
                                              "[JCA70002,JCA70005] Field that is not an SCA reference cannot have policySet/intent annotations: " + field);
        }
View Full Code Here

    }

    @Override
    public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type) {
        if (!type.getReferenceMembers().values().contains(parameter)) {
            PolicySubject subject = assemblyFactory.createComponent();
            readPolicySetAndIntents(subject, parameter);
            if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
                return;
            }
            throw new ServiceRuntimeException(
                                              "[JCA70002,JCA70005] Constructor parameter that is not an SCA reference cannot have policySet/intent annotations: " + parameter);
        }
View Full Code Here

        for (JavaElementImpl element : type.getReferenceMembers().values()) {
            annotatedElements.add(element.getAnchor());
        }
        // Check if a field that is not an SCA reference has any policySet/intent annotations
        if (!annotatedElements.contains(method)) {
            PolicySubject subject = assemblyFactory.createComponent();
            readPolicySetAndIntents(subject, method);
            if (subject.getPolicySets().isEmpty() && subject.getRequiredIntents().isEmpty()) {
                return;
            }
            throw new ServiceRuntimeException(
                                              "[JCA70002,JCA70005] Method that is not an SCA reference cannot have policySet/intent annotations: " + method);
        }
View Full Code Here

TOP

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

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.