Package org.apache.tuscany.core.context

Examples of org.apache.tuscany.core.context.SystemCompositeContext.publish()


        comp.getImplementation().setComponentType(getIntrospector().introspect(JavaContextFactoryBuilder.class));
        ctx.registerModelObject(comp);
        comp = systemFactory.createSystemComponent(JAVA_WIRE_BUILDER, WireBuilder.class, JavaTargetWireBuilder.class, Scope.MODULE);
        comp.getImplementation().setComponentType(getIntrospector().introspect(JavaTargetWireBuilder.class));
        ctx.registerModelObject(comp);
        ctx.publish(new ModuleStart(new Object()));
        return runtime;
    }

    /**
     * Registers the {@link FooBinding} builders with a given runtime
View Full Code Here


    public void testModuleToModuleScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
View Full Code Here

        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Assert.assertSame(target, source.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testStatelessToModuleScope() throws Exception {
        SystemCompositeContext context = createContext();
View Full Code Here

    public void testStatelessToModuleScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.INSTANCE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
View Full Code Here

        Assert.assertNotNull(targetRef);
        source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertSame(target, targetRef);
        Assert.assertSame(target, source.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testModuleToStatelessScope() throws Exception {
        SystemCompositeContext context = createContext();
View Full Code Here

    public void testModuleToStatelessScope() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.INSTANCE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target targetRef = source.getTarget();
        Assert.assertNotNull(targetRef);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
View Full Code Here

        Assert.assertNotSame(target, targetRef);
        Source source2 = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        // should be the same since the module scope component was alreadyy created and the stateless
        // component will be "attached" to it
        Assert.assertSame(source.getTarget(), source2.getTarget());
        context.publish(new ModuleStop(this));
        context.stop();
    }

    public void testMultiplicity() throws Exception {
        SystemCompositeContext context = createContext();
View Full Code Here

    public void testMultiplicity() throws Exception {
        SystemCompositeContext context = createContext();
        context.start();
        context.registerModelObject(MockFactory.createSystemModuleWithWiredComponents("system.module",Scope.MODULE, Scope.MODULE));
        context.publish(new ModuleStart(this));
        Source source = (Source) ((AtomicContext) context.getContext("source")).getTargetInstance();
        Assert.assertNotNull(source);
        Target target = (Target) ((AtomicContext) context.getContext("target")).getTargetInstance();
        Assert.assertNotNull(target);
        // test setter injection
View Full Code Here

    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        moduleContext.publish(new ModuleStop(this));
        moduleContext.stop();
        SystemCompositeContext systemContext = runtime.getSystemContext();
        systemContext.publish(new ModuleStop(this));
        systemContext.stop();
        runtime.stop();
        servletContextEvent.getServletContext().removeAttribute(MODULE_COMPONENT_NAME);
        servletContextEvent.getServletContext().removeAttribute(TUSCANY_RUNTIME_NAME);
    }
View Full Code Here

        Component source = MockFactory.createSystemComponent("source", Source.class, AutowireSourceImpl.class, Scope.MODULE);
        app1aComponent.getImplementation().getComponents().add(source);
        app1Component.getImplementation().getComponents().add(app1aComponent);
        CompositeContext root = runtime.getRootContext();
        root.registerModelObject(app1Component);
        system.publish(new ModuleStart(this));
        return runtime;
    }

    private RuntimeContext createScenario2Runtime() throws Exception {
        RuntimeContext runtime = MockFactory.createCoreRuntime();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.