Package org.osoa.sca.annotations

Examples of org.osoa.sca.annotations.Requires


    private void verifyIntents(Class serviceImplClass, JavaImplementation type) {
        if ( !(type instanceof PolicySetAttachPoint) ) {
            fail("No Intents on the service ");
        }
        Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
        if (serviceImplIntentAnnotation != null) {
            String[] serviceImplIntents = serviceImplIntentAnnotation.value();
            List<Intent> requiredIntents = ((PolicySetAttachPoint)type).getRequiredIntents();
            if (serviceImplIntents.length > 0) {
                if (requiredIntents == null || requiredIntents.size() == 0) {
                    fail("No Intents on the service ");
                }
                Map<String, Intent> intentMap = new HashMap<String, Intent>();
                for (Intent intent : requiredIntents) {
                    intentMap.put(intent.getName().getLocalPart(), intent);
                }
                for (String intent : serviceImplIntents) {
                    assertTrue("ComponentType for Service class " + serviceImplClass.getName()
                        + " did not contain Service Implementation intent "
                        + intent, intentMap.containsKey(intent));
                }
            }
        }

        // This should match what was specified on @Service for a Service Implementation
        // If we use these to get the Service names and we get a null Service
        // name then it would seem that wrong values were put on the @Service annotation
        // or the wrong interfaces were specified on the implements list of the class
        // statement?
        Map<String, org.apache.tuscany.sca.assembly.Service> serviceMap = new HashMap<String, org.apache.tuscany.sca.assembly.Service>();
        for (org.apache.tuscany.sca.assembly.Service service: type.getServices()) {
            serviceMap.put(service.getName(), service);
        }
        for (Class interfaceClass : serviceImplClass.getInterfaces()) {
            Requires interfaceIntentAnnotation = (Requires)interfaceClass.getAnnotation(Requires.class);
            org.apache.tuscany.sca.assembly.Service service = serviceMap.get(interfaceClass.getSimpleName());
            if (service == null) {
                fail("No service defined for interface " + interfaceClass.getSimpleName()
                    + " on Service Implementation "
                    + serviceImplClass.getName());
            }

            if (interfaceIntentAnnotation != null) {
                String[] interfaceIntents = interfaceIntentAnnotation.value();
                List<Intent> requiredIntents = service.getInterfaceContract().getInterface().getRequiredIntents();
                if (interfaceIntents.length > 0) {
                    if (requiredIntents == null || requiredIntents.size() == 0) {
                        fail("No Intents on the service " + service.getName());
                    }
                    Map<String, Intent> intentMap = new HashMap<String, Intent>();
                    for (Intent intent : requiredIntents) {
                        intentMap.put(intent.getName().getLocalPart(), intent);
                    }
                    for (String intent : interfaceIntents) {
                        assertTrue("Interface " + service.getName()
                            + " did not contain Service Interface intent "
                            + intent, intentMap.containsKey(intent));
                    }
                }
            }

            for (Method method : interfaceClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Interface Methods exist on their associated operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = null;
                        for ( ConfiguredOperation confOp : service.getConfiguredOperations() ) {
                            if ( confOp.getName().equals(method.getName()) &&
                                    confOp.getContractName().equals(service.getName()) ) {
                                requiredIntents = confOp.getRequiredIntents();
                            }
                        }
                       
                        if (requiredIntents == null || requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
                        for (String intent : methodIntents) {
                            boolean found = false;
                            for (Intent requiredIntent: requiredIntents) {
                                if (requiredIntent.getName().getLocalPart().equals(intent)) {
                                    found = true;
                                    break;
                                }
                            }
                            assertTrue("Operation " + method.getName()
                                + " did not contain Service Interface method intent "
                                + intent, found);
                        }
                    }
                }
            }
           
            for (Method method : serviceImplClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Implementation Methods exist on their associated
                // operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = null;
                        for ( ConfiguredOperation confOp : ((OperationsConfigurator)type).getConfiguredOperations() ) {
                            if ( confOp.getName().equals(method.getName())  ) {
                                requiredIntents = confOp.getRequiredIntents();
View Full Code Here


     * Read policy intents on the given interface or class
     * @param clazz
     * @param requiredIntents
     */
    private void readIntentsAndPolicySets(Class<?> clazz, List<Intent> requiredIntents, List<PolicySet> policySets) {
        Requires intentAnnotation = clazz.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                for (String intentName : intentNames) {

                    // Add each intent to the list
                    Intent intent = policyFactory.createIntent();
View Full Code Here

     * @param requiredIntents
     */
    private void readIntentsAndPolicySets(Class<?> clazz,
                                          List<Intent> requiredIntents,
                                          List<PolicySet> policySets) {
        Requires intentAnnotation = clazz.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                for (String intentName : intentNames) {

                    // Add each intent to the list
                    Intent intent = policyFactory.createIntent();
View Full Code Here

    private void verifyIntents(Class serviceImplClass, JavaImplementation type) {
        if ( !(type instanceof PolicySetAttachPoint) ) {
            fail("No Intents on the service ");
        }
        Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
        if (serviceImplIntentAnnotation != null) {
            String[] serviceImplIntents = serviceImplIntentAnnotation.value();
            List<Intent> requiredIntents = ((PolicySetAttachPoint)type).getRequiredIntents();
            if (serviceImplIntents.length > 0) {
                if (requiredIntents == null || requiredIntents.size() == 0) {
                    fail("No Intents on the service ");
                }
                Map<String, Intent> intentMap = new HashMap<String, Intent>();
                for (Intent intent : requiredIntents) {
                    intentMap.put(intent.getName().getLocalPart(), intent);
                }
                for (String intent : serviceImplIntents) {
                    assertTrue("ComponentType for Service class " + serviceImplClass.getName()
                        + " did not contain Service Implementation intent "
                        + intent, intentMap.containsKey(intent));
                }
            }
        }

        // This should match what was specified on @Service for a Service Implementation
        // If we use these to get the Service names and we get a null Service
        // name then it would seem that wrong values were put on the @Service annotation
        // or the wrong interfaces were specified on the implements list of the class
        // statement?
        Map<String, org.apache.tuscany.sca.assembly.Service> serviceMap = new HashMap<String, org.apache.tuscany.sca.assembly.Service>();
        for (org.apache.tuscany.sca.assembly.Service service: type.getServices()) {
            serviceMap.put(service.getName(), service);
        }
        for (Class interfaceClass : serviceImplClass.getInterfaces()) {
            Requires interfaceIntentAnnotation = (Requires)interfaceClass.getAnnotation(Requires.class);
            org.apache.tuscany.sca.assembly.Service service = serviceMap.get(interfaceClass.getSimpleName());
            if (service == null) {
                fail("No service defined for interface " + interfaceClass.getSimpleName()
                    + " on Service Implementation "
                    + serviceImplClass.getName());
            }

            if (interfaceIntentAnnotation != null) {
                String[] interfaceIntents = interfaceIntentAnnotation.value();
                List<Intent> requiredIntents = service.getInterfaceContract().getInterface().getRequiredIntents();
                if (interfaceIntents.length > 0) {
                    if (requiredIntents == null || requiredIntents.size() == 0) {
                        fail("No Intents on the service " + service.getName());
                    }
                    Map<String, Intent> intentMap = new HashMap<String, Intent>();
                    for (Intent intent : requiredIntents) {
                        intentMap.put(intent.getName().getLocalPart(), intent);
                    }
                    for (String intent : interfaceIntents) {
                        assertTrue("Interface " + service.getName()
                            + " did not contain Service Interface intent "
                            + intent, intentMap.containsKey(intent));
                    }
                }
            }

            for (Method method : interfaceClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Interface Methods exist on their associated operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = null;
                        for ( ConfiguredOperation confOp : service.getConfiguredOperations() ) {
                            if ( confOp.getName().equals(method.getName()) &&
                                    confOp.getContractName().equals(service.getName()) ) {
                                requiredIntents = confOp.getRequiredIntents();
                            }
                        }
                       
                        if (requiredIntents == null || requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
                        for (String intent : methodIntents) {
                            boolean found = false;
                            for (Intent requiredIntent: requiredIntents) {
                                if (requiredIntent.getName().getLocalPart().equals(intent)) {
                                    found = true;
                                    break;
                                }
                            }
                            assertTrue("Operation " + method.getName()
                                + " did not contain Service Interface method intent "
                                + intent, found);
                        }
                    }
                }
            }
           
            for (Method method : serviceImplClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Implementation Methods exist on their associated
                // operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = null;
                        for ( ConfiguredOperation confOp : ((OperationsConfigurator)type).getConfiguredOperations() ) {
                            if ( confOp.getName().equals(method.getName())  ) {
                                requiredIntents = confOp.getRequiredIntents();
View Full Code Here

     * Read policy intents on the given interface or class
     * @param clazz
     * @param requiredIntents
     */
    private void readIntents(Class<?> clazz, List<Intent> requiredIntents) {
        Requires intentAnnotation = clazz.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                for (String intentName : intentNames) {
                   
                    // Add each intent to the list
                    Intent intent = policyFactory.createIntent();
View Full Code Here

            }
        }
    }
   
    private void readIntents(Method method, List<Intent> requiredIntents) {
        Requires intentAnnotation = method.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                Operation operation = assemblyFactory.createOperation();
                operation.setName(method.getName());
                operation.setUnresolved(true);
                for (String intentName : intentNames) {
View Full Code Here

    private void verifyIntents(Class serviceImplClass, JavaImplementation type) {
        if ( !(type instanceof PolicySetAttachPoint) ) {
            fail("No Intents on the service ");
        }
        Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
        if (serviceImplIntentAnnotation != null) {
            String[] serviceImplIntents = serviceImplIntentAnnotation.value();
            List<Intent> requiredIntents = ((PolicySetAttachPoint)type).getRequiredIntents();
            if (serviceImplIntents.length > 0) {
                if (requiredIntents == null || requiredIntents.size() == 0) {
                    fail("No Intents on the service ");
                }
                Map<String, Intent> intentMap = new HashMap<String, Intent>();
                for (Intent intent : requiredIntents) {
                    intentMap.put(intent.getName().getLocalPart(), intent);
                }
                for (String intent : serviceImplIntents) {
                    assertTrue("ComponentType for Service class " + serviceImplClass.getName()
                        + " did not contain Service Implementation intent "
                        + intent, intentMap.containsKey(intent));
                }
            }
        }

        // This should match what was specified on @Service for a Service Implementation
        // If we use these to get the Service names and we get a null Service
        // name then it would seem that wrong values were put on the @Service annotation
        // or the wrong interfaces were specified on the implements list of the class
        // statement?
        Map<String, org.apache.tuscany.sca.assembly.Service> serviceMap = new HashMap<String, org.apache.tuscany.sca.assembly.Service>();
        for (org.apache.tuscany.sca.assembly.Service service: type.getServices()) {
            serviceMap.put(service.getName(), service);
        }
        for (Class interfaceClass : serviceImplClass.getInterfaces()) {
            Requires interfaceIntentAnnotation = (Requires)interfaceClass.getAnnotation(Requires.class);
            org.apache.tuscany.sca.assembly.Service service = serviceMap.get(interfaceClass.getSimpleName());
            if (service == null) {
                fail("No service defined for interface " + interfaceClass.getSimpleName()
                    + " on Service Implementation "
                    + serviceImplClass.getName());
            }

            if (interfaceIntentAnnotation != null) {
                String[] interfaceIntents = interfaceIntentAnnotation.value();
                List<Intent> requiredIntents = service.getRequiredIntents();
                if (interfaceIntents.length > 0) {
                    if (requiredIntents == null || requiredIntents.size() == 0) {
                        fail("No Intents on the service " + service.getName());
                    }
                    Map<String, Intent> intentMap = new HashMap<String, Intent>();
                    for (Intent intent : requiredIntents) {
                        intentMap.put(intent.getName().getLocalPart(), intent);
                    }
                    for (String intent : interfaceIntents) {
                        assertTrue("Interface " + service.getName()
                            + " did not contain Service Interface intent "
                            + intent, intentMap.containsKey(intent));
                    }
                }
            }

            /*for (Method method : interfaceClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Interface Methods exist on their associated operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = service.getRequiredIntents();
                        if (requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
                        for (String intent : methodIntents) {
                            boolean found = false;
                            for (Intent requiredIntent: requiredIntents) {
                                if (requiredIntent.getName().getLocalPart().equals(intent)) {
                                    for (Operation operation: requiredIntent.getOperations()) {
                                        if (operation.getName().equals(method.getName())) {
                                            found = true;
                                            break;
                                        }
                                    }
                                }
                                if (found)
                                    break;
                            }
                            assertTrue("Operation " + method.getName()
                                + " did not contain Service Interface method intent "
                                + intent, found);
                        }
                    }
                }
            }
            */
            for (Method method : serviceImplClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Implementation Methods exist on their associated
                // operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = ((PolicySetAttachPoint)type).getRequiredIntents();
                        if (requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
View Full Code Here

        verifyIntents(Service6.class, type);
    }

    private void verifyIntents(Class serviceImplClass, JavaImplementation type) {

        Requires serviceImplIntentAnnotation = (Requires)serviceImplClass.getAnnotation(Requires.class);
        if (serviceImplIntentAnnotation != null) {
            String[] serviceImplIntents = serviceImplIntentAnnotation.value();
            List<Intent> requiredIntents = type.getRequiredIntents();
            if (serviceImplIntents.length > 0) {
                if (requiredIntents == null || requiredIntents.size() == 0) {
                    fail("No Intents on the service ");
                }
                Map<String, Intent> intentMap = new HashMap<String, Intent>();
                for (Intent intent : requiredIntents) {
                    intentMap.put(intent.getName().getLocalPart(), intent);
                }
                for (String intent : serviceImplIntents) {
                    assertTrue("ComponentType for Service class " + serviceImplClass.getName()
                        + " did not contain Service Implementation intent "
                        + intent, intentMap.containsKey(intent));
                }
            }
        }

        // This should match what was specified on @Service for a Service Implementation
        // If we use these to get the Service names and we get a null Service
        // name then it would seem that wrong values were put on the @Service annotation
        // or the wrong interfaces were specified on the implements list of the class
        // statement?
        Map<String, org.apache.tuscany.sca.assembly.Service> serviceMap = new HashMap<String, org.apache.tuscany.sca.assembly.Service>();
        for (org.apache.tuscany.sca.assembly.Service service: type.getServices()) {
            serviceMap.put(service.getName(), service);
        }
        for (Class interfaceClass : serviceImplClass.getInterfaces()) {
            Requires interfaceIntentAnnotation = (Requires)interfaceClass.getAnnotation(Requires.class);
            org.apache.tuscany.sca.assembly.Service service = serviceMap.get(interfaceClass.getSimpleName());
            if (service == null) {
                fail("No service defined for interface " + interfaceClass.getSimpleName()
                    + " on Service Implementation "
                    + serviceImplClass.getName());
            }

            if (interfaceIntentAnnotation != null) {
                String[] interfaceIntents = interfaceIntentAnnotation.value();
                List<Intent> requiredIntents = service.getRequiredIntents();
                if (interfaceIntents.length > 0) {
                    if (requiredIntents == null || requiredIntents.size() == 0) {
                        fail("No Intents on the service " + service.getName());
                    }
                    Map<String, Intent> intentMap = new HashMap<String, Intent>();
                    for (Intent intent : requiredIntents) {
                        intentMap.put(intent.getName().getLocalPart(), intent);
                    }
                    for (String intent : interfaceIntents) {
                        assertTrue("Interface " + service.getName()
                            + " did not contain Service Interface intent "
                            + intent, intentMap.containsKey(intent));
                    }
                }
            }

            for (Method method : interfaceClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Interface Methods exist on their associated operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = service.getRequiredIntents();
                        if (requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
                        for (String intent : methodIntents) {
                            boolean found = false;
                            for (Intent requiredIntent: requiredIntents) {
                                if (requiredIntent.getName().getLocalPart().equals(intent)) {
                                    for (Operation operation: requiredIntent.getOperations()) {
                                        if (operation.getName().equals(method.getName())) {
                                            found = true;
                                            break;
                                        }
                                    }
                                }
                                if (found)
                                    break;
                            }
                            assertTrue("Operation " + method.getName()
                                + " did not contain Service Interface method intent "
                                + intent, found);
                        }
                    }
                }
            }

            for (Method method : serviceImplClass.getDeclaredMethods()) {
                Requires methodIntentAnnotation = method.getAnnotation(Requires.class);

                // Verify that each of the Intents on each of the Service
                // Implementation Methods exist on their associated
                // operation.
                if (methodIntentAnnotation != null) {
                    String[] methodIntents = methodIntentAnnotation.value();
                    if (methodIntents.length > 0) {
                        List<Intent> requiredIntents = type.getRequiredIntents();
                        if (requiredIntents.size() == 0) {
                            fail("No Intents on operation " + method.getName());
                        }
View Full Code Here

     * @param requiredIntents
     */
    private void readIntentsAndPolicySets(Class<?> clazz,
                                          List<Intent> requiredIntents,
                                          List<PolicySet> policySets) {
        Requires intentAnnotation = clazz.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                for (String intentName : intentNames) {

                    // Add each intent to the list
                    Intent intent = policyFactory.createIntent();
View Full Code Here

            }
        }
    }
   
    private void readIntents(Method method, List<Intent> requiredIntents) {
        Requires intentAnnotation = method.getAnnotation(Requires.class);
        if (intentAnnotation != null) {
            String[] intentNames = intentAnnotation.value();
            if (intentNames.length != 0) {
                Operation operation = assemblyFactory.createOperation();
                operation.setName(method.getName());
                operation.setUnresolved(true);
                for (String intentName : intentNames) {
View Full Code Here

TOP

Related Classes of org.osoa.sca.annotations.Requires

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.