Package org.apache.tuscany.core.injection

Examples of org.apache.tuscany.core.injection.MethodInjector


    }

    @SuppressWarnings("unchecked")
    public Injector<?> getInjector(ContextResolver resolver) {
        if (method != null) {
            return new MethodInjector(method, new AutowireObjectFactory(method.getParameterTypes()[0], resolver));
        } else {
            return new FieldInjector(field, new AutowireObjectFactory(field.getType(), resolver));
        }
    }
View Full Code Here


    }

    public Injector<?> getInjector(MonitorFactory factory) {
        if (method != null) {
            Object monitor = factory.getMonitor(method.getParameterTypes()[0]);
            return new MethodInjector(method, new SingletonObjectFactory<Object>(monitor));
        } else {
            Object monitor = factory.getMonitor(field.getType());
            return new FieldInjector(field, new SingletonObjectFactory<Object>(monitor));
        }
    }
View Full Code Here

        field = f;
    }

    public Injector<?> getInjector(ContextResolver resolver) {
        if (method != null) {
            return new MethodInjector(method, new ContextObjectFactory(resolver));
        } else {
            return new FieldInjector(field, new ContextObjectFactory(resolver));
        }
    }
View Full Code Here

            ObjectCreationException e = new ObjectCreationException("Unknown type");
            e.setIdentifier(type.getName());
            throw e;
        }
        if (method != null) {
            return new MethodInjector(method, factory);
        }
        return new FieldInjector(field, factory);
    }
View Full Code Here

        field = f;
    }

    public Injector<?> getInjector(ContextResolver resolver) {
        if (method != null) {
            return new MethodInjector(method, new ContextObjectFactory(resolver));
        } else {
            return new FieldInjector(field, new ContextObjectFactory(resolver));
        }
    }
View Full Code Here

        field = f;
    }

    public Injector<?> getEventInvoker(String name) {
        if (method != null) {
            return new MethodInjector(method, new SingletonObjectFactory<Object>(name));
        }else{
            return new FieldInjector(field, new SingletonObjectFactory<Object>(name));
        }
    }
View Full Code Here

                destroyInvoker = new MethodEventInvoker(method);
                continue;
            }
            ComponentName compName = method.getAnnotation(ComponentName.class);
            if (compName != null) {
                Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
                injectors.add(injector);
            }
            org.osoa.sca.annotations.Context context = method.getAnnotation(org.osoa.sca.annotations.Context.class);
            if (context != null) {
                Injector injector = new MethodInjector(method, new SingletonObjectFactory(moduleComponentContext));
                injectors.add(injector);
            }
        }
        boolean stateless = (scope == Scope.INSTANCE);
        return new JavaAtomicContext("foo", new PojoObjectFactory(JavaIntrospectionHelper
View Full Code Here

        source.setDestroyInvoker(destroyInvoker);
        JavaContextFactory target = new JavaContextFactory("target",constructor,scope);
        target.setInitInvoker(initInvoker);
        target.setDestroyInvoker(destroyInvoker);
        List<Injector> injectors = new ArrayList<Injector>();
        injectors.add(new MethodInjector(getPojo, new MockTargetFactory("target",context)));
        source.setSetters(injectors);
        List<ContextFactory<Context>> list = new ArrayList<ContextFactory<Context>>();
        list.add((ContextFactory)source);
        list.add((ContextFactory)target);
        return list;
View Full Code Here

        Injector injector = null;
        if (value instanceof DataObject) {
            if (field != null) {
                injector = new FieldInjector(field, new SDOObjectFactory((DataObject) value));
            } else {
                injector = new MethodInjector(method, new SDOObjectFactory((DataObject) value));
            }
        } else if (JavaIntrospectionHelper.isImmutable(type)) {
            if (field != null) {
                injector = new FieldInjector(field, new SingletonObjectFactory<Object>(value));
            } else {
                injector = new MethodInjector(method, new SingletonObjectFactory<Object>(value));
            }
        }
        return injector;

    }
View Full Code Here

                } else {
                    injector = new FieldInjector(field, new ListMultiplicityObjectFactory(objectFactories));
                }
            } else {
                if (method.getParameterTypes()[0].isArray()) {
                    injector = new MethodInjector(method, new ArrayMultiplicityObjectFactory(refClass, objectFactories));
                } else {
                    injector = new MethodInjector(method, new ListMultiplicityObjectFactory(objectFactories));
                }
            }
            return injector;
        } else {
            field = JavaIntrospectionHelper.findClosestMatchingField(refName, refClass, fields);
            if (field == null) {
                // hack for TUSCANY-300
                for (Field current : fields) {
                    Reference annot = current.getAnnotation(Reference.class);
                    if (annot != null) {
                        if (refName.equals(annot.name())) {
                            field = current;
                            break;
                        }
                    }
                }
                if (field == null) {
                    method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[]{refClass}, methods);
                    if(method == null){
                        // Fix for Tuscany-325
                        method = JavaIntrospectionHelper.findClosestMatchingMethod("set"+refName.substring(0,1).toUpperCase()+ refName.substring(1), new Class[]{refClass}, methods);
                    }
                    if (method == null) {
                        // hack for TUSCANY-300
                        for (Method current : methods) {
                            Reference annot = current.getAnnotation(Reference.class);
                            if (annot != null) {
                                if (refName.equals(annot.name())) {
                                    method = current;
                                    break;
                                }
                            }
                        }
                        if (method == null) {
                            throw new NoAccessorException(refName);
                        }
                    }
                }
            }
            Injector injector;
            if (field != null) {
                injector = new FieldInjector(field, objectFactories.get(0));
            } else {
                injector = new MethodInjector(method, objectFactories.get(0));
            }
            return injector;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.injection.MethodInjector

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.