Package org.apache.tuscany.core.component.event

Examples of org.apache.tuscany.core.component.event.CompositeStart


        final ScopeContainer requestScope = new RequestScopeContainer(ctx);
        requestScope.start();

        Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
            moduleScope, members, "target", Target.class, TargetImpl.class, requestScope);
        moduleScope.onEvent(new CompositeStart(this, null));
        requestScope.onEvent(new RequestStart(this));

        AtomicComponent sourceComponent = contexts.get("source");
        final AtomicComponent targetComponent = contexts.get("target");
        final Source source = (Source) sourceComponent.getServiceInstance();
View Full Code Here


        ScopeContainer statelessScope = new StatelessScopeContainer(ctx);
        statelessScope.start();

        Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
            moduleScope, members, "target", Target.class, TargetImpl.class, statelessScope);
        moduleScope.onEvent(new CompositeStart(this, null));

        AtomicComponent sourceComponent = contexts.get("source");
        AtomicComponent targetComponent = contexts.get("target");
        Source source = (Source) sourceComponent.getServiceInstance();
        Target target = (Target) targetComponent.getServiceInstance();
View Full Code Here

        ScopeContainer sessionScope = new HttpSessionScopeContainer(ctx);
        sessionScope.start();

        Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
            sessionScope, members, "target", Target.class, TargetImpl.class, moduleScope);
        moduleScope.onEvent(new CompositeStart(this, null));
        Object session1 = new Object();
        ctx.setIdentifier(HttpSessionScopeContainer.HTTP_IDENTIFIER, session1);
        sessionScope.onEvent(new HttpSessionStart(this, session1));
        AtomicComponent sourceComponent = contexts.get("source");
        AtomicComponent targetComponent = contexts.get("target");
View Full Code Here

        WorkContext ctx = new WorkContextImpl();
        final ScopeContainer requestScope = new RequestScopeContainer(ctx);
        final ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
        requestScope.start();
        moduleScope.start();
        moduleScope.onEvent(new CompositeStart(this, null));

        Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
            requestScope, members, "target", Target.class, TargetImpl.class, moduleScope);
        requestScope.onEvent(new RequestStart(this));
View Full Code Here

        ScopeContainer moduleScope = new ModuleScopeContainer(ctx);
        moduleScope.start();

        Map<String, AtomicComponent> contexts = MockFactory.createWiredComponents("source", SourceImpl.class,
            statelessScope, members, "target", Target.class, TargetImpl.class, moduleScope);
        moduleScope.onEvent(new CompositeStart(this, null));
        AtomicComponent sourceComponent = contexts.get("source");
        AtomicComponent targetComponent = contexts.get("target");
        Source source = (Source) sourceComponent.getServiceInstance();
        Target target = (Target) targetComponent.getServiceInstance();
        assertNull(source.getTarget().getString());
View Full Code Here

        }
        AtomicComponent sourceComponent = contexts.get("source");
        AtomicComponent targetComponent = contexts.get("target");
        scopeCtx.register(sourceComponent);
        scopeCtx.register(targetComponent);
        scopeCtx.onEvent(new CompositeStart(this, null));
        OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
        OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent);
        assertNotNull(source.getPojo());
        assertNotNull(target);
        assertEquals(2, source.getNumberInstantiated());
View Full Code Here

            "target",
            OrderedInitPojoImpl.class,
            scopeCtx);
        AtomicComponent sourceComponent = contexts.get("source");
        AtomicComponent targetComponent = contexts.get("target");
        scopeCtx.onEvent(new CompositeStart(this, null));
        scopeCtx.register(sourceComponent);
        scopeCtx.register(targetComponent);
        OrderedDependentPojo source = (OrderedDependentPojo) scopeCtx.getInstance(sourceComponent);
        OrderedInitPojo target = (OrderedInitPojo) scopeCtx.getInstance(targetComponent);
        assertNotNull(source.getPojo());
View Full Code Here

        Constructor<InitDestroyOnce> ctr = InitDestroyOnce.class.getConstructor((Class<?>[]) null);
        configuration.setInstanceFactory(new PojoObjectFactory<InitDestroyOnce>(ctr));
        SystemAtomicComponent context = new SystemAtomicComponentImpl("InitDestroy", configuration);
        context.start();

        scope.onEvent(new CompositeStart(this, null));
        Object instance = context.getServiceInstance();
        assertSame(instance, context.getServiceInstance());

        scope.onEvent(new CompositeStop(this, null));
        scope.stop();
        context.stop();

        scope.start();
        scope.onEvent(new CompositeStart(this, null));
        context.start();
        assertNotSame(instance, context.getServiceInstance());
        scope.onEvent(new CompositeStop(this, null));
        scope.stop();
        context.stop();
View Full Code Here

    public void testToModuleScope() throws Exception {

        ModuleScopeContainer scope = new ModuleScopeContainer(workContext);
        scope.start();
        scope.onEvent(new CompositeStart(this, null));
        final OutboundWire wire = getWire(scope);
        Target service = (Target) wireService.createProxy(wire);
        Target target = (Target) wireService.createProxy(wire);
        assertNotNull(service);
        service.setString("foo");
View Full Code Here

        impl.setComponentType(type);
        impl.setImplementationClass(FooImpl.class);
        ComponentDefinition<SystemImplementation> definition = new ComponentDefinition<SystemImplementation>(impl);
        AtomicComponent component = builder.build(parent, definition, deploymentContext);
        component.start();
        container.onEvent(new CompositeStart(this, null));
        FooImpl foo = (FooImpl) component.getServiceInstance();
        assertTrue(foo.initialized);
        container.onEvent(new CompositeStop(this, null));
        assertTrue(foo.destroyed);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.component.event.CompositeStart

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.