Package org.apache.tuscany.core.builder

Examples of org.apache.tuscany.core.builder.ContextFactory


        Map<String, Component> compMap = new HashMap<String, Component>(components.size());

        for (Component component : components) {
            compMap.put(component.getName(), component);
            builder.build(component);
            ContextFactory contextFactory = (ContextFactory) component.getContextFactory();
            Assert.assertNotNull(contextFactory);
        }
        for (Component component : components) {
            ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
            Assert.assertNotNull(source);
            for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
                WireConfiguration pConfig = pFactory.getConfiguration();
                Component target = compMap.get(pConfig.getTargetName().getPartName());

                if (target != null) {
                    ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
                    boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
                    wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
                            .getPortName()), targetConfig.getClass(), downScope, scopeContext);
                }
                pFactory.initialize();
            }
            scopeContext.registerFactory(source);
        }
        for (Component component : components) {
            ContextFactory config = (ContextFactory) component.getContextFactory();
            Context context = config.createContext();
            if ("source".equals(component.getName())) {
                ModuleScopeComponent source = (ModuleScopeComponent) context.getInstance(null);
                Assert.assertNotNull(source);
                GenericComponent gComp = source.getGenericComponent();
                gComp.getString();
View Full Code Here


            }
            if (scope != null && current != Scope.INSTANCE) {
                scope = current;
            }
        }
        ContextFactory contextFactory;
        try {
            contextFactory = createContextFactory(component.getName(), component.getImplementation(), scope);
            // create target-side wire invocation chains for each service offered by the implementation
            for (ConfiguredService configuredService : component.getConfiguredServices()) {
                Service service = configuredService.getPort();
                TargetWireFactory wireFactory = wireFactoryService.createTargetFactory(configuredService);
                contextFactory.addTargetWireFactory(service.getName(), wireFactory);
            }
            // handle properties
            List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
            if (configuredProperties != null) {
                for (ConfiguredProperty property : configuredProperties) {
                    contextFactory.addProperty(property.getName(), property.getValue());
                }
            }
            // handle references and source side reference chains
            List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
            if (configuredReferences != null) {
                for (ConfiguredReference reference : configuredReferences) {
                    if (reference.getPort().getMultiplicity() == Multiplicity.ZERO_N || reference.getPort().getMultiplicity() == Multiplicity.ZERO_ONE){
                        if (reference.getTargetConfiguredServices().size() < 1 && reference.getTargets().size() <1 ){
                            continue; // not required, not configured fix TUSCANY-299
                        }
                    }
                    List<SourceWireFactory> wireFactories = wireFactoryService.createSourceFactory(reference);
                    String refName = reference.getPort().getName();
                    Class refClass = reference.getPort().getServiceContract().getInterface();
                    boolean multiplicity = reference.getPort().getMultiplicity() == Multiplicity.ONE_N
                            || reference.getPort().getMultiplicity() == Multiplicity.ZERO_N;
                    contextFactory.addSourceWireFactories(refName, refClass, wireFactories, multiplicity);
                }
            }
            component.setContextFactory(contextFactory);
        } catch (BuilderException e) {
            e.addContextName(component.getName());
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.builder.ContextFactory

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.