• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Service类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setResult

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void setResult(OperationContext context, final String attributeName, final Service<?> service)
        throws OperationFailedException {
    final ScheduledThreadPoolService pool = (ScheduledThreadPoolService) service;
    if(attributeName.equals(CommonAttributes.ACTIVE_COUNT)) {
        context.getResult().set(pool.getActiveCount());
    } else if(attributeName.equals(CommonAttributes.COMPLETED_TASK_COUNT)) {
        context.getResult().set(pool.getCompletedTaskCount());
    } else if (attributeName.equals(CommonAttributes.CURRENT_THREAD_COUNT)) {
        context.getResult().set(pool.getCurrentThreadCount());
    } else if (attributeName.equals(CommonAttributes.LARGEST_THREAD_COUNT)) {
        context.getResult().set(pool.getLargestThreadCount());
    } else if (attributeName.equals(CommonAttributes.TASK_COUNT)) {
        context.getResult().set(pool.getTaskCount());
    } else if (attributeName.equals(CommonAttributes.QUEUE_SIZE)) {
        context.getResult().set(pool.getQueueSize());
    } else {
        // Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
        throw ThreadsLogger.ROOT_LOGGER.unsupportedScheduledThreadPoolMetric(attributeName);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:22,代码来源:ScheduledThreadPoolMetricsHandler.java


示例2: setResult

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void setResult(OperationContext context, final String attributeName, final Service<?> service)
        throws OperationFailedException {
    final UnboundedQueueThreadPoolService pool = (UnboundedQueueThreadPoolService) service;
    if(attributeName.equals(CommonAttributes.ACTIVE_COUNT)) {
        context.getResult().set(pool.getActiveCount());
    } else if(attributeName.equals(CommonAttributes.COMPLETED_TASK_COUNT)) {
        context.getResult().set(pool.getCompletedTaskCount());
    } else if(attributeName.equals(CommonAttributes.CURRENT_THREAD_COUNT)) {
        context.getResult().set(pool.getCurrentThreadCount());
    } else if (attributeName.equals(CommonAttributes.LARGEST_THREAD_COUNT)) {
        context.getResult().set(pool.getLargestThreadCount());
    } else if (attributeName.equals(CommonAttributes.REJECTED_COUNT)) {
        context.getResult().set(pool.getRejectedCount());
    } else if (attributeName.equals(CommonAttributes.TASK_COUNT)) {
        context.getResult().set(pool.getTaskCount());
    }else if (attributeName.equals(CommonAttributes.QUEUE_SIZE)) {
        context.getResult().set(pool.getQueueSize());
    } else {
        // Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
        throw ThreadsLogger.ROOT_LOGGER.unsupportedUnboundedQueueThreadPoolMetric(attributeName);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:UnboundedQueueThreadPoolMetricsHandler.java


示例3: setResult

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void setResult(OperationContext context, final String attributeName, final Service<?> service)
        throws OperationFailedException {
    final QueuelessThreadPoolService pool = (QueuelessThreadPoolService) service;
    if(attributeName.equals(CommonAttributes.CURRENT_THREAD_COUNT)) {
        context.getResult().set(pool.getCurrentThreadCount());
    } else if (attributeName.equals(CommonAttributes.LARGEST_THREAD_COUNT)) {
        context.getResult().set(pool.getLargestThreadCount());
    } else if (attributeName.equals(CommonAttributes.REJECTED_COUNT)) {
        context.getResult().set(pool.getRejectedCount());
    }else if (attributeName.equals(CommonAttributes.QUEUE_SIZE)) {
        context.getResult().set(pool.getRejectedCount());
    } else {
        // Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
        throw ThreadsLogger.ROOT_LOGGER.unsupportedQueuelessThreadPoolMetric(attributeName);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:QueuelessThreadPoolMetricsHandler.java


示例4: setResult

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void setResult(OperationContext context, final String attributeName, final Service<?> service)
        throws OperationFailedException {
    BoundedQueueThreadPoolService bounded = (BoundedQueueThreadPoolService) service;
    if(attributeName.equals(CommonAttributes.CURRENT_THREAD_COUNT)) {
        context.getResult().set(bounded.getCurrentThreadCount());
    } else if (attributeName.equals(CommonAttributes.LARGEST_THREAD_COUNT)) {
        context.getResult().set(bounded.getLargestThreadCount());
    } else if (attributeName.equals(CommonAttributes.REJECTED_COUNT)) {
        context.getResult().set(bounded.getRejectedCount());
    } else if (attributeName.equals(CommonAttributes.QUEUE_SIZE)) {
        context.getResult().set(bounded.getQueueSize());
    } else {
        // Programming bug. Throw a RuntimeException, not OFE, as this is not a client error
        throw ThreadsLogger.ROOT_LOGGER.unsupportedBoundedQueueThreadPoolMetric(attributeName);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:18,代码来源:BoundedQueueThreadPoolMetricsHandler.java


示例5: installService

import org.jboss.msc.service.Service; //导入依赖的package包/类
private Service installService(Class clazz, Object... args) throws Exception {
    Method installer = null;
    for (Method m: clazz.getMethods()) {
        if ("installService".equals(m.getName())) {
            installer = m;
            break;
        }
    }
    if (installer == null) {
        throw new NullPointerException("Class " + clazz + " has no installService method");
    }
    if (installer.getParameterTypes().length == args.length) {
        return (Service) installer.invoke(null, args);
    } else {
        List extra = new ArrayList(Collections.nCopies(2, null));
        extra.addAll(Arrays.asList(args));
        return (Service) installer.invoke(null, extra.toArray());
    }
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:20,代码来源:WildFlyDestinationManager.java


示例6: installEAPSingleton

import org.jboss.msc.service.Service; //导入依赖的package包/类
private static void installEAPSingleton(final ServiceRegistry registry,
                                        final ServiceTarget target,
                                        final Service service,
                                        final ServiceName name) {
    try {
        Class clazz = SingletonHelper.class.getClassLoader()
                .loadClass("org.jboss.as.clustering.singleton.SingletonService");
        Object singletonService = clazz.getDeclaredConstructor(Service.class, ServiceName.class)
                .newInstance(service, name);
        ModuleUtils.lookupMethodByName(clazz, "setElectionPolicy").invoke(singletonService, electionPolicy());
        ServiceBuilder builder = (ServiceBuilder)ModuleUtils.lookupMethod(clazz, "build", ServiceTarget.class)
                .invoke(singletonService, new DelegatingServiceContainer(target, registry));
        builder.setInitialMode(ServiceController.Mode.ACTIVE).install();

    } catch (ClassNotFoundException
            | NoSuchMethodException
            | InstantiationException
            | IllegalAccessException
            | InvocationTargetException e) {
        throw new RuntimeException("Failed to install singleton service", e);
    }
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:23,代码来源:SingletonHelper.java


示例7: installWildFlySingleton

import org.jboss.msc.service.Service; //导入依赖的package包/类
private static void installWildFlySingleton(final ServiceRegistry registry,
                                            final ServiceTarget target,
                                            final Service service,
                                            final ServiceName name) {
    SingletonServiceBuilderFactory factory = null;
    for(ServiceName each : SINGLETON_FACTORY_NAMES) {
        ServiceController factoryService = registry.getService(each);
        if (factoryService != null) {
            factory = (SingletonServiceBuilderFactory)factoryService.getValue();
        }
    }

    if (factory == null) {
        throw new RuntimeException("Failed to locate singleton builder");
    }

    final InjectedValue<ServerEnvironment> env = new InjectedValue<>();
    factory.createSingletonServiceBuilder(name, service)
            .electionPolicy((SingletonElectionPolicy)electionPolicy())
            .requireQuorum(1)
            .build(target)
            .addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, env)
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:26,代码来源:SingletonHelper.java


示例8: start

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
public void start(StartContext context) throws StartException {
    ServiceTarget target = context.getChildTarget();

    target.addService(APPLICATIONS_DIR, new ApplicationsDirectoryService(new File(this.applicationsDirectoryInjector.getValue()).getAbsoluteFile()))
            .install();

    target.addService(APPLICATION_REGISTRY, new ApplicationRegistryService())
            .install();

    ApplicationsDeployerService deployerService = new ApplicationsDeployerService();
    target.addService(APPLICATIONS_DEPLOYER, deployerService)
            .addDependency(APPLICATIONS_DIR, File.class, deployerService.applicationsDirectoryInjector())
            .addDependency(APPLICATION_REGISTRY, InternalApplicationRegistry.class, deployerService.applicationRegistryInjector())
            .install();

    Service<GlobalContext> globalContext = new ValueService<GlobalContext>(new ImmediateValue<>(new GlobalContext()));
    target.addService(GLOBAL_CONTEXT, globalContext)
            .install();
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:21,代码来源:TenancyBootstrappingService.java


示例9: activate

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    Service<Void> service = new AbstractService<Void>() { };
    context.getServiceTarget().addService(BASE.append(this.cacheName).append("activator"), service)
            .addDependency(BASE.append(this.cacheName))
            .setInitialMode(ServiceController.Mode.ACTIVE)
            .install();
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:9,代码来源:CacheActivator.java


示例10: main

import org.jboss.msc.service.Service; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {
	ServiceContainer container = ServiceContainer.Factory.create(); 
	Service<Boolean> service = new MyService("Hello World");
	ServiceBuilder<Boolean> builder = container.addService(MyService.SERVICE, service);
	builder.install();
	Thread.sleep(1000);
	System.out.println("MyService isActive:" + service.getValue());
	container.dumpServices();
}
 
开发者ID:jbosschina,项目名称:wildfly-dev-cookbook,代码行数:10,代码来源:HelloWorld.java


示例11: performRuntime

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    String osb = ATTRIBUTE.resolveModelAttribute(context, resource.getModel()).asString();
    Service<Void> service = new AbstractService<Void>() {};
    context.getServiceTarget().addService(ServiceName.of("wfcore-1106"), service)
            .addDependency(context.getCapabilityServiceName("org.wildfly.network.outbound-socket-binding", osb, OutboundSocketBinding.class))
            .install();

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


示例12: addServiceValue

import org.jboss.msc.service.Service; //导入依赖的package包/类
public <T> ServiceBuilder<T> addServiceValue(final ServiceName name, final Value<? extends Service<T>> value) {
    final ServiceBuilder<T> realBuilder = delegate.addServiceValue(name, value);
    // If done() has been called we are no longer associated with a management op and should just
    // return the builder from delegate
    synchronized (this) {
        if (builderSupplier == null) {
            return realBuilder;
        }
        ContextServiceBuilder<T> csb = builderSupplier.getContextServiceBuilder(realBuilder, name);
        builders.add(csb);
        return csb;
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:OperationContextImpl.java


示例13: addCapability

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
public <T> CapabilityServiceBuilder<T> addCapability(final RuntimeCapability<?> capability, final Service<T> service) throws IllegalArgumentException {
    if (capability.isDynamicallyNamed()){
        return addService(capability.getCapabilityServiceName(targetAddress), service);
    }else{
        return addService(capability.getCapabilityServiceName(), service);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:OperationContextImpl.java


示例14: deploy

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    if(deploymentUnit.getParent() == null) {
        for(final DeploymentUnit subDeployment : deploymentUnit.getAttachmentList(Attachments.SUB_DEPLOYMENTS)) {
            deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_COMPLETE_SERVICES, serviceName(subDeployment.getServiceName()));
        }
    }

    phaseContext.getServiceTarget().addService(serviceName(deploymentUnit.getServiceName()), Service.NULL)
            .addDependencies(deploymentUnit.getAttachmentList(Attachments.DEPLOYMENT_COMPLETE_SERVICES))
            .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:14,代码来源:DeploymentCompleteServiceProcessor.java


示例15: executeRuntimeStep

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) throws OperationFailedException {
    final String attributeName = operation.require(ModelDescriptionConstants.NAME).asString();
    if (context.getRunningMode() == RunningMode.NORMAL) {
        ServiceController<?> serviceController = getService(context, operation);
        final Service<?> service = serviceController.getService();
        setResult(context, attributeName, service);
    }

    context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:ThreadPoolMetricsHandler.java


示例16: installThreadPoolService

import org.jboss.msc.service.Service; //导入依赖的package包/类
static <T> void installThreadPoolService(final Service<T> threadPoolService,
                                         final String threadPoolName,
                                         final ServiceName serviceNameBase,
                                         final String threadFactoryName,
                                         final ThreadFactoryResolver threadFactoryResolver,
                                         final Injector<ThreadFactory> threadFactoryInjector,
                                         final ServiceTarget target) {
    installThreadPoolService(threadPoolService, threadPoolName, serviceNameBase,
            threadFactoryName, threadFactoryResolver, threadFactoryInjector,
            null, null, null,
            target);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ThreadPoolManagementUtils.java


示例17: clusterParticipant

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected ClusterParticipant clusterParticipant(final String name, final boolean singleton) {
    ClusterParticipant participant;
    if (singleton
            && ASUtils.inCluster()) {
        participant = new SingletonClusterParticipant();
        SingletonHelper.installSingleton(this.registry, this.target, (Service) participant,
                                         "immediate-" + name);
    } else {
        participant = AlwaysMasterClusterParticipant.INSTANCE;
    }

    return participant;
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:15,代码来源:ImmediateContextProvider.java


示例18: installSingleton

import org.jboss.msc.service.Service; //导入依赖的package包/类
public static void installSingleton(final ServiceRegistry registry,
                                    final ServiceTarget target,
                                    final Service service,
                                    final String name) {
    final String deploymentName = (String)WunderBoss.options().get("deployment-name");
    final ServiceName serviceName = SINGLETON_NAME.append(deploymentName).append(name);
    if (ASUtils.containerIsEAP6()) {
        installEAPSingleton(registry, target, service, serviceName);
    } else {
        installWildFlySingleton(registry, target, service, serviceName);
    }
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:13,代码来源:SingletonHelper.java


示例19: clusterParticipant

import org.jboss.msc.service.Service; //导入依赖的package包/类
@Override
protected ClusterParticipant clusterParticipant(final String name, final boolean singleton) {
    ClusterParticipant participant;
    if (singleton
            && ASUtils.inCluster()) {
        participant = new SingletonClusterParticipant();
        SingletonHelper.installSingleton(this.registry, this.target, (Service) participant,
                                         "daemon-" + name);
    } else {
        participant = AlwaysMasterClusterParticipant.INSTANCE;
    }

    return participant;
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:15,代码来源:DaemonContextProvider.java


示例20: installService

import org.jboss.msc.service.Service; //导入依赖的package包/类
private static void installService(ServiceName serviceName, Service<?> service, ServiceTarget serviceTarget) {
    serviceTarget.addService(serviceName, service)
        .setInitialMode(Mode.ACTIVE)
        .install();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:6,代码来源:ElytronDefinition.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FieldTypeSignature类代码示例发布时间:2022-05-21
下一篇:
Java SymmetricKeyAlgorithmTags类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap