Package org.apache.tuscany.core.context.event

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


        ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
        JavaServiceContract inter = systemFactory.createJavaServiceContract();
        inter.setInterface(ModuleScopeSystemComponentImpl.class);
        service.setServiceContract(inter);
        system.registerModelObject(ep);
        system.publish(new ModuleStart(this));
        Assert.assertNotNull(system.getContext("TestService1").getInstance(null));
        Assert.assertNotNull(system.getContext("TestService2EP").getInstance(null));

        // create a test module and wire an external service to the system entry point
        Component moduleComponent = MockFactory.createCompositeComponent("test.module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
        moduleContext.registerModelObject(es);
        moduleContext.publish(new ModuleStart(this));
        Assert.assertNotNull(moduleContext.getContext("TestService2ES").getInstance(null));

        moduleContext.publish(new ModuleStop(this));
        system.publish(new ModuleStop(this));
    }
View Full Code Here


        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createAutowirableExternalService("TestService2ES", ModuleScopeSystemComponent.class);
        moduleContext.registerModelObject(es);

        system.publish(new ModuleStart(this));
        moduleContext.publish(new ModuleStart(this));
        // test that the autowire was resolved
        Assert.assertNotNull(moduleContext.getContext("TestService2ES").getInstance(null));

        moduleContext.publish(new ModuleStop(this));
        system.publish(new ModuleStop(this));
View Full Code Here

    public void testServiceNotFound() throws Exception {
        // create a test module
        Component moduleComponent = MockFactory.createCompositeComponent("module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("module");
        moduleContext.publish(new ModuleStart(this));
        try {
            moduleContext.locateService("TestService");
            fail("Expected " + ServiceNotFoundException.class.getName());
        } catch (ServiceNotFoundException e) {
            // expected
View Full Code Here

        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("module");
        ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1xEP");
        moduleContext.registerModelObject(es);

        // start the modules and test inter-module system wires
        system.publish(new ModuleStart(this));
        moduleContext.publish(new ModuleStart(this));
        try {
            moduleContext.locateService("TestServiceES");
            fail("Expected " + ServiceNotFoundException.class.getName());
        } catch (ServiceNotFoundException e) {
            // expected
View Full Code Here

        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("module");
        EntryPoint epSystemBinding = MockFactory.createEPSystemBinding("TestServiceEP", ModuleScopeSystemComponent.class, "NoReference", component);
        moduleContext.registerModelObject(epSystemBinding);

        moduleContext.publish(new ModuleStart(this));
        try {
            moduleContext.locateService("TestServiceEP");
            fail("Expected " + ServiceNotFoundException.class.getName());
        } catch (ServiceNotFoundException e) {
            // expected
View Full Code Here

        ExternalService externalService2 = MockFactory.createESSystemBinding("ExternalService2", "module1/EntryPoint1");
        moduleContext2.registerModelObject(component2);
        moduleContext2.registerModelObject(entryPoint2);
        moduleContext2.registerModelObject(externalService2);

        moduleContext1.publish(new ModuleStart(this));
        moduleContext2.publish(new ModuleStart(this));
        Assert.assertNotNull(moduleContext2.getContext("ExternalService2").getInstance(null));
        Assert.assertNotNull(moduleContext1.getContext("ExternalService1").getInstance(null));
    }
View Full Code Here

        CompositeContext system = runtime.getSystemContext();
        Component builder = factory.createSystemComponent("TestBuilder", ContextFactoryBuilder.class, TestBuilder.class, Scope.MODULE);
        builder.getImplementation().setComponentType(MockFactory.getIntrospector().introspect(TestBuilder.class));
        system.registerModelObject(builder);
        system.publish(new ModuleStart(this));
        Component module1 = MockFactory.createCompositeComponent("module1");
        runtime.registerModelObject(module1);
        runtime.getContext("module1");
        Assert.assertTrue(((TestBuilder) system.getContext("TestBuilder").getInstance(null)).invoked());
        system.publish(new ModuleStop(this));
View Full Code Here

        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createESSystemBinding("TestServiceES", "tuscany.system/TestService1EP");
        moduleContext.registerModelObject(es);

        // start the modules and test inter-module system wires
        systemContext.publish(new ModuleStart(this));
        moduleContext.publish(new ModuleStart(this));

        Assert.assertNotNull(systemContext.getContext("TestService1EP").getInstance(null));
        GenericSystemComponent testService = (GenericSystemComponent) systemContext.getContext("TestService1").getInstance(null);
        Assert.assertNotNull(testService);
        GenericSystemComponent testES = (GenericSystemComponent) moduleContext.getContext("TestServiceES").getInstance(null);
View Full Code Here

        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(ModuleScopeSystemComponentImpl.class);
        service.setServiceContract(inter);
        ep.getConfiguredReference().getTargetConfiguredServices().get(0).setPort(service);
        system.registerModelObject(ep);
        system.publish(new ModuleStart(this));
        Assert.assertNotNull(system.getContext("TestService1").getInstance(null));
        Assert.assertNotNull(system.getContext("TestService2EP").getInstance(null));

        Assert.assertNotNull(((AutowireContext) system).resolveInstance(ModuleScopeSystemComponent.class));
        // create a test module
        Component moduleComponent = MockFactory.createCompositeComponent("test.module");
        runtime.registerModelObject(moduleComponent);
        CompositeContextImpl moduleContext = (CompositeContextImpl) runtime.getContext("test.module");
        Assert.assertNotNull(moduleContext);
        ExternalService es = MockFactory.createESSystemBinding("TestService2ES", "tuscany.system/TestService2EP");
        moduleContext.registerModelObject(es);
        moduleContext.publish(new ModuleStart(this));
        Assert.assertNotNull(moduleContext.getContext("TestService2ES").getInstance(null));

        moduleContext.publish(new ModuleStop(this));
        system.publish(new ModuleStop(this));
        runtime.stop();
View Full Code Here

        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));
        EntryPointContext ctx = (EntryPointContext) child.getContext("source");
        Assert.assertNotNull(ctx);
        InvocationHandler handler = (InvocationHandler) ctx.getHandler();
View Full Code Here

TOP

Related Classes of org.apache.tuscany.core.context.event.ModuleStart

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.