Examples of SpringBeanElement


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

                                       List<SpringBeanElement> beans,
                                       List<SpringSCAServiceElement> services,
                                       List<SpringSCAReferenceElement> references,
                                       List<SpringSCAPropertyElement> scaproperties, ProcessorContext context) throws ContributionReadException {

        SpringBeanElement bean = null;

        try {
            boolean completed = false;
            while (!completed) {
                switch (reader.next()) {
                    case START_ELEMENT:
                        QName qname = reader.getName();
                        //System.out.println("Spring TypeLoader - found element with name: " + qname.toString());
                        if (SpringImplementationConstants.IMPORT_ELEMENT.equals(qname)) {
                          //FIXME - put the sequence of code below which gets the ireader into a subsidiary method
                            String location = reader.getAttributeValue(null, "resource");
                            if (location != null) {
                              // FIXME - need to find a right way of generating this path
                                String resourcePath = contextPath.substring(0, contextPath.lastIndexOf("/")+1) + location;
                                XMLStreamReader ireader = getApplicationContextReader(resolver, resourcePath, context);
                                // Read the context definition for the identified imported resource
                                readContextDefinition(resolver, ireader, contextPath, beans, services, references, scaproperties, context);
                            }
                        } else if (SpringImplementationConstants.SCA_SERVICE_ELEMENT.equals(qname)) {
                          // The value of the @name attribute of an <sca:service/> subelement of a <beans/>
                          // element MUST be unique amongst the <sca:service/> subelements of the <beans/> element.
                          if (!services.isEmpty() && (services.contains(reader.getAttributeValue(null, "name"))))
                                error("ScaServiceNameNotUnique", resolver);
                         
                          SpringSCAServiceElement service =
                                new SpringSCAServiceElement(reader.getAttributeValue(null, "name"),
                                              reader.getAttributeValue(null, "target"));
                            if (reader.getAttributeValue(null, "type") != null)
                              service.setType(reader.getAttributeValue(null, "type"));
                            policyProcessor.readPolicies(service, reader);
                            services.add(service);
                        } else if (SpringImplementationConstants.SCA_REFERENCE_ELEMENT.equals(qname)) {
                          // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
                          // element MUST be unique amongst the @name attributes of the <sca:reference/> subelements,
                          // of the <beans/> element.
                          if (!references.isEmpty() && (references.contains(reader.getAttributeValue(null, "name"))))
                                error("ScaReferenceNameNotUnique", resolver);
                         
                          SpringSCAReferenceElement reference =
                                new SpringSCAReferenceElement(reader.getAttributeValue(null, "name"),
                                                reader.getAttributeValue(null, "type"));
                            if (reader.getAttributeValue(null, "default") != null)
                              reference.setDefaultBean(reader.getAttributeValue(null, "default"));
                            policyProcessor.readPolicies(reference, reader);
                            references.add(reference);                           
                        } else if (SpringImplementationConstants.SCA_PROPERTY_ELEMENT.equals(qname)) {
                          // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
                          // element MUST be unique amongst the @name attributes of the <sca:property/> subelements,
                          // of the <beans/> element.
                          if (!scaproperties.isEmpty() && (scaproperties.contains(reader.getAttributeValue(null, "name"))))
                                error("ScaPropertyNameNotUnique", resolver);
                         
                          SpringSCAPropertyElement scaproperty =
                                new SpringSCAPropertyElement(reader.getAttributeValue(null, "name"), reader
                                    .getAttributeValue(null, "type"));
                            scaproperties.add(scaproperty);
                        } else if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
                            bean = new SpringBeanElement(reader.getAttributeValue(null, "id"),
                                           reader.getAttributeValue(null, "class"));
                            if (reader.getAttributeValue(null, "abstract") != null)
                              if (reader.getAttributeValue(null, "abstract").equals("true"))
                                bean.setAbstractBean(true);
                            if (reader.getAttributeValue(null, "parent") != null)
                              if (!reader.getAttributeValue(null, "parent").equals(""))
                                bean.setParentAttribute(true);                            
                            if (reader.getAttributeValue(null, "factory-bean") != null)
                              if (!reader.getAttributeValue(null, "factory-bean").equals(""))
                                bean.setFactoryBeanAttribute(true);                             
                            if (reader.getAttributeValue(null, "factory-method") != null)
                              if (!reader.getAttributeValue(null, "factory-method").equals(""))
                                bean.setFactoryMethodAttribute(true);                            
                            // Set the first name as bean name, when the @id attribute is absent.
                            if (reader.getAttributeValue(null, "id") == null) {
                              if (reader.getAttributeValue(null, "name") != null) {
                                String[] names = (reader.getAttributeValue(null, "name")).split(",");
                                bean.setId(names[0]);
                              }
                            }
                            beans.add(bean);
                            // Read the <bean> element and its child elements
                            readBeanDefinition(reader, bean, beans);
View Full Code Here

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

     */
    private void readBeanDefinition(XMLStreamReader reader,
                                    SpringBeanElement bean,
                                    List<SpringBeanElement> beans) throws ContributionReadException {

      SpringBeanElement innerbean = null;
        SpringPropertyElement property = null;
        SpringConstructorArgElement constructorArg = null;
       
        try {
            boolean completed = false;           
            while (!completed) {
                switch (reader.next()) {
                    case START_ELEMENT:
                        QName qname = reader.getName();
                        if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
                          innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
                                    .getAttributeValue(null, "class"));
                          // Set the first name as bean name, when the @id attribute is absent.
                            if (reader.getAttributeValue(null, "id") == null) {
                              if (reader.getAttributeValue(null, "name") != null) {
                                String[] names = (reader.getAttributeValue(null, "name")).split(",");
                                innerbean.setId(names[0]);
                              }
                            }
                            innerbean.setInnerBean(true);
                            beans.add(innerbean);
                            readBeanDefinition(reader, innerbean, beans);
                        } else if (SpringImplementationConstants.PROPERTY_ELEMENT.equals(qname)) {
                            property = new SpringPropertyElement(reader.getAttributeValue(null, "name"));
                            if (reader.getAttributeValue(null, "ref") != null)
View Full Code Here

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

                                 SpringBeanElement bean,
                                 List<SpringBeanElement> beans,
                                 SpringPropertyElement property,
                                 SpringConstructorArgElement constructorArg) throws ContributionReadException {
     
      SpringBeanElement innerbean = null;
       
        try {
            boolean completed = false;           
            while (!completed) {
                switch (reader.next()) {
                    case START_ELEMENT:
                        QName qname = reader.getName();
                        if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
                          innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
                                    .getAttributeValue(null, "class"));
                          // Set the first name as bean name, when the @id attribute is absent.
                            if (reader.getAttributeValue(null, "id") == null)
                              if (reader.getAttributeValue(null, "name") != null) {
                                String[] names = (reader.getAttributeValue(null, "name")).split(",");
                                innerbean.setId(names[0]);
                              }
                            innerbean.setInnerBean(true);
                            beans.add(innerbean);
                            readBeanDefinition(reader, innerbean, beans);
                        } else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
                          String ref = reader.getAttributeValue(null, "bean");
                            if (property != null) property.addRef(ref);
View Full Code Here

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

            // If there are no explicit service elements, then expose all the beans
            if (services.isEmpty()) {
                itb = beans.iterator();
                // Loop through all the beans found
                while (itb.hasNext()) {
                    SpringBeanElement beanElement = itb.next();
                    // If its not a valid bean for service, ignore it
                    if (!isvalidBeanForService(beanElement)) continue;
                    // Load the Spring bean class
                    Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
                    // Introspect the bean
                    beanIntrospector =
                        new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
                    ComponentType beanComponentType = assemblyFactory.createComponentType();
                    javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
                    // Set the service name as bean name
                    for (Service componentService : beanComponentType.getServices())                     
                      componentService.setName(beanElement.getId());
                    // Get the service interface defined by this Spring Bean and add to
                    // the component type of the Spring Assembly
                    List<Service> beanServices = beanComponentType.getServices();
                    componentType.getServices().addAll(beanServices);
                    // Add these services to the Service / Bean map
                    for (Service beanService : beanServices) {
                        implementation.setBeanForService(beanService, beanElement);
                    }
                } // end while
            } // end if

            itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                // Ignore if the bean has no properties and constructor arguments
                if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
                  continue;

                Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
                // Introspect the bean
                beanIntrospector =
                    new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
                ComponentType beanComponentType = assemblyFactory.createComponentType();
                javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
                Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
                JavaConstructorImpl constructor = javaImplementation.getConstructor();
                // Get the references by this Spring Bean and add the unresolved ones to
                // the component type of the Spring Assembly
                List<Reference> beanReferences = beanComponentType.getReferences();
                List<Property> beanProperties = beanComponentType.getProperties();

                Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
                while (itp.hasNext()) {
                    SpringPropertyElement propertyElement = itp.next();
                    for (String propertyRef : propertyElement.getRefs()) {
                      if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
                          // This means an unresolved reference from the spring bean...
                        for (Reference reference : beanReferences) {
                              if (propertyElement.getName().equals(reference.getName())) {
                                // The name of the reference in this case is the string in
                                  // the @ref attribute of the Spring property element, NOT the
                                  // name of the field in the Spring bean....
                                  reference.setName(propertyRef);
                                  componentType.getReferences().add(reference);
                              } // end if
                          } // end for
 
                        // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
                        for (Property scaproperty : beanProperties) {
                              if (propertyElement.getName().equals(scaproperty.getName())) {
                                // The name of the reference in this case is the string in
                                  // the @ref attribute of the Spring property element, NOT the
                                  // name of the field in the Spring bean....
                                Class<?> interfaze = resolveClass(resolver, (propertyMap.get(propertyElement.getName()).getType()).getName(), context);
                                  Reference theReference = createReference(interfaze, propertyRef);
                                  implementation.setUnresolvedBeanRef(propertyRef, theReference);
                              } // end if
                        } // end for
                      } // end if
                    } // end for
                } // end while

                Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
                while (itcr.hasNext()) {
                  SpringConstructorArgElement conArgElement = itcr.next();
                  for (String constructorArgRef : conArgElement.getRefs()) {
                    if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
                        for (JavaParameterImpl parameter : constructor.getParameters()) {
View Full Code Here

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

                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();
            while (itr.hasNext()) {
                SpringSCAReferenceElement referenceElement = itr.next();
                Class<?> interfaze = resolveClass(resolver, referenceElement.getType(), context);
                Reference theReference = createReference(interfaze, referenceElement.getName());
                // Override the older bean definition with the latest ones
                // for the duplicate definitions found.
                Reference duplicate = null;
                for (Reference reference : componentType.getReferences()) {
                    if (reference.getName().equals(theReference.getName()))
                        duplicate = reference;
                }
                if (duplicate != null)
                    componentType.getReferences().remove(duplicate);

                // add the required intents and policySets for this reference
                theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents());
                theReference.getPolicySets().addAll(referenceElement.getPolicySets());
                componentType.getReferences().add(theReference);
            } // end while

            // Next handle the properties
            Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
            while (itsp.hasNext()) {
                SpringSCAPropertyElement scaproperty = itsp.next();
                // Create a component type property if the SCA property element has a name
                // and a type declared...
                if (scaproperty.getType() != null && scaproperty.getName() != null) {
                    Property theProperty = assemblyFactory.createProperty();
                    theProperty.setName(scaproperty.getName());
                    // Get the Java class and then an XSD element type for the property
                    Class<?> propType = Class.forName(scaproperty.getType());
                    theProperty.setXSDType(JavaXMLMapper.getXMLType(propType));
                    // Override the older bean definition with the latest ones
                    // for the duplicate definitions found.
                    Property duplicate = null;
                    for (Property property : componentType.getProperties()) {
                        if (property.getName().equals(theProperty.getName()))
                            duplicate = property;
                    }
                    if (duplicate != null)
                        componentType.getProperties().remove(duplicate);

                    componentType.getProperties().add(theProperty);
                    // Remember the Java Class (ie the type) for this property
                    implementation.setPropertyClass(theProperty.getName(), propType);
                } // end if
            } // end while

            // Finally deal with the beans
            Iterator<SpringBeanElement> itb;
            // If there are no explicit service elements, then expose all the beans
            if (services.isEmpty()) {
                itb = beans.iterator();
                // Loop through all the beans found
                while (itb.hasNext()) {
                    SpringBeanElement beanElement = itb.next();

                    // If its not a valid bean for service, ignore it
                    if (!isValidBeanForService(beanElement)) {
                        continue;
                    }
                    try {
                        // Load the Spring bean class
                        Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
                        // Introspect the bean
                        beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
                        ComponentType beanComponentType = assemblyFactory.createComponentType();
                        javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
                        // Set the service name as bean name
                        for (Service componentService : beanComponentType.getServices()) {
                            componentService.setName(beanElement.getId());
                        }
                        // Get the service interface defined by this Spring Bean and add to
                        // the component type of the Spring Assembly
                        List<Service> beanServices = beanComponentType.getServices();
                        componentType.getServices().addAll(beanServices);
                        // Add these services to the Service / Bean map
                        for (Service beanService : beanServices) {
                            implementation.setBeanForService(beanService, beanElement);
                        }
                    } catch (Throwable e) {
                        // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
                        // Tuscany is not happy with that during the introspection
                        log.log(Level.SEVERE, e.getMessage(), e);
                    }
                } // end while
            } // end if

            // [rfeng] We only try to implicitly map Spring beans if no sca:reference or sca:property is present
            if (references.isEmpty() && scaproperties.isEmpty()) {
                itb = beans.iterator();
                while (itb.hasNext()) {
                    SpringBeanElement beanElement = itb.next();

                    // If its not a valid bean for service, ignore it
                    if (!isValidBeanForService(beanElement)) {
                        continue;
                    }
                    // Ignore if the bean has no properties and constructor arguments
                    if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
                        continue;

                    ComponentType beanComponentType = assemblyFactory.createComponentType();

                    try {
                        Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
                        // Introspect the bean
                        beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
                        javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
                    } catch (Exception e) {
                        // [rfeng] FIXME: Some Spring beans have constructors that take pararemters injected by Spring and
                        // Tuscany is not happy with that during the introspection
                        log.log(Level.SEVERE, e.getMessage(), e);
                        continue;
                    }
                    Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
                    JavaConstructorImpl constructor = javaImplementation.getConstructor();
                    // Get the references by this Spring Bean and add the unresolved ones to
                    // the component type of the Spring Assembly
                    List<Reference> beanReferences = beanComponentType.getReferences();
                    List<Property> beanProperties = beanComponentType.getProperties();

                    Set<String> excludedNames = new HashSet<String>();
                    Iterator<SpringPropertyElement> itp = beanElement.getProperties().iterator();
                    while (itp.hasNext()) {
                        SpringPropertyElement propertyElement = itp.next();
                        // Exclude the reference that is also known as a spring property
                        excludedNames.add(propertyElement.getName());
                        for (String propertyRef : propertyElement.getRefs()) {
                            if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
                                // This means an unresolved reference from the spring bean...
                                for (Reference reference : beanReferences) {
                                    if (propertyElement.getName().equals(reference.getName())) {
                                        // The name of the reference in this case is the string in
                                        // the @ref attribute of the Spring property element, NOT the
                                        // name of the field in the Spring bean....
                                        reference.setName(propertyRef);
                                        // reference.setWiredByImpl(true);
                                        componentType.getReferences().add(reference);
                                        break;
                                    } // end if
                                } // end for

                                // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
                                for (Property scaproperty : beanProperties) {
                                    if (propertyElement.getName().equals(scaproperty.getName())) {
                                        // The name of the reference in this case is the string in
                                        // the @ref attribute of the Spring property element, NOT the
                                        // name of the field in the Spring bean....
                                        Class<?> interfaze =
                                            resolveClass(resolver,
                                                         (propertyMap.get(propertyElement.getName()).getType())
                                                             .getName(),
                                                         context);
                                        Reference theReference = createReference(interfaze, propertyRef);
                                        implementation.setUnresolvedBeanRef(propertyRef, theReference);
                                        break;
                                    } // end if
                                } // end for
                            } // end if
                        } // end for
                    } // end while

                    Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
                    while (itcr.hasNext()) {
                        SpringConstructorArgElement conArgElement = itcr.next();
                        for (String constructorArgRef : conArgElement.getRefs()) {
                            if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
                                for (JavaParameterImpl parameter : constructor.getParameters()) {
View Full Code Here

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

    private Class<?> getBeanInterface(ModelResolver resolver,
                                      String target,
                                      List<SpringBeanElement> beans,
                                      ProcessorContext context) throws ClassNotFoundException {
        SpringBeanElement bean = null;
        for (SpringBeanElement sbe : beans) {
            if (sbe.getId().equals(target)) {
                bean = sbe;
                break;
            }
        }
        if (bean == null) {
            error(context.getMonitor(), "TargetBeanDoesNotExist", null, target);
            return null;
        }

        Class<?> beanClass = resolveClass(resolver, bean.getClassName(), context);
        List<Class<?>> ifaces = javaIntrospectionHelper.getAllInterfaces(beanClass);
        for (Class<?> interfaze : ifaces) {
            if (interfaze.isAnnotationPresent(Remotable.class)) {
                return interfaze;
            }
View Full Code Here

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

        if (ref != null) {
            // Scan over the beans looking for a match
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                // Does the bean name match the ref?
                if (ref.equals(beanElement.getId())) {
                    unresolved = false;
                    break;
                } // end if
            } // end while
              // Scan over the SCA reference elements looking for a match
View Full Code Here

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

        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
                warning(monitor, "TargetBeanDoesNotExist", beans);
            }
        } // end while

        // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
        // element MUST be unique amongst the @name attributes of the <sca:property/>
        // subelements and the <bean/> subelements of the <beans/> element.
        //                   AND
        // The @default attribute of a <sca:reference/> subelement of a <beans/> 
        // element MUST have the value of the @name attribute of one of the <bean/>
        // subelements of the <beans/> element.
        Iterator<SpringSCAReferenceElement> itr = references.iterator();
        while (itr.hasNext()) {
            SpringSCAReferenceElement referenceElement = itr.next();
            boolean defaultBeanExists = false;
            boolean isUniqueReferenceName = true;
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                if (referenceElement.getDefaultBean() != null)
                    if (referenceElement.getDefaultBean().equals(beanElement.getId()))
                        defaultBeanExists = true;
                if (referenceElement.getName().equals(beanElement.getId()))
                    isUniqueReferenceName = false;
            }
            Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
            while (itp.hasNext()) {
                SpringSCAPropertyElement propertyElement = itp.next();
                if (referenceElement.getName().equals(propertyElement.getName()))
                    isUniqueReferenceName = false;
            }
            if (!defaultBeanExists && referenceElement.getDefaultBean() != null)
                error(monitor, "DefaultBeanDoesNotExist", beans);
            if (!isUniqueReferenceName)
                error(monitor, "ScaReferenceNameNotUnique", beans);
        } // end while

        // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
        // element MUST be unique amongst the @name attributes of the <sca:reference/>
        // subelements and the <bean/> subelements of the <beans/> element.     
        Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
        while (itp.hasNext()) {
            SpringSCAPropertyElement propertyElement = itp.next();
            boolean isUniquePropertyName = true;
            Iterator<SpringBeanElement> itb = beans.iterator();
            while (itb.hasNext()) {
                SpringBeanElement beanElement = itb.next();
                if (propertyElement.getName().equals(beanElement.getId()))
                    isUniquePropertyName = false;
            }
            Iterator<SpringSCAReferenceElement> itrp = references.iterator();
            while (itrp.hasNext()) {
                SpringSCAReferenceElement referenceElement = itrp.next();
View Full Code Here

Examples of org.apache.tuscany.sca.implementation.spring.elements.tie.SpringBeanElement

    public synchronized List<SpringBeanElement> getBeanElements() {
        if (beanElements == null) {
            beanElements = new ArrayList<SpringBeanElement>();
            for (String name : getBeanDefinitionNames()) {
                BeanDefinition def = getBeanDefinition(name);
                SpringBeanElement beanElement = new SpringBeanElement(name, def.getBeanClassName());
                beanElements.add(beanElement);
                beanElement.setAbstractBean(def.isAbstract());
                beanElement.setFactoryBeanAttribute(def.getFactoryBeanName() != null);
                beanElement.setFactoryMethodAttribute(def.getFactoryMethodName() != null);
                beanElement.setParentAttribute(def.getParentName() != null);
                beanElement.setInnerBean(beanElement.getId() == null);

                ConstructorArgumentValues args = def.getConstructorArgumentValues();
                for (Map.Entry<Integer, ValueHolder> e: args.getIndexedArgumentValues().entrySet()) {
                    ValueHolder holder = e.getValue();
                    SpringConstructorArgElement arg = new SpringConstructorArgElement(holder.getType());
                    arg.setIndex(e.getKey());
                    beanElement.addCustructorArgs(arg);
                }

                MutablePropertyValues values = def.getPropertyValues();
                for (PropertyValue p : values.getPropertyValueList()) {
                    SpringPropertyElement propertyElement = new SpringPropertyElement(p.getName());
                    Object value = p.getValue();
                    configurePropertyElement(propertyElement, value);
                    beanElement.getProperties().add(propertyElement);
                }
            }
        }
        return beanElements;
    }
View Full Code Here

Examples of org.apache.tuscany.sca.implementation.spring.xml.SpringBeanElement

     * Returns the Spring Bean which implements a particular service
     * @param service the service
     * @return the bean which implements the service, as a SpringBeanElement
     */
    public SpringBeanElement getBeanFromService(Service service) {
        SpringBeanElement theBean = serviceMap.get(service.getName());
        return theBean;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.