Package org.apache.tuscany.sca.implementation.spring

Examples of org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement


        try {
            // Deal with the services first....
            Iterator<SpringSCAServiceElement> its = services.iterator();
            while (its.hasNext()) {
                SpringSCAServiceElement serviceElement = its.next();

                Class<?> interfaze;
                if (serviceElement.getType() != null) {
                    interfaze = resolveClass(resolver, serviceElement.getType(), context);
                } else {
                    interfaze = getBeanInterface(resolver, serviceElement.getTarget(), beans, context);
                }

                Service theService = createService(interfaze, serviceElement.getName());
                // Spring allows duplication of bean definitions in multiple context scenario,
                // in such cases, the latest bean definition overrides the older ones, hence
                // we will remove any older definition and use the latest.
                Service duplicate = null;
                for (Service service : componentType.getServices()) {
                    if (service.getName().equals(theService.getName()))
                        duplicate = service;
                }
                if (duplicate != null)
                    componentType.getServices().remove(duplicate);

                componentType.getServices().add(theService);
                // Add this service to the Service / Bean map
                String beanName = serviceElement.getTarget();
                boolean found = false;
                for (SpringBeanElement beanElement : beans) {
                    if (beanName.equals(beanElement.getId())) {
                        if (isValidBeanForService(beanElement)) {
                            // add the required intents and policySets for the service
                            theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
                            theService.getPolicySets().addAll(serviceElement.getPolicySets());
                            implementation.setBeanForService(theService, beanElement);
                            found = true;
                            break;
                        }
                    }
                } // end for

                if (!found) {
                    // REVIEW: Adding a SpringBeanElement "proxy" so that the bean id can be used at runtime to look
                    // up the bean instance from the parent context
                    implementation.setBeanForService(theService,
                                                     new SpringBeanElement(serviceElement.getTarget(), null));
                }
            } // end while

            // Next handle the references
            Iterator<SpringSCAReferenceElement> itr = references.iterator();
View Full Code Here


        // The @target attribute of a <service/> subelement of a <beans/> element
        // MUST have the value of the @name attribute of one of the <bean/>
        // subelements of the <beans/> element.     
        Iterator<SpringSCAServiceElement> its = services.iterator();
        while (its.hasNext()) {
            SpringSCAServiceElement serviceElement = its.next();
            boolean targetBeanExists = false;
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                if (serviceElement.getTarget().equals(beanElement.getId()))
                    targetBeanExists = true;
            }
            if (!targetBeanExists) {
                // REVIEW: [rfeng] The target bean can exist in the parent Spring application context which we don't know
                // until runtime
View Full Code Here

        try {
            // Deal with the services first....
            Iterator<SpringSCAServiceElement> its = services.iterator();
            while (its.hasNext()) {
                SpringSCAServiceElement serviceElement = its.next();
                Class<?> interfaze = resolveClass(resolver, serviceElement.getType(), context);
                Service theService = createService(interfaze, serviceElement.getName());
                // Spring allows duplication of bean definitions in multiple context scenario,
                // in such cases, the latest bean definition overrides the older ones, hence
                // we will remove any older definition and use the latest.
                Service duplicate = null;
                for (Service service : componentType.getServices()) {
                    if (service.getName().equals(theService.getName()))
                        duplicate = service;
                }
                if (duplicate != null)
                    componentType.getServices().remove(duplicate);

                componentType.getServices().add(theService);
                // Add this service to the Service / Bean map
                String beanName = serviceElement.getTarget();
                boolean found = false;
                for (SpringBeanElement beanElement : beans) {
                    if (beanName.equals(beanElement.getId())) {
                        if (isValidBeanForService(beanElement)) {
                            // add the required intents and policySets for the service
                            theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
                            theService.getPolicySets().addAll(serviceElement.getPolicySets());
                            implementation.setBeanForService(theService, beanElement);
                            found = true;
                            break;
                        }
                    }
                } // end for
               
                if (!found) {
                    // REVIEW: Adding a SpringBeanElement "proxy" so that the bean id can be used at runtime to look
                    // up the bean instance from the parent context
                    implementation.setBeanForService(theService,
                                                     new SpringBeanElement(serviceElement.getTarget(), null));
                }
            } // end while

            // Next handle the references
            Iterator<SpringSCAReferenceElement> itr = references.iterator();
View Full Code Here

        // The @target attribute of a <service/> subelement of a <beans/> element
        // MUST have the value of the @name attribute of one of the <bean/>
        // subelements of the <beans/> element.     
        Iterator<SpringSCAServiceElement> its = services.iterator();
        while (its.hasNext()) {
            SpringSCAServiceElement serviceElement = its.next();
            boolean targetBeanExists = false;
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                if (serviceElement.getTarget().equals(beanElement.getId()))
                    targetBeanExists = true;
            }
            if (!targetBeanExists) {
                // REVIEW: [rfeng] The target bean can exist in the parent Spring application context which we don't know
                // until runtime
View Full Code Here

    public BeanDefinition parse(Element element, ParserContext parserContext) {
        BeanDefinitionRegistry registry = parserContext.getRegistry();
        if (registry instanceof SCAGenericApplicationContext) {
            SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
            SpringSCAServiceElement serviceElement =
                new SpringSCAServiceElement(getAttribute(element, "name"), getAttribute(element, "target"));
            serviceElement.setType(getAttribute(element, "type"));

            String requires = getAttribute(element, "requires");
            if (requires != null) {
                List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
                serviceElement.getIntentNames().addAll(qnames);
            }

            String policySets = getAttribute(element, "policySets");
            if (policySets != null) {
                List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
                serviceElement.getPolicySetNames().addAll(qnames);
            }

            context.addSCAServiceElement(serviceElement);
        }
        // do nothing, handled by Tuscany
View Full Code Here

        try {
            // Deal with the services first....
            Iterator<SpringSCAServiceElement> its = services.iterator();
            while (its.hasNext()) {
                SpringSCAServiceElement serviceElement = its.next();

                Class<?> interfaze;
                if (serviceElement.getType() != null) {
                    interfaze = resolveClass(resolver, serviceElement.getType(), context);
                } else {
                    interfaze = getBeanInterface(resolver, serviceElement.getTarget(), beans, context);
                }

                Service theService = createService(interfaze, serviceElement.getName());
                // Spring allows duplication of bean definitions in multiple context scenario,
                // in such cases, the latest bean definition overrides the older ones, hence
                // we will remove any older definition and use the latest.
                Service duplicate = null;
                for (Service service : componentType.getServices()) {
                    if (service.getName().equals(theService.getName()))
                        duplicate = service;
                }
                if (duplicate != null)
                    componentType.getServices().remove(duplicate);

                componentType.getServices().add(theService);
                // Add this service to the Service / Bean map
                String beanName = serviceElement.getTarget();
                boolean found = false;
                for (SpringBeanElement beanElement : beans) {
                    if (beanName.equals(beanElement.getId())) {
                        if (isValidBeanForService(beanElement)) {
                            // add the required intents and policySets for the service
                            theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
                            theService.getPolicySets().addAll(serviceElement.getPolicySets());
                            implementation.setBeanForService(theService, beanElement);
                            found = true;
                            break;
                        }
                    }
                } // end for

                if (!found) {
                    // REVIEW: Adding a SpringBeanElement "proxy" so that the bean id can be used at runtime to look
                    // up the bean instance from the parent context
                    implementation.setBeanForService(theService,
                                                     new SpringBeanElement(serviceElement.getTarget(), null));
                }
            } // end while

            // Next handle the references
            Iterator<SpringSCAReferenceElement> itr = references.iterator();
View Full Code Here

        // The @target attribute of a <service/> subelement of a <beans/> element
        // MUST have the value of the @name attribute of one of the <bean/>
        // subelements of the <beans/> element.     
        Iterator<SpringSCAServiceElement> its = services.iterator();
        while (its.hasNext()) {
            SpringSCAServiceElement serviceElement = its.next();
            boolean targetBeanExists = false;
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                if (serviceElement.getTarget().equals(beanElement.getId()))
                    targetBeanExists = true;
            }
            if (!targetBeanExists) {
                // REVIEW: [rfeng] The target bean can exist in the parent Spring application context which we don't know
                // until runtime
View Full Code Here

                                XMLStreamReader ireader = getApplicationContextReader(resolver, resourcePath);
                                // Read the context definition for the identified imported resource
                                readContextDefinition(resolver, ireader, contextPath, beans, services, references, scaproperties);
                            }
                        } else if (SpringImplementationConstants.SERVICE_ELEMENT.equals(qname)) {
                            SpringSCAServiceElement service =
                                new SpringSCAServiceElement(reader.getAttributeValue(null, "name"), reader
                                    .getAttributeValue(null, "type"), reader.getAttributeValue(null, "target"));
                            services.add(service);
                        } else if (SpringImplementationConstants.REFERENCE_ELEMENT.equals(qname)) {
                            SpringSCAReferenceElement reference =
                                new SpringSCAReferenceElement(reader.getAttributeValue(null, "name"), reader
View Full Code Here

        try {
            // Deal with the services first....
            Iterator<SpringSCAServiceElement> its = services.iterator();
            while (its.hasNext()) {
                SpringSCAServiceElement serviceElement = its.next();
                Class<?> interfaze = resolveClass(resolver, serviceElement.getType());
                Service theService = createService(interfaze, serviceElement.getName());
                componentType.getServices().add(theService);
                // Add this service to the Service / Bean map
                String beanName = serviceElement.getTarget();
                for (SpringBeanElement beanElement : beans) {
                    if (beanName.equals(beanElement.getId())) {
                        implementation.setBeanForService(theService, beanElement);
                    }
                } // end for
View Full Code Here

    public BeanDefinition parse(Element element, ParserContext parserContext) {
        BeanDefinitionRegistry registry = parserContext.getRegistry();
        if (registry instanceof SCAGenericApplicationContext) {
            SCAGenericApplicationContext context = (SCAGenericApplicationContext)registry;
            SpringSCAServiceElement serviceElement =
                new SpringSCAServiceElement(getAttribute(element, "name"), getAttribute(element, "target"));
            serviceElement.setType(getAttribute(element, "type"));

            String requires = getAttribute(element, "requires");
            if (requires != null) {
                List<QName> qnames = ScaNamespaceHandler.resolve(element, requires);
                serviceElement.getIntentNames().addAll(qnames);
            }

            String policySets = getAttribute(element, "policySets");
            if (policySets != null) {
                List<QName> qnames = ScaNamespaceHandler.resolve(element, policySets);
                serviceElement.getPolicySetNames().addAll(qnames);
            }

            context.addSCAServiceElement(serviceElement);
        }
        // do nothing, handled by Tuscany
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement

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.