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


Java ServiceBuilder类代码示例

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


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

示例1: performRuntime

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model,
                              ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) throws OperationFailedException {
    final String moduleId = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
    _componentNames.add(moduleId);

    context.addStep(new AbstractDeploymentChainStep() {
        protected void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(SwitchYardExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, _priority++, new SwitchYardModuleDependencyProcessor(moduleId));
        }
    }, OperationContext.Stage.RUNTIME);

    final SwitchYardComponentService componentService = new SwitchYardComponentService(moduleId, model);
    final ServiceBuilder<Component> componentServiceBuilder = context.getServiceTarget().addService(SwitchYardComponentService.SERVICE_NAME.append(moduleId), componentService);
    componentServiceBuilder.addDependency(SwitchYardInjectorService.SERVICE_NAME, Map.class, componentService.getInjectedValues())
            .addDependency(RA_REPOSITORY_SERVICE_NAME, ResourceAdapterRepository.class, componentService.getResourceAdapterRepository());
    componentServiceBuilder.addDependency(WebSubsystemServices.JBOSS_WEB);
    componentServiceBuilder.setInitialMode(Mode.ACTIVE);
    newControllers.add(componentServiceBuilder.install());
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:21,代码来源:SwitchYardModuleAdd.java

示例2: installManagementChannelOpenListenerService

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
/**
 * Set up the services to create a channel listener. This assumes that an endpoint service called {@code endpointName} exists.
 *  @param serviceTarget the service target to install the services into
 * @param endpointName the name of the endpoint to install a channel listener into
 * @param channelName the name of the channel
 * @param operationHandlerName the name of the operation handler to handle request for this channel
 * @param options the remoting options
 * @param onDemand whether to install the services on demand
 */
public static void installManagementChannelOpenListenerService(
        final ServiceTarget serviceTarget,
        final ServiceName endpointName,
        final String channelName,
        final ServiceName operationHandlerName,
        final OptionMap options,
        final boolean onDemand) {

    final ManagementChannelOpenListenerService channelOpenListenerService = new ManagementChannelOpenListenerService(channelName, options);
    final ServiceBuilder<?> builder = serviceTarget.addService(channelOpenListenerService.getServiceName(endpointName), channelOpenListenerService)
            .addDependency(endpointName, Endpoint.class, channelOpenListenerService.getEndpointInjector())
            .addDependency(operationHandlerName, ManagementChannelInitialization.class, channelOpenListenerService.getOperationHandlerInjector())
            .addDependency(ManagementChannelRegistryService.SERVICE_NAME, ManagementChannelRegistryService.class, channelOpenListenerService.getRegistry())
            .addDependency(SHUTDOWN_EXECUTOR_NAME, ExecutorService.class, channelOpenListenerService.getExecutorServiceInjectedValue())
            .setInitialMode(onDemand ? ON_DEMAND : ACTIVE);

    builder.install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:28,代码来源:ManagementRemotingServices.java

示例3: addDependency

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
public static ServiceBuilder<?> addDependency(ServiceBuilder<?> sb, Injector<KeytabIdentityFactoryService> injector,
        String realmName) {
    ServiceBuilder.DependencyType type = ServiceBuilder.DependencyType.REQUIRED;
    sb.addDependency(type, createServiceName(realmName), KeytabIdentityFactoryService.class, injector);

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

示例4: startNeo4jDriverService

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
private void startNeo4jDriverService(OperationContext context, ConfigurationBuilder builder, final Set<String> outboundSocketBindings) throws OperationFailedException {
    if (builder.getJNDIName() != null && builder.getJNDIName().length() > 0) {
        final Neo4jClientConnectionService neo4jClientConnectionService = new Neo4jClientConnectionService(builder);
        final ServiceName serviceName = ConnectionServiceAccess.serviceName(builder.getDescription());
        final ContextNames.BindInfo bindingInfo = ContextNames.bindInfoFor(builder.getJNDIName());

        final BinderService binderService = new BinderService(bindingInfo.getBindName());
        context.getServiceTarget().addService(bindingInfo.getBinderServiceName(), binderService)
                .addDependency(Neo4jSubsystemService.serviceName())
                .addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
                .addDependency(serviceName, Neo4jClientConnectionService.class, new Injector<Neo4jClientConnectionService>() {
                    @Override
                    public void inject(final Neo4jClientConnectionService value) throws
                            InjectionException {
                        binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<>(value.getDriver())));
                    }

                    @Override
                    public void uninject() {
                        binderService.getNamingStoreInjector().uninject();
                    }
                }).install();

        final ServiceBuilder<Neo4jClientConnectionService> serviceBuilder = context.getServiceTarget().addService(serviceName, neo4jClientConnectionService);
        serviceBuilder.addDependency(Neo4jSubsystemService.serviceName(), new CastingInjector<>(neo4jClientConnectionService.getNeo4jSubsystemServiceInjectedValue(), Neo4jSubsystemService.class));
        // add service dependency on each separate hostname/port reference in standalone*.xml referenced from this driver profile definition.
        for (final String outboundSocketBinding : outboundSocketBindings) {
            final ServiceName outboundSocketBindingDependency = context.getCapabilityServiceName(Neo4jDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding, OutboundSocketBinding.class);
            serviceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingDependency, OutboundSocketBinding.class, neo4jClientConnectionService.getOutboundSocketBindingInjector(outboundSocketBinding));
        }
        if (builder.getSecurityDomain() != null) {
            serviceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
                    neo4jClientConnectionService.getSubjectFactoryInjector());
        }

        serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    }
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:39,代码来源:Neo4jDefinition.java

