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


Java ServiceContainer类代码示例

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


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

示例1: doGet

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Override
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {

        ServiceContainer sc = CurrentServiceContainer.getServiceContainer();

//        for(ServiceName sn: sc.getServiceNames()) {
//            log.info("" + sn);
//        }

        ServiceName sn = ServiceName.of("jboss", "infinispan", "web", "repl");
        ServiceController scon = sc.getService(sn);
        Cache cache = (Cache)scon.getValue();
        log.info("" + cache);


        String path = req.getPathInfo();

        Object o = null;

        if ("/put".equals(path)) {
            cache.put("test", "blah");
        }
        else if ("/get".equals(path)) {

            o = cache.get("test");
        }

        res.setContentType("text/html");
        PrintWriter out = res.getWriter();

        if (o != null) {
            out.println(o);
        }
    }
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:36,代码来源:AccessServlet.java

示例2: start

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
    parser = new HCIDumpParser(cmdArgs);
    final ServiceContainer serviceContainer = context.getController().getServiceContainer();

    try {
        log.infof("Begin scanning");
        // Start the scanner parser handler threads other than the native stack handler
        parser.start();
        // Setup the native bluetooth stack integration, callbacks, and stack thread
        HCIDump.setRawEventCallback(parser::beaconEvent);
        HCIDump.initScanner(cmdArgs.hciDev);
        // Schedule a thread to wait for a shutdown marker
        Thread shutdownMonitor = new Thread(() -> awaitShutdown(serviceContainer), "ShutdownMonitor");
        shutdownMonitor.setDaemon(true);
        shutdownMonitor.start();
    } catch (Exception e) {
        log.error("Scanner exiting on exception", e);
        context.failed(new StartException(e));
    }
}
 
开发者ID:RHioTResearch,项目名称:SwarmBeaconScanner,代码行数:22,代码来源:ScannerService.java

示例3: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Before
public void setupController() throws InterruptedException {
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    if (useDelegateRootResourceDefinition) {
        initializer = createInitializer();
        controllerService = new ModelControllerService(getAuditLogger(), rootResourceDefinition);
    } else {
        controllerService = new ModelControllerService(getAuditLogger());
    }
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), controllerService);
    builder.install();
    controllerService.awaitStartup(30, TimeUnit.SECONDS);
    controller = controllerService.getValue();
    //ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
    //controller.execute(setup, null, null, null);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:AbstractControllerTestBase.java

