Package org.jboss.gravia.runtime

Examples of org.jboss.gravia.runtime.ModuleContext


        Assert.assertEquals(Module.State.ACTIVE, modA.getState());

        String symbolicName = modA.getHeaders().get("Bundle-SymbolicName");
        Assert.assertEquals("simple-bundle", symbolicName);

        ModuleContext context = modA.getModuleContext();
        Module sysmodule = runtime.getModule(0);
        symbolicName = sysmodule.getHeaders().get("Bundle-SymbolicName");
        Assert.assertNotNull("System bundle symbolic name not null", symbolicName);

        ServiceReference<String> sref = context.getServiceReference(String.class);
        String service = context.getService(sref);
        Assert.assertEquals("Hello", service);

        modA.stop();
        Assert.assertEquals(Module.State.INSTALLED, modA.getState());
View Full Code Here


    public void testServletThroughModuleContext() throws Exception {

        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(getClass().getClassLoader());

        ModuleContext context = module.getModuleContext();
        ServiceReference<HttpService> sref = context.getServiceReference(HttpService.class);
        HttpService httpService = context.getService(sref);

        String reqspec = "/gravia/servlet?test=module";
        try {
            // Verify that the alias is not yet available
            assertNotAvailable(reqspec);

            // Register the test servlet and make a call
            String servletAlias = getRuntimeAwareAlias("/servlet");
            httpService.registerServlet(servletAlias, new HttpServiceServlet(module), null, null);
            Assert.assertEquals("http-service:1.0.0", performCall(reqspec));

            // Unregister the servlet alias
            httpService.unregister(servletAlias);
            assertNotAvailable(reqspec);

            // Verify that the alias is not available any more
            assertNotAvailable(reqspec);
        } finally {
            context.ungetService(sref);
        }
    }
View Full Code Here

    }

    @Before
    public void setUp() throws Exception {
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        ModuleContext syscontext = runtime.getModuleContext();
        ServiceReference<Resolver> sref = syscontext.getServiceReference(Resolver.class);
        Assert.assertNotNull("Resolver reference not null", sref);
        resolver = syscontext.getService(sref);
    }
View Full Code Here

    @Override
    public void init() {
        assertNoShutdown();

        // Register the Runtime
        ModuleContext syscontext = adapt(ModuleContext.class);
        systemServices.add(registerRuntimeService(syscontext));

        // Register the LogService
        systemServices.add(registerLogService(syscontext));
View Full Code Here

    @Override
    public void init() {
        assertNoShutdown();

        // Register the LogService
        ModuleContext syscontext = adapt(ModuleContext.class);
        systemServices.add(syscontext.registerService(LogService.class.getName(), new EmbeddedLogServiceFactory(), null));

        // Register the MBeanServer service
        MBeanServer mbeanServer = findOrCreateMBeanServer();
        systemServices.add(syscontext.registerService(MBeanServer.class, mbeanServer, null));

        // Install the plugin modules
        List<Module> pluginModules = new ArrayList<Module>();
        ClassLoader classLoader = getClass().getClassLoader();
        ServiceLoader<RuntimePlugin> services = ServiceLoader.load(RuntimePlugin.class, EmbeddedRuntime.class.getClassLoader());
View Full Code Here

        Assert.assertEquals(Module.State.ACTIVE, modA.getState());

        String symbolicName = modA.getHeaders().get("Bundle-SymbolicName");
        Assert.assertEquals("simple-module", symbolicName);

        ModuleContext context = modA.getModuleContext();
        Module sysmodule = runtime.getModule(0);
        symbolicName = sysmodule.getHeaders().get("Bundle-SymbolicName");
        Assert.assertNotNull("System bundle symbolic name not null", symbolicName);

        ServiceReference<String> sref = context.getServiceReference(String.class);
        String service = context.getService(sref);
        Assert.assertEquals("Hello", service);

        modA.stop();
        Assert.assertEquals(Module.State.INSTALLED, modA.getState());
View Full Code Here

    public void testBasicModule() throws Exception {

        Runtime runtime = RuntimeLocator.getRuntime();
        Module modA = runtime.getModule(getClass().getClassLoader());

        ModuleContext ctxA = modA.getModuleContext();
        ServiceReference<ServiceA> srefA = ctxA.getServiceReference(ServiceA.class);
        Assert.assertNotNull("ServiceReference not null", srefA);

        ServiceA srvA = ctxA.getService(srefA);
        Assert.assertEquals("ServiceA#1:ServiceA1#1:Hello", srvA.doStuff("Hello"));
    }
View Full Code Here

    public void testBasicModule() throws Exception {

        Runtime runtime = RuntimeLocator.getRuntime();
        Module module = runtime.getModule(getClass().getClassLoader());

        ModuleContext ctxA = module.getModuleContext();
        ServiceReference<ServiceD> srefD = ctxA.getServiceReference(ServiceD.class);
        Assert.assertNotNull("ServiceReference not null", srefD);

        ServiceD srvD = ctxA.getService(srefD);
        Assert.assertEquals("ServiceD#1:ServiceD1#1:null:Hello", srvD.doStuff("Hello"));

        ConfigurationAdmin configAdmin = getConfigurationAdmin(module);
        Configuration config = configAdmin.getConfiguration(ServiceD1.class.getName());
        Assert.assertNotNull("Config not null", config);
View Full Code Here

        Assert.assertEquals("ServiceD#1:ServiceD1#1:bar:Hello", srvD.doStuff("Hello"));
    }

    protected ConfigurationAdmin getConfigurationAdmin(Module module) {
        ModuleContext context = module.getModuleContext();
        return context.getService(context.getServiceReference(ConfigurationAdmin.class));
    }
View Full Code Here

        PropertiesProvider propsProvider = new TomcatPropertiesProvider(servletContext);
        Runtime runtime = RuntimeLocator.createRuntime(new TomcatRuntimeFactory(servletContext), propsProvider);
        runtime.init();

        // HttpService integration
        ModuleContext moduleContext = runtime.getModuleContext();
        BundleContext bundleContext = new BundleContextAdaptor(moduleContext);
        servletContext.setAttribute(BundleContext.class.getName(), bundleContext);

        // Register the {@link Repository}, {@link Resolver}, {@link Provisioner} services
        Repository repository = registerRepositoryService(runtime);
View Full Code Here

TOP

Related Classes of org.jboss.gravia.runtime.ModuleContext

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.