Package org.apache.tuscany.container.java.config

Examples of org.apache.tuscany.container.java.config.JavaContextFactory


        Method init = OrderedDependentPojo.class.getMethod("init",(Class[])null);
        EventInvoker<Object> initInvoker = new MethodEventInvoker<Object>(init);
        Method destroy = OrderedDependentPojo.class.getMethod("destroy",(Class[])null);
        EventInvoker<Object> destroyInvoker = new MethodEventInvoker<Object>(destroy);

        JavaContextFactory source = new JavaContextFactory("source",constructor,scope);
        source.setInitInvoker(initInvoker);
        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);
View Full Code Here


    }

    @SuppressWarnings("unchecked")
    protected ContextFactory createContextFactory(String name, JavaImplementation javaImpl, Scope scope) {
        Class implClass = null;
        JavaContextFactory contextFactory;
        try {
            implClass = javaImpl.getImplementationClass();

            contextFactory = new JavaContextFactory(name, JavaIntrospectionHelper
                    .getDefaultConstructor(implClass), scope);

            List<Injector> injectors = new ArrayList<Injector>();
            List<Object> elements = javaImpl.getComponentType().getExtensibilityElements();
            for (Object element : elements) {
                if (element instanceof InitInvokerExtensibilityElement) {
                    InitInvokerExtensibilityElement invokerElement = (InitInvokerExtensibilityElement) element;
                    EventInvoker<Object> initInvoker = invokerElement.getEventInvoker();
                    boolean eagerInit = invokerElement.isEager();
                    contextFactory.setEagerInit(eagerInit);
                    contextFactory.setInitInvoker(initInvoker);
                } else if (element instanceof DestroyInvokerExtensibilityElement) {
                    DestroyInvokerExtensibilityElement invokerElement = (DestroyInvokerExtensibilityElement) element;
                    EventInvoker<Object> destroyInvoker = invokerElement.getEventInvoker();
                    contextFactory.setDestroyInvoker(destroyInvoker);
                } else if (element instanceof ComponentNameExtensibilityElement) {
                    ComponentNameExtensibilityElement nameElement = (ComponentNameExtensibilityElement) element;
                    injectors.add(nameElement.getEventInvoker(name));
                } else if (element instanceof ContextExtensibilityElement) {
                    ContextExtensibilityElement contextElement = (ContextExtensibilityElement) element;
                    injectors.add(contextElement.getInjector(contextFactory));
                }else if (element instanceof InjectorExtensibilityElement){
                    InjectorExtensibilityElement injectorElement = (InjectorExtensibilityElement)element;
                    injectors.add(injectorElement.getInjector(contextFactory));
                }
            }
            contextFactory.setSetters(injectors);
            return contextFactory;
        } catch (BuilderException e) {
            e.addContextName(name);
            throw e;
        } catch (NoSuchMethodException e) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.container.java.config.JavaContextFactory

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.