示例5: startServices

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
private void startServices(OperationContext context, Configuration configuration, String outboundSocketBinding) {
    ServiceName connectionsServiceName = ConnectionServiceAccess.serviceName(configuration.getProfileName());
    OrientInteraction orientInteraction = new OrientInteraction(configuration);
    OrientClientConnectionsService connectionsService = new OrientClientConnectionsService(configuration, orientInteraction);
    ServiceBuilder<OrientClientConnectionsService> connectionsServiceBuilder = context.getServiceTarget()
            .addService(connectionsServiceName, connectionsService);

    connectionsServiceBuilder.addDependency(OrientSubsystemService.SERVICE_NAME, new CastingInjector<>(
            connectionsService.getOrientSubsystemServiceInjectedValue(), OrientSubsystemService.class));

    ServiceName outboundSocketBindingServiceName = context.getCapabilityServiceName(
            OrientDriverDefinition.OUTBOUND_SOCKET_BINDING_CAPABILITY_NAME, outboundSocketBinding,
            OutboundSocketBinding.class);
    connectionsServiceBuilder.addDependency(ServiceBuilder.DependencyType.REQUIRED, outboundSocketBindingServiceName,
            new CastingInjector<>(connectionsService.getOutboundSocketBindingInjectedValue(),
                    OutboundSocketBinding.class));
    if (configuration.getSecurityDomain() != null) {
        connectionsServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class,
                connectionsService.getSubjectFactoryInjector());
    }

    connectionsServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
    bindJndi(context, connectionsServiceName, configuration.getJndiName(), orientInteraction.getDatabasePoolClass());
}
 
开发者ID:wildfly,项目名称:wildfly-nosql,代码行数:25,代码来源:OrientDefinition.java

示例6: activate

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    ServiceTarget target = context.getServiceTarget();

    if (!topologyWebAppFractionInstance.isUnsatisfied()) {
        serviceNames = topologyWebAppFractionInstance.get().proxiedServiceMappings().keySet();
    }

    TopologyProxyService proxyService = new TopologyProxyService(serviceNames);
    ServiceBuilder<TopologyProxyService> serviceBuilder = target
            .addService(TopologyProxyService.SERVICE_NAME, proxyService)
            .addDependency(DefaultNamespaceContextSelectorService.SERVICE_NAME)
            .addDependency(TopologyManagerActivator.CONNECTOR_SERVICE_NAME)
            .addDependency(NamingService.SERVICE_NAME);

    for (String serviceName : serviceNames) {
        serviceBuilder.addDependency(proxyService.mscServiceNameForServiceProxy(serviceName),
                                     HttpHandler.class, proxyService.getHandlerInjectorFor(serviceName));
    }
    serviceBuilder.install();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:22,代码来源:TopologyWebAppActivator.java

示例7: activate

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext serviceActivatorContext) throws ServiceRegistryException {

    ServiceTarget target = serviceActivatorContext.getServiceTarget();

    MetricsService service = new MetricsService();
    ServiceBuilder<MetricsService> metricsServiceBuilder = target.addService(MetricsService.SERVICE_NAME, service);

    RegistryFactory factory = new RegistryFactoryImpl();

    ServiceBuilder<MetricsService> serviceBuilder = metricsServiceBuilder
            .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, service.getServerEnvironmentInjector())
            .addDependency(ServiceName.parse("jboss.eclipse.microprofile.config.config-provider"))
            .addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, service.getModelControllerInjector());

    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE)
            .install();

    BinderService binderService = new BinderService(SWARM_MP_METRICS, null, true);

    target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, SWARM_MP_METRICS), binderService)
            .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector())
            .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(factory))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:27,代码来源:MetricsServiceActivator.java

