Package org.apache.tuscany.sca.core.factory

Examples of org.apache.tuscany.sca.core.factory.ObjectFactory


        for (ComponentProperty prop : componentProperties) {
            JavaElementImpl element = propertyMembers.get(prop.getName());
           
            if (element != null && !(element.getAnchor() instanceof Constructor) && prop.getValue() != null) {
                Class propertyJavaType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
                ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue(), propertyJavaType);
                   
                factories.put(element, objFactory);
                injectionSites.add(element);
           
        }
View Full Code Here


        List<ComponentProperty> props = component.getProperties();
        for (ComponentProperty prop : props) {
            if (prop.getName().equals(name)) {
                // On finding the property, create a factory for it and create a Bean using
                // the factory
                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
                propertyObject = (B)factory.getInstance();
            } // end if
        } // end for

        return propertyObject;
    }
View Full Code Here

            Object propertyValue = null;
            if (clazz == null || java.lang.Object.class.equals(clazz)) {
                propertyValue = property.getValue();
            } else {
                ObjectFactory objfactory = javaFactory.createValueFactory(property, property.getValue(), clazz);
                propertyValue = objfactory.getInstance();
            }
            properties.put(propName, propertyValue);
        }
    }
View Full Code Here

                    String pid = null;
                   
                    if (serviceProps != null) {
                        for (ComponentProperty prop : serviceProps) {
                            if (prop.getName().equals("service.pid")) {
                                ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
                                pid = (String)objFactory.getInstance();
                            }
                        }
                    }
                    if (pid == null || pidsProcessed.contains(pid))
                        continue;
View Full Code Here

       
        for (ComponentProperty prop : compProps) {
           
            boolean hasSetProp = false;
            String propName = prop.getName();
            ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
           
            try {
                Field field = implClass.getDeclaredField(propName);
                org.osoa.sca.annotations.Property propAnn;
               
                if ((propAnn = field.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
                        || Modifier.isPublic(field.getModifiers())) {
                   
                    try {
                        if (!field.isAccessible())
                            field.setAccessible(true);
                           
                        field.set(instance, objFactory.getInstance());
                        hasSetProp = true;
                    } catch (IllegalAccessException e) {
                        if (propAnn.required())
                            throw new RuntimeException(e);
                    }
                   
                }
            } catch (NoSuchFieldException e) {
                // Ignore exception
            }

            if (!hasSetProp) {
                Method[] methods = implClass.getDeclaredMethods();
                org.osoa.sca.annotations.Property propAnn = null;

                for (Method method : methods) {

                    if (!method.getName().startsWith("set"))
                        continue;
                    if ((propAnn = method.getAnnotation(org.osoa.sca.annotations.Property.class)) != null
                            || Modifier.isPublic(method.getModifiers())) {
                       
                        String methodPropName = Introspector.decapitalize(method.getName().substring(3));
                        if (!propName.equals(methodPropName))
                            continue;
                    }
                    try {
                        if (!method.isAccessible())
                            method.setAccessible(true);

                        method.invoke(instance, objFactory.getInstance());
                        hasSetProp = true;
                    } catch (Exception e) {
                        if (propAnn != null && propAnn.required())
                            throw new RuntimeException(e);
                    }
View Full Code Here

       
        for (ComponentProperty prop : compProps) {
           
            boolean hasSetProp = false;
            String propName = prop.getName();
            ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop, prop.getValue());
           
            try {
                Field field = implClass.getDeclaredField(propName);
               
                if (Modifier.isPublic(field.getModifiers())) {
                  
                    try {
                        field.set(instance, objFactory.getInstance());
                        hasSetProp = true;
                   
                    } catch (Exception e) {
                        // Ignore
                    }
                }
            } catch (NoSuchFieldException e) {
                // Ignore exception
            }

            if (!hasSetProp) {
                Method[] methods = implClass.getDeclaredMethods();
                for (Method method : methods) {

                    if (!method.getName().startsWith("set"))
                        continue;
                    if (Modifier.isPublic(method.getModifiers())) {
                       
                        String methodPropName = Introspector.decapitalize(method.getName().substring(3));
                        if (!propName.equals(methodPropName))
                            continue;
                    }
                    try {
                        method.invoke(instance, objFactory.getInstance());
                    } catch (Exception e) {
                       // Ignore
                    }
                }
            }
View Full Code Here

     
      Object propertyValue = null;
      if(clazz == null || java.lang.Object.class.equals(clazz)) {
        propertyValue = property.getValue();
      } else {
        ObjectFactory objfactory = javaFactory.createValueFactory(property, property.getValue(), clazz);
        propertyValue = objfactory.getInstance();
      }
      properties.put(propName, propertyValue);
    }
  }
View Full Code Here

        List<ComponentProperty> props = component.getProperties();
        for (ComponentProperty prop : props) {
            if (prop.getName().equals(name)) {
                // On finding the property, create a factory for it and create a Bean using
                // the factory
                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
                propertyObject = (B)factory.getInstance();
            } // end if
        } // end for

        return propertyObject;
    }
View Full Code Here

        List<ComponentProperty> props = component.getProperties();
        for (ComponentProperty prop : props) {
            if (prop.getName().equals(name)) {
                // On finding the property, create a factory for it and create a Bean using
                // the factory
                ObjectFactory factory = propertyFactory.createValueFactory(prop, prop.getValue(), requiredType);
                propertyObj = factory.getInstance();
            } // end if
        } // end for       
       
        return propertyObj;
    }
View Full Code Here

                    String pid = null;
                   
                    if (serviceProps != null) {
                        for (ComponentProperty prop : serviceProps) {
                            if (prop.getName().equals("service.pid")) {
                                ObjectFactory objFactory = propertyValueFactory.createValueFactory(prop,
                                        prop.getValue(), String.class);
                                pid = (String)objFactory.getInstance();
                            }
                        }
                    }
                    if (pid == null || pidsProcessed.contains(pid))
                        continue;
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.core.factory.ObjectFactory

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.