Package org.apache.tuscany.sca.implementation.java

Examples of org.apache.tuscany.sca.implementation.java.JavaConstructorImpl


        if (annotation == null) {
            return;
        }
        JavaConstructorImpl<?> definition = type.getConstructor();
        if (definition == null) {
            definition = new JavaConstructorImpl(constructor);
            type.setConstructor(definition);
        }
        JavaParameterImpl[] parameters = definition.getParameters();
        String[] value = annotation.value();
        boolean isDefault = value.length == 0 || (value.length == 1 && "".equals(value[0]));
View Full Code Here


    @Override
    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
        Constructor[] ctors = clazz.getConstructors();
        boolean found = false;
        for (Constructor constructor : ctors) {
            JavaConstructorImpl<?> definition = new JavaConstructorImpl(constructor);
            type.getConstructors().put(constructor, definition);
            if (constructor.getAnnotation(org.oasisopen.sca.annotation.Constructor.class) != null) {
                if (found) {
                    throw new DuplicateConstructorException("Multiple constructors marked with @Constructor", constructor);
                }
View Full Code Here

        if (annotation == null) {
            return;
        }
        JavaConstructorImpl<?> definition = type.getConstructor();
        if (definition == null) {
            definition = new JavaConstructorImpl(constructor);
            type.setConstructor(definition);
        }
        JavaParameterImpl[] parameters = definition.getParameters();
        String[] value = annotation.value();
        boolean isDefault = value.length == 0 || (value.length == 1 && "".equals(value[0]));
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor ctor = Foo.class.getConstructor(String.class);
        type.setConstructor(new JavaConstructorImpl(ctor));
        propertyProcessor.visitConstructorParameter(type.getConstructor().getParameters()[0], type);
        heuristicProcessor.visitEnd(Foo.class, type);
        assertEquals(1, type.getProperties().size());
        assertEquals("foo", type.getProperties().get(0).getName());
    }
View Full Code Here

                beanIntrospector =
                    new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, 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();
                    if (propertyRefUnresolved(propertyElement.getRef(), 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(propertyElement.getRef());
                                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());
                                Reference theReference = createReference(interfaze, propertyElement.getRef());
                                implementation.setUnresolvedBeanRef(propertyElement.getRef(), theReference);
                            } // end if
                      } // end for
                    } // end if
                } // end while

                Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
                while (itcr.hasNext()) {
                  SpringConstructorArgElement conArgElement = itcr.next();
                    if (propertyRefUnresolved(conArgElement.getRef(), beans, references, scaproperties)) {
                      for (JavaParameterImpl parameter : constructor.getParameters()) {
                        String paramType = parameter.getType().getName();
                        Class<?> interfaze = resolveClass(resolver, paramType);
                        // Create a component type reference/property if the constructor-arg element has a
                            // type attribute OR index attribute declared...
                        if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) ||
View Full Code Here

    @Override
    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
        Constructor[] ctors = clazz.getConstructors();
        boolean found = false;
        for (Constructor constructor : ctors) {
            JavaConstructorImpl<?> definition = new JavaConstructorImpl(constructor);
            type.getConstructors().put(constructor, definition);
            if (constructor.getAnnotation(org.oasisopen.sca.annotation.Constructor.class) != null) {
                if (found) {
                    throw new DuplicateConstructorException("[JCI50002] Multiple constructors marked with @Constructor", constructor);
                }
View Full Code Here

        if (annotation == null) {
            return;
        }
        JavaConstructorImpl<?> definition = type.getConstructor();
        if (definition == null) {
            definition = new JavaConstructorImpl(constructor);
            type.setConstructor(definition);
        }
        JavaParameterImpl[] parameters = definition.getParameters();
        String[] value = annotation.value();
        boolean isDefault = value.length == 0 || (value.length == 1 && "".equals(value[0]));
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
        JavaImplementation type = javaImplementationFactory.createJavaImplementation();
        Constructor ctor = Foo.class.getConstructor(String.class);
        type.setConstructor(new JavaConstructorImpl(ctor));
        propertyProcessor.visitConstructorParameter(type.getConstructor().getParameters()[0], type);
        heuristicProcessor.visitEnd(Foo.class, type);
        assertEquals(1, type.getProperties().size());
        assertEquals("foo", type.getProperties().get(0).getName());
    }
View Full Code Here

                    // 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);
                                    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()) {
                                String paramType = parameter.getType().getName();
                                Class<?> interfaze = resolveClass(resolver, paramType, context);
                                // Create a component type reference/property if the constructor-arg element has a
                                // type attribute OR index attribute declared...
                                if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) || (conArgElement
View Full Code Here

    @Override
    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
        Constructor[] ctors = clazz.getConstructors();
        boolean found = false;
        for (Constructor constructor : ctors) {
            JavaConstructorImpl<?> definition = new JavaConstructorImpl(constructor);
            type.getConstructors().put(constructor, definition);
            if (constructor.getAnnotation(org.oasisopen.sca.annotation.Constructor.class) != null) {
                if (found) {
                    throw new DuplicateConstructorException("[JCI50002] Multiple constructors marked with @Constructor", constructor);
                }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.java.JavaConstructorImpl

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.