Package org.apache.tuscany.core.context.scope

Examples of org.apache.tuscany.core.context.scope.DefaultScopeStrategy


    public AbstractCompositeContext() {
        scopeIndex = new ConcurrentHashMap<String, ScopeContext>();
        // FIXME the factory should be injected
        module = new AssemblyFactoryImpl().createModule();
        scopeStrategy = new DefaultScopeStrategy();
    }
View Full Code Here


    }

    public AbstractCompositeContext(String name, CompositeContext parent, ScopeStrategy strategy, EventContext ctx, ConfigurationContext configCtx) {
        super(name);
        if (strategy == null) {
            strategy = new DefaultScopeStrategy();
        }
        this.scopeStrategy = strategy;
        this.eventContext = ctx;
        this.configurationContext = configCtx;
        scopeIndex = new ConcurrentHashMap<String, ScopeContext>();
View Full Code Here

        policyRegistry.registerSourceBuilder(interceptorBuilder);
        WireFactoryService wireService = new DefaultWireFactoryService(new MessageFactoryImpl(), new JDKWireFactoryFactory(), policyRegistry);
        JavaContextFactoryBuilder builder = new JavaContextFactoryBuilder(wireService);

        JavaTargetWireBuilder javaWireBuilder = new JavaTargetWireBuilder();
        ScopeStrategy strategy = new DefaultScopeStrategy();
        DefaultWireBuilder wireBuilder = new DefaultWireBuilder();
        wireBuilder.addWireBuilder(javaWireBuilder);
        Module module = MockFactory.createModule();
        EventContext eCtx = new EventContextImpl();
        ScopeContext scopeContext = new ModuleScopeContext(eCtx);
        scopeContext.start();
        scopeContext.onEvent(new ModuleStart(this));
        List<Component> components = module.getComponents();
        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();
            }
View Full Code Here



    protected CompositeContext createContextHierachy() throws Exception {
        List<ContextFactoryBuilder> mockBuilders = MockFactory.createSystemBuilders();
        CompositeContext parent = new SystemCompositeContextImpl("test.parent", null, null, new DefaultScopeStrategy(), new EventContextImpl(), new MockConfigContext(mockBuilders));
        parent.registerModelObject(MockFactory.createCompositeComponent("test.child"));
        parent.start();
        CompositeContext child = (CompositeContext) parent.getContext("test.child");
        Assert.assertNotNull(child);
        return parent;
View Full Code Here

*/
public class SystemCompositeContextRegisterTestCase extends CompositeContextRegisterTestCase {

    protected CompositeContext createContext() {
        List<ContextFactoryBuilder> builders = MockFactory.createSystemBuilders();
        return new SystemCompositeContextImpl("test.context", null, null, new DefaultScopeStrategy(), new EventContextImpl(), new MockConfigContext(builders));
    }
View Full Code Here

            }
        }
    }

    private static CompositeContext createContext() {
        return new CompositeContextImpl("test.parent", null, new DefaultScopeStrategy(), new EventContextImpl(), new MockConfigContext(null));
    }
View Full Code Here




    private static CompositeContext createContext() {
        return new CompositeContextImpl("test.parent", null, new DefaultScopeStrategy(), new EventContextImpl(),
                new MockConfigContext(null));
    }
View Full Code Here

    /**
     * Checks that registration of duplicate named model objects before context start throws an exception
     */
    public void testRegisterSameName() throws Exception {
        CompositeContext parent = new CompositeContextImpl("test.parent", null, new DefaultScopeStrategy(),
                new EventContextImpl(), new MockConfigContext(builders));
        parent.registerModelObject(MockFactory.createSystemCompositeComponent("test.child"));
        try {
            parent.registerModelObject(MockFactory.createSystemCompositeComponent("test.child"));
            parent.start();
View Full Code Here

    /**
     * Checks that registration of duplicate named model objects after context start throws an exception
     */
    public void testRegisterSameNameAfterStart() throws Exception {
        CompositeContext parent = new CompositeContextImpl("test.parent", null, new DefaultScopeStrategy(),
                new EventContextImpl(), new MockConfigContext(builders));
        parent.registerModelObject(MockFactory.createSystemCompositeComponent("test.child"));
        parent.start();
        CompositeContext child = (CompositeContext) parent.getContext("test.child");
        Assert.assertNotNull(child);
View Full Code Here

        parent.stop();
    }

    protected CompositeContext createContextHierachy() throws Exception {
        List<ContextFactoryBuilder> systemBuilders = MockFactory.createSystemBuilders();
        CompositeContext parent = new CompositeContextImpl("test.parent", null, new DefaultScopeStrategy(),
                new EventContextImpl(), new MockConfigContext(systemBuilders));
        Component component = MockFactory.createCompositeComponent("test.child");
        parent.registerModelObject(component);
        parent.start();
        CompositeContext child = (CompositeContext) parent.getContext("test.child");
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.scope.DefaultScopeStrategy

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.