Examples of ModuleStart


Examples of org.apache.tuscany.core.context.event.ModuleStart

        MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
        registry.registerTargetBuilder(interceptorBuilder);
        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithEntryPointToExternalService());
        child.publish(new ModuleStart(this));
        Object id = new Object();
        child.publish(new RequestStart(this, id));
        HelloWorldService service1 = (HelloWorldService) child.getContext("target").getInstance(null);
        Assert.assertEquals("foo", service1.hello("foo"));
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

        MockInterceptorBuilder interceptorBuilder = new MockInterceptorBuilder(mockInterceptor, false);
        registry.registerTargetBuilder(interceptorBuilder);
        runtime.getRootContext().registerModelObject(MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModuleWithExternalService());
        child.publish(new ModuleStart(this));
        HelloWorldService source = (HelloWorldService) child.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        Assert.assertEquals(0, mockInterceptor.getCount());
        Assert.assertEquals("foo", source.hello("foo"));
        Assert.assertEquals(1, mockInterceptor.getCount());
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

    public void testInitDestroy() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        ModuleScopeInitDestroyComponent initDestroy = (ModuleScopeInitDestroyComponent) scope.getContext(
                "TestServiceInitDestroy").getInstance(null);
        Assert.assertNotNull(initDestroy);
        ModuleScopeInitOnlyComponent initOnly = (ModuleScopeInitOnlyComponent) scope.getContext("TestServiceInitOnly")
                .getInstance(null);
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

    public void testEagerInit() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createEagerInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        ModuleScopeEagerInitDestroyComponent initDestroy = (ModuleScopeEagerInitDestroyComponent) scope.getContext(
                "TestServiceEagerInitDestroy").getInstance(null);
        Assert.assertNotNull(initDestroy);
        ModuleScopeEagerInitComponent initOnly = (ModuleScopeEagerInitComponent) scope
                .getContext("TestServiceEagerInit").getInstance(null);
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

    public void testDestroyOrder() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createOrderedInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        OrderedInitPojo one = (OrderedInitPojo) scope.getContext("one").getInstance(null);
        Assert.assertNotNull(one);
        Assert.assertEquals(1, one.getNumberInstantiated());
        Assert.assertEquals(1, one.getInitOrder());
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

    public void testEagerInitDestroyOrder() throws Exception {
        EventContext ctx = new EventContextImpl();
        ModuleScopeContext scope = new ModuleScopeContext(ctx);
        scope.registerFactories(createOrderedEagerInitComponents());
        scope.start();
        scope.onEvent(new ModuleStart(this));
        OrderedEagerInitPojo one = (OrderedEagerInitPojo) scope.getContext("one").getInstance(null);
        Assert.assertNotNull(one);

        OrderedEagerInitPojo two = (OrderedEagerInitPojo) scope.getContext("two").getInstance(null);
        Assert.assertNotNull(two);
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

        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);
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

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

Examples of org.apache.tuscany.core.context.event.ModuleStart

        runtime.start();
        runtime.getRootContext().registerModelObject(
                MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModule());
        child.publish(new ModuleStart(this));
        GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        source.getGenericComponent().getString();
        Assert.assertEquals(1, mockInterceptor.getCount());
        source.getGenericComponent().getString();
View Full Code Here

Examples of org.apache.tuscany.core.context.event.ModuleStart

        runtime.start();
        runtime.getRootContext().registerModelObject(
                MockFactory.createCompositeComponent("test.module"));
        CompositeContext child = (CompositeContext) runtime.getRootContext().getContext("test.module");
        child.registerModelObject(MockFactory.createModule());
        child.publish(new ModuleStart(this));
        GenericComponent source = (GenericComponent) child.getContext("source").getInstance(null);
        Assert.assertNotNull(source);
        source.getGenericComponent().getString();
        Assert.assertEquals(1, mockInterceptor.getCount());
        Assert.assertEquals(1, mockHandler.getCount());
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.