当前位置: 首页>>代码示例>>Java>>正文


Java Runtime类代码示例

本文整理汇总了Java中org.jboss.gravia.runtime.Runtime的典型用法代码示例。如果您正苦于以下问题:Java Runtime类的具体用法?Java Runtime怎么用?Java Runtime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Runtime类属于org.jboss.gravia.runtime包,在下文中一共展示了Runtime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testServletAccess

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Test
public void testServletAccess() throws Exception {

    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    Module module = runtime.getModule(getClass().getClassLoader());
    HttpService httpService = ServiceLocator.getRequiredService(HttpService.class);

    // Verify that the alias is not yet available
    String reqspec = "/fabric8/service?test=param&param=Kermit";
    assertNotAvailable(reqspec);

    // Register the test servlet and make a call
    httpService.registerServlet("/service", new HttpServiceServlet(module), null, null);
    Assert.assertEquals("Hello: Kermit", performCall(reqspec));

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

    // Verify that the alias is not available any more
    assertNotAvailable(reqspec);
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:23,代码来源:HttpServiceTestBase.java

示例2: testStreamResource

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
/**
 * Provision a resource from an input stream.
 *
 * The client controlls the resource identity
 * The installed resource is self sufficient - no additional dependency mapping needed.
 */
@Test
public void testStreamResource() throws Exception {

    Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class);

    ResourceIdentity identityA = ResourceIdentity.fromString(RESOURCE_A);
    ResourceBuilder builderA = provisioner.getContentResourceBuilder(identityA, deployer.getDeployment(RESOURCE_A));
    Resource resourceA = builderA.getResource();

    ResourceHandle handle = provisioner.installResource(resourceA);
    try {
        // Verify that the module got installed
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Module module = runtime.getModule(identityA);
        Assert.assertNotNull("Module not null", module);
        Assert.assertEquals("ACTIVE " + module, State.ACTIVE, module.getState());

        // Verify that the module activator was called
        MBeanServer server = ServiceLocator.getRequiredService(MBeanServer.class);
        Assert.assertTrue("MBean registered", server.isRegistered(getObjectName(module)));
        Assert.assertEquals("ACTIVE", server.getAttribute(getObjectName(module), "ModuleState"));
    } finally {
        handle.uninstall();
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:32,代码来源:ProvisionerTest.java

示例3: testMavenResource

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
/**
 * Provision a resource from maven coordinates.
 *
 * The client controlls the resource identity
 * The installed resource is self sufficient - no additional dependency mapping needed.
 */
@Test
public void testMavenResource() throws Exception {

    // Tomcat does not support jar deployments
    Assume.assumeFalse(RuntimeType.TOMCAT == RuntimeType.getRuntimeType());

    Provisioner provisioner = ServiceLocator.getRequiredService(Provisioner.class);

    ResourceIdentity identityA = ResourceIdentity.fromString("camel.core.unshared");
    MavenCoordinates mavenid = MavenCoordinates.parse("org.apache.camel:camel-core:jar:2.11.0");
    ResourceBuilder builderA = provisioner.getMavenResourceBuilder(identityA, mavenid);
    Resource resourceA = builderA.getResource();

    ResourceHandle handleA = provisioner.installResource(resourceA);
    try {
        Runtime runtime = RuntimeLocator.getRequiredRuntime();
        Assert.assertSame(handleA.getModule(), runtime.getModule(identityA));
        Assert.assertEquals("ACTIVE " + identityA, State.ACTIVE, handleA.getModule().getState());
    } finally {
        handleA.uninstall();
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:29,代码来源:ProvisionerTest.java

示例4: getResourceB

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Deployment(name = RESOURCE_B, managed = false, testable = false)
public static Archive<?> getResourceB() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, RESOURCE_B + ".jar");
    archive.addClasses(ModuleStateB.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_B);
            builder.addExportPackages(ModuleStateB.class);
            builder.addImportPackages(Runtime.class, Resource.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:18,代码来源:ProvisionerTest.java

示例5: getContentF3

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Deployment(name = CONTENT_F3, managed = false, testable = false)
public static Archive<?> getContentF3() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, CONTENT_F3 + ".jar");
    archive.addClasses(ModuleStateB.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_F);
            builder.addExportPackages(ModuleStateB.class);
            builder.addImportPackages(Runtime.class, Resource.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:18,代码来源:ProvisionerTest.java

示例6: getContentG3

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Deployment(name = CONTENT_G3, managed = false, testable = false)
public static Archive<?> getContentG3() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, CONTENT_G3 + ".jar");
    archive.addClasses(BundleActivatorBridge.class, ModuleActivatorB.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_G);
            builder.addBundleActivator(BundleActivatorBridge.class);
            builder.addManifestHeader(Constants.MODULE_ACTIVATOR, ModuleActivatorB.class.getName());
            builder.addImportPackages(Runtime.class, Resource.class, ServiceLocator.class);
            builder.addImportPackages(MBeanServer.class, ModuleStateB.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:20,代码来源:ProvisionerTest.java

示例7: getResourceB

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
public static Archive<?> getResourceB() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, RESOURCE_B + ".jar");
    archive.addClasses(ModuleStateA.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_B);
            builder.addExportPackages(ModuleStateA.class);
            builder.addImportPackages(Runtime.class, Resource.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:17,代码来源:ResourceItemTestBase.java

示例8: getContentF3

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
public static Archive<?> getContentF3() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, CONTENT_F3 + ".jar");
    archive.addClasses(ModuleStateB.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_F);
            builder.addExportPackages(ModuleStateB.class);
            builder.addImportPackages(Runtime.class, Resource.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:17,代码来源:ResourceItemTestBase.java

示例9: getContentG3

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
public static Archive<?> getContentG3() {
    JavaArchive archive = ShrinkWrap.create(JavaArchive.class, CONTENT_G3 + ".jar");
    archive.addClasses(BundleActivatorBridge.class, ModuleActivatorB.class);
    archive.setManifest(new Asset() {
        @Override
        public InputStream openStream() {
            OSGiManifestBuilder builder = OSGiManifestBuilder.newInstance();
            builder.addBundleManifestVersion(2);
            builder.addBundleSymbolicName(RESOURCE_G);
            builder.addBundleActivator(BundleActivatorBridge.class);
            builder.addManifestHeader(Constants.MODULE_ACTIVATOR, ModuleActivatorB.class.getName());
            builder.addImportPackages(Runtime.class, Resource.class, ServiceLocator.class);
            builder.addImportPackages(MBeanServer.class, ModuleStateB.class);
            return builder.openStream();
        }
    });
    return archive;
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:19,代码来源:ResourceItemTestBase.java

示例10: testManagedKaraf

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Test
@Ignore
public void testManagedKaraf() throws Exception {

    // Build the {@link CreateOptions}
    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    File dataDir = new File((String) runtime.getProperty(RuntimeService.RUNTIME_DATA_DIR));

    CreateOptions options = KarafContainerBuilder.create()
            .identity("ManagedKaraf")
            .outputToConsole(true)
            .targetPath(dataDir.toPath())
            .getCreateOptions();

    ContainerManager cntManager = ContainerManagerLocator.getContainerManager();
    Container cnt = cntManager.createContainer(options);
    ContainerIdentity cntId = cnt.getIdentity();
    try {
        // Start the container
        cnt = cntManager.startContainer(cntId, null);
        verifyContainer(cnt);
    } finally {
        cnt = cntManager.stopContainer(cntId);
        Assert.assertEquals(State.STOPPED, cnt.getState());
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:27,代码来源:ManagedContainerTestBase.java

示例11: contextInitialized

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent event) {

    // [TODO] #41 Invalid class load of embedded interface despite defined dependency
    // https://issues.jboss.org/browse/WFLY-3511
    try {
        ModuleClassLoader classLoader = (ModuleClassLoader) getClass().getClassLoader();
        org.jboss.modules.Module graviaModule = classLoader.getModule().getModuleLoader().loadModule(ModuleIdentifier.create("org.jboss.gravia"));
        org.jboss.modules.Module osgiModule = classLoader.getModule().getModuleLoader().loadModule(ModuleIdentifier.create("org.osgi.enterprise"));
        Class<?> interfClass = loadClass(null, osgiModule.getClassLoader(), "org.osgi.service.http.HttpService");
        Class<?> implClass = loadClass(null, graviaModule.getClassLoader(), "org.apache.felix.http.base.internal.service.HttpServiceImpl");
        if (!interfClass.isAssignableFrom(implClass)) {
            System.out.println("NOT ASSIGNABLE: " + interfClass + " <= " + implClass);
        }
    } catch (Exception ex) {
        throw new IllegalStateException(ex);
    }

    ServletContext servletContext = event.getServletContext();

    // HttpService integration
    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    Module sysmodule = runtime.getModuleContext().getModule();
    BundleContext bundleContext = sysmodule.adapt(Bundle.class).getBundleContext();
    servletContext.setAttribute(BundleContext.class.getName(), bundleContext);
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:27,代码来源:FabricRuntimeActivator.java

示例12: run

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Override
public void run() {
    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    LOGGER.info("Agent shutdown initiated ...");
    shutdownLatch.countDown();
    runtime.shutdown();
    try {
        if (runtime.awaitShutdown(10, TimeUnit.SECONDS)) {
            LOGGER.info("Agent shutdown complete");
        } else {
            LOGGER.error("Cannot shutdown agent in time");
        }
    } catch (InterruptedException ex) {
        LOGGER.error("Agent shutdown interrupted", ex);
    }
}
 
开发者ID:tdiesler,项目名称:fabric8poc,代码行数:17,代码来源:Main.java

示例13: testModuleLifecycle

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Test
public void testModuleLifecycle() throws Exception {

    Runtime runtime = RuntimeLocator.getRequiredRuntime();
    Module modA = runtime.getModule(getClass().getClassLoader());
    Assert.assertEquals(Module.State.ACTIVE, modA.getState());

    ModuleContext context = modA.getModuleContext();
    ServiceRegistration<String> sreg = context.registerService(String.class, new String("Hello"), null);
    Assert.assertNotNull("Null sreg", sreg);

    String service = context.getService(sreg.getReference());
    Assert.assertEquals("Hello", service);

    modA.stop();
    Assert.assertEquals(Module.State.INSTALLED, modA.getState());

    modA.uninstall();
    Assert.assertEquals(Module.State.UNINSTALLED, modA.getState());
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:21,代码来源:WebappBundleModuleLifecycleTest.java

示例14: installPluginModule

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Override
public Module installPluginModule(Runtime runtime, ClassLoader classLoader) throws ModuleException {
    String resourceName = getBundleActivator().replace('.', '/') + ".class";
    URL resurl = classLoader.getResource(resourceName);
    if (resurl == null) {
        RuntimeLogger.LOGGER.debug("Cannot load BundleActivator resource '{}'", resourceName);
        return null;
    }

    String urlpath = resurl.toExternalForm();
    urlpath = urlpath.substring(0, urlpath.indexOf(resourceName));
    urlpath = urlpath + JarFile.MANIFEST_NAME;

    Manifest manifest;
    try {
        manifest = new Manifest(new URL(urlpath).openStream());
    } catch (Exception ex) {
        throw new ModuleException("Cannot load plugin manifest: " + urlpath, ex);
    }

    Dictionary<String, String> headers = new ManifestHeadersProvider(manifest).getHeaders();
    headers.put(Constants.MODULE_ACTIVATOR, getClass().getName());
    return runtime.installModule(classLoader, headers);
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:25,代码来源:AbstractRuntimePlugin.java

示例15: setUp

import org.jboss.gravia.runtime.Runtime; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    PropertiesProvider propsProvider = new DefaultPropertiesProvider();
    RuntimeFactory factory = new RuntimeFactory() {
        @Override
        public Runtime createRuntime(PropertiesProvider propertiesProvider) {
            return new EmbeddedRuntime(propertiesProvider, null) {
                @Override
                protected ModuleEntriesProvider getDefaultEntriesProvider(Module module, Attachable context) {
                    return new ClassLoaderEntriesProvider(module);
                }
            };
        }
    };
    runtime = RuntimeLocator.createRuntime(factory, propsProvider);
    runtime.init();
}
 
开发者ID:tdiesler,项目名称:gravia,代码行数:18,代码来源:AbstractEmbeddedRuntimeTest.java


注:本文中的org.jboss.gravia.runtime.Runtime类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。