示例4: findAllMissingServices

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
private static SortedSet<ServiceName> findAllMissingServices(Set<ServiceController<?>> missingTransitive, Set<ServiceName> alreadyTracked) {
    // Check all relevant service containers. This is a bit silly since in reality there
    // should only be one that is associated with every SC that is passed in,
    // but I'm being anal and vaguely future-proofing a bit
    Set<ServiceContainer> examined = new HashSet<ServiceContainer>();
    SortedSet<ServiceName> allMissingServices = new TreeSet<ServiceName>();
    for (ServiceController<?> controller : missingTransitive) {
        ServiceContainer container = controller.getServiceContainer();
        if (examined.add(container)) {
            allMissingServices.addAll(findAllMissingServices(container));
        }
    }

    Set<ServiceName> retain = new HashSet<>(allMissingServices);
    retain.removeAll(alreadyTracked);
    if (retain.size() == 0) {
        allMissingServices.clear();
    }

    return allMissingServices;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:ServiceVerificationHelper.java

示例5: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
private ManagementResourceRegistration setupController(ProcessType processType, TestResourceDefinition resourceDefinition) throws InterruptedException {

        System.out.println("=========  New Test \n");
        container = ServiceContainer.Factory.create(TEST_METRIC);
        ServiceTarget target = container.subTarget();
        ModelControllerService svc = new ModelControllerService(processType, resourceDefinition);
        ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
        builder.install();
        svc.awaitStartup(30, TimeUnit.SECONDS);
        controller = svc.getValue();
        ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
        controller.execute(setup, null, null, null);

        client = controller.createClient(executor);

        return svc.managementControllerResource;
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:MetricsRegistrationTestCase.java

示例6: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
private ManagementResourceRegistration setupController(TestResourceDefinition resourceDefinition) throws InterruptedException {

        // restore default
        blockObject = new CountDownLatch(1);
        latch = new CountDownLatch(1);

        System.out.println("=========  New Test \n");
        container = ServiceContainer.Factory.create(TEST_METRIC);
        ServiceTarget target = container.subTarget();
        ModelControllerService svc = new ModelControllerService(resourceDefinition);
        ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
        builder.install();
        svc.awaitStartup(30, TimeUnit.SECONDS);
        controller = svc.getValue();
        ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
        controller.execute(setup, null, null, null);

        client = controller.createClient(executor);

        return svc.managementControllerResource;
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:MetricsUndefinedValueUnitTestCase.java

示例7: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Before
public void setupController() throws InterruptedException {

    // restore default
    blockObject = new CountDownLatch(1);
    latch = new CountDownLatch(1);

    System.out.println("=========  New Test \n");
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    ModelControllerService svc = new ModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    controller = svc.getValue();
    ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
    controller.execute(setup, null, null, null);

    client = controller.createClient(executor);

    managementControllerResource = svc.managementControllerResource;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:OperationCancellationUnitTestCase.java

示例8: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Before
public void setupController() throws InterruptedException {

    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    ModelControllerService svc = new ModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    sharedState = svc.getSharedState();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    controller = svc.getValue();
    ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
    controller.execute(setup, null, null, null);
    notificationHandler = new ServiceNotificationHandler();
    controller.getNotificationRegistry().registerNotificationHandler(PathAddress.pathAddress(CORE_SERVICE, MANAGEMENT).append(SERVICE, MANAGEMENT_OPERATIONS), notificationHandler, notificationHandler);
    assertEquals(ControlledProcessState.State.RUNNING, svc.getCurrentProcessState());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:ModelControllerImplUnitTestCase.java

示例9: testInterleavedOps

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Test
public void testInterleavedOps() throws Exception {
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    TestModelControllerService svc = new InterleavedSubsystemModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    ModelController controller = svc.getValue();

    final ModelNode op = Util.getEmptyOperation(READ_RESOURCE_OPERATION, new ModelNode());
    op.get(RECURSIVE).set(true);

    ModelNode result = controller.execute(op, null, null, null);
    assertTrue(result.hasDefined(OUTCOME));
    assertEquals(SUCCESS, result.get(OUTCOME).asString());
    assertTrue(result.hasDefined(RESULT));
    assertTrue(result.get(RESULT).hasDefined(EXTENSION));
    assertTrue(result.get(RESULT, EXTENSION).hasDefined("a"));
    assertTrue(result.get(RESULT, EXTENSION, "a").hasDefined(MODULE.getName()));
    assertEquals("a", result.get(RESULT, EXTENSION, "a", MODULE.getName()).asString());
    assertTrue(result.get(RESULT, EXTENSION).hasDefined("b"));
    assertTrue(result.get(RESULT, EXTENSION, "b").hasDefined(MODULE.getName()));
    assertEquals("b", result.get(RESULT, EXTENSION, "b", MODULE.getName()).asString());
    assertTrue(result.get(RESULT, EXTENSION).hasDefined("c"));
    assertTrue(result.get(RESULT, EXTENSION, "c").hasDefined(MODULE.getName()));
    assertEquals("c", result.get(RESULT, EXTENSION, "c", MODULE.getName()).asString());
    assertTrue(result.get(RESULT).hasDefined(SUBSYSTEM));
    assertTrue(result.get(RESULT, SUBSYSTEM).hasDefined("a"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "a").hasDefined("attribute"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "a", "attribute").asBoolean());
    assertTrue(result.get(RESULT, SUBSYSTEM).hasDefined("b"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "b").hasDefined("attribute"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "b", "attribute").asBoolean());
    assertTrue(result.get(RESULT, SUBSYSTEM).hasDefined("c"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "c").hasDefined("attribute"));
    assertTrue(result.get(RESULT, SUBSYSTEM, "c", "attribute").asBoolean());

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:40,代码来源:InterleavedSubsystemTestCase.java

示例10: testRemoveNonExistingResource

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Test
public void testRemoveNonExistingResource() throws Exception {
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    TestModelControllerService svc = new InterleavedSubsystemModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    ModelController controller = svc.getValue();

    final PathAddress attributePath = PathAddress.pathAddress(PathElement.pathElement("subsystem", "a"))
            .append(PathElement.pathElement(SUBMODEL_NAME, "nonExisting"));
    final ModelNode op = Util.createEmptyOperation(REMOVE, attributePath);
    ModelNode result = controller.execute(op, null, null, null);

    Assert.assertEquals("failed", result.get("outcome").asString());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:RemoveNotEsistingResourceTestCase.java

示例11: testRemoveExistingResource

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Test
public void testRemoveExistingResource() throws Exception {
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    TestModelControllerService svc = new InterleavedSubsystemModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    ModelController controller = svc.getValue();

    // create child node
    final PathAddress attributePath = PathAddress.pathAddress(PathElement.pathElement("subsystem", "a"))
            .append(PathElement.pathElement(SUBMODEL_NAME, "existing"));
    final ModelNode addChild = Util.createEmptyOperation(ADD, attributePath);
    controller.execute(addChild, null, null, null);

    // should be able to remove it
    final ModelNode op = Util.createEmptyOperation(REMOVE, attributePath);
    ModelNode result = controller.execute(op, null, null, null);

    Assert.assertEquals("success", result.get("outcome").asString());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:23,代码来源:RemoveNotEsistingResourceTestCase.java

示例12: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Before
public void setupController() throws InterruptedException {
    System.out.println("=========  New Test \n");

    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    TestModelControllerService svc = new ModelControllerImplUnitTestCase.ModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
    builder.install();
    sharedState = svc.getSharedState();
    svc.awaitStartup(30, TimeUnit.SECONDS);
    controller = svc.getValue();
    ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
    controller.execute(setup, null, null, null);

    assertEquals(ControlledProcessState.State.RUNNING, svc.getCurrentProcessState());
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:CompositeOperationHandlerUnitTestCase.java

示例13: setupController

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Before
public void setupController() throws InterruptedException {

    // restore default
    blockObject = new CountDownLatch(1);
    latch = new CountDownLatch(1);

    System.out.println("=========  New Test \n");
    container = ServiceContainer.Factory.create("test");
    ServiceTarget target = container.subTarget();
    controllerService = new ModelControllerService();
    ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), controllerService);
    builder.install();
    controllerService.awaitStartup(30, TimeUnit.SECONDS);
    ModelController controller = controllerService.getValue();

    client = controller.createClient(executor);

    System.setProperty(BlockingTimeout.SYSTEM_PROPERTY, "1");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:21,代码来源:OperationTimeoutUnitTestCase.java

示例14: ContextCreateHandlerRegistryImpl

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
ContextCreateHandlerRegistryImpl(final ServiceContainer serviceContainer, final ServiceTarget serviceTarget) {

            // Setup the default handlers
            addContextCreateHandler(null, new ModuleClassLoaderAssociationHandler());
            addContextCreateHandler(null, new ClassResolverAssociationHandler());
            addContextCreateHandler(null, new ComponentResolverAssociationHandler(subsystemState));

            subsystemState.processExtensions(new Consumer<CamelSubsytemExtension>() {
                @Override
                public void accept(CamelSubsytemExtension plugin) {
                    ContextCreateHandler handler = plugin.getContextCreateHandler(serviceContainer, serviceTarget, subsystemState);
                    if (handler != null) {
                        addContextCreateHandler(null, handler);
                    }
                }
            });
        }
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:18,代码来源:ContextCreateHandlerRegistryService.java

示例15: testHttpEndpoint

import org.jboss.msc.service.ServiceContainer; //导入依赖的package包/类
@Test
public void testHttpEndpoint() throws Exception {

    ServiceContainer container = ServiceLocator.getRequiredService(ServiceContainer.class);
    ServiceName hostServiceName = UndertowService.virtualHostName("default-server", "default-host");
    Host host = (Host) container.getRequiredService(hostServiceName).getValue();

    final StringBuilder result = new StringBuilder();
    host.registerHandler("/myapp/myservice", new HttpHandler() {
        @Override
        public void handleRequest(HttpServerExchange exchange) throws Exception {
            String name = exchange.getQueryParameters().get("name").getFirst();
            result.append("Hello " + name);
        }});

    HttpResponse response = HttpRequest.get("http://localhost:8080/myapp/myservice?name=Kermit").getResponse();
    Assert.assertEquals(HttpURLConnection.HTTP_OK, response.getStatusCode());
    Assert.assertEquals("Hello Kermit", result.toString());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:20,代码来源:UndertowHandlerTest.java


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