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


Java Service类代码示例

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


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


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