示例8: performRuntime

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    final String moduleId = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue();
    _componentNames.add(moduleId);

    context.addStep(new AbstractDeploymentChainStep() {
        protected void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(SwitchYardExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, _priority++, new SwitchYardModuleDependencyProcessor(moduleId));
        }
    }, OperationContext.Stage.RUNTIME);

    final SwitchYardComponentService componentService = new SwitchYardComponentService(moduleId, model);
    final ServiceBuilder<Component> componentServiceBuilder = context.getServiceTarget().addService(SwitchYardComponentService.SERVICE_NAME.append(moduleId), componentService);
    componentServiceBuilder.addDependency(SwitchYardInjectorService.SERVICE_NAME, Map.class, componentService.getInjectedValues())
            .addDependency(RA_REPOSITORY_SERVICE_NAME, ResourceAdapterRepository.class, componentService.getResourceAdapterRepository());
    componentServiceBuilder.setInitialMode(Mode.ACTIVE);
    componentServiceBuilder.install();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:19,代码来源:SwitchYardModuleAdd.java

示例9: performRuntime

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();
    RuntimeCapability<Void> runtimeCapability = SECURITY_REALM_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName realmName = runtimeCapability.getCapabilityServiceName(SecurityRealm.class);

    final InjectedValue<KeyStore> keyStore = new InjectedValue<KeyStore>();
    TrivialService<SecurityRealm> keyStoreRealmService = new TrivialService<SecurityRealm>(() -> new KeyStoreBackedSecurityRealm(keyStore.getValue()));

    ServiceBuilder<SecurityRealm> serviceBuilder = serviceTarget.addService(realmName, keyStoreRealmService);

    String keyStoreCapabilityName = RuntimeCapability.buildDynamicCapabilityName(KEY_STORE_CAPABILITY, KEYSTORE.resolveModelAttribute(context, model).asString());
    ServiceName keyStoreServiceName = context.getCapabilityServiceName(keyStoreCapabilityName, KeyStore.class);
    KEY_STORE_UTIL.addInjection(serviceBuilder, keyStore, keyStoreServiceName);
    commonDependencies(serviceBuilder)
        .setInitialMode(Mode.ACTIVE)
        .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:KeyStoreRealmDefinition.java

示例10: performRuntime

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {
    ServiceTarget serviceTarget = context.getServiceTarget();
    RuntimeCapability<Void> runtimeCapability = ROLE_DECODER_RUNTIME_CAPABILITY.fromBaseCapability(context.getCurrentAddressValue());
    ServiceName roleDecoderName = runtimeCapability.getCapabilityServiceName(RoleDecoder.class);

    final String attribute = ATTRIBUTE.resolveModelAttribute(context, model).asString();
    TrivialService<RoleDecoder> roleDecoderService = new TrivialService<RoleDecoder>(() -> RoleDecoder.simple(attribute));

    ServiceBuilder<RoleDecoder> roleDecoderBuilderBuilder = serviceTarget.addService(roleDecoderName, roleDecoderService);

    commonDependencies(roleDecoderBuilderBuilder)
        .setInitialMode(Mode.LAZY)
        .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:RoleDecoderDefinitions.java

示例11: getConstantRealmMapper

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
static ResourceDefinition getConstantRealmMapper() {
    AbstractAddStepHandler add = new TrivialAddHandler<RealmMapper>(RealmMapper.class, CONSTANT_REALM_MAPPER_ATTRIBUTES, REALM_MAPPER_RUNTIME_CAPABILITY) {

        @Override
        protected ValueSupplier<RealmMapper> getValueSupplier(ServiceBuilder<RealmMapper> serviceBuilder,
                OperationContext context, ModelNode model) throws OperationFailedException {
            final String realmName = REALM_NAME.resolveModelAttribute(context, model).asString();

            return () -> RealmMapper.single(realmName);
        }
    };

    return TrivialResourceDefinition.builder()
            .setPathKey(ElytronDescriptionConstants.CONSTANT_REALM_MAPPER)
            .setAddHandler(add)
            .setAttributes(CONSTANT_REALM_MAPPER_ATTRIBUTES)
            .setRuntimeCapabilities(REALM_MAPPER_RUNTIME_CAPABILITY).build();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:RealmMapperDefinitions.java

示例12: testInterleavedOps

import org.jboss.msc.service.ServiceBuilder; //导入依赖的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

示例13: testRemoveNonExistingResource

import org.jboss.msc.service.ServiceBuilder; //导入依赖的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

示例14: setupController

import org.jboss.msc.service.ServiceBuilder; //导入依赖的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

示例15: performRuntime

import org.jboss.msc.service.ServiceBuilder; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model)
        throws OperationFailedException {

ServiceTarget serviceTarget = context.getServiceTarget();
RuntimeCapability<?> runtimeCapability = this.runtimeCapability.fromBaseCapability(context.getCurrentAddressValue());
ServiceName componentName = runtimeCapability.getCapabilityServiceName(valueType);

TrivialService<T> componentService = new TrivialService<T>(valueSupplier);

ServiceBuilder<T> componentBuilder = serviceTarget.addService(componentName, componentService);

commonDependencies(componentBuilder)
    .setInitialMode(Mode.LAZY)
    .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:17,代码来源:EmptyResourceDefinition.java


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