Package org.apache.tuscany.core.system.config

Examples of org.apache.tuscany.core.system.config.SystemContextFactory


        } else {
            return;
        }
        Set<Field> fields;
        Set<Method> methods;
        SystemContextFactory contextFactory;
        try {
            fields = JavaIntrospectionHelper.getAllFields(implClass);
            methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
            String name = component.getName();
            if (componentImplementation instanceof Module) {
                Module module = (Module) componentImplementation;
                contextFactory = new SystemContextFactory(name, module, JavaIntrospectionHelper.getDefaultConstructor(implClass), scope);

            } else {
                contextFactory = new SystemContextFactory(name, JavaIntrospectionHelper.getDefaultConstructor(implClass), scope);
            }

            //ContextObjectFactory contextObjectFactory = new ContextObjectFactory(contextFactory);

            List<Injector> injectors = new ArrayList<Injector>();

            // handle properties
            List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
            if (configuredProperties != null) {
                for (ConfiguredProperty property : configuredProperties) {
                    Injector injector = createPropertyInjector(property, fields, methods);
                    injectors.add(injector);
                }
            }

            // FIXME do not inject references on an application module yet
            if (implClass != CompositeContextImpl.class) {
                // handle references
                List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
                if (configuredReferences != null) {
                    for (ConfiguredReference reference : configuredReferences) {
                        Injector injector = createReferenceInjector(reference, fields, methods, contextFactory);
                        injectors.add(injector);
                    }
                }
            }
            List<Object> elements = componentImplementation.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));
                } else if (element instanceof SystemInjectorExtensibilityElement) {
                    SystemInjectorExtensibilityElement injectorElement = (SystemInjectorExtensibilityElement) element;
                    injectors.add(injectorElement.getInjector(contextFactory));
                } else if (element instanceof MonitorExtensibilityElement) {
                    MonitorExtensibilityElement monitorElement = (MonitorExtensibilityElement) element;
                    injectors.add(monitorElement.getInjector(monitorFactory));
                }
            }
            contextFactory.setSetters(injectors);
            // decorate the logical model
            component.setContextFactory(contextFactory);
        } catch (BuilderConfigException e) {
            e.addContextName(component.getName());
            throw e;
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.system.config.SystemContextFactory

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.