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


Java ManagedExecutorService类代码示例

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


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

示例1: onOpen

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@OnOpen
public void onOpen(Session session) throws NamingException {
	logger.info("Open session:" + session.getId());
	ManagedExecutorService mes = doLookup("java:comp/DefaultManagedExecutorService");
	final Session s = session;
	mes.execute(new Runnable() {
		@Override
		public void run() {
			try {
				for (int i = 0; i < 3; i++) {
					sleep(10000);
					s.getBasicRemote().sendText("Message from server");
				}
			} catch (InterruptedException | IOException e) {
				logger.log(SEVERE, "connection error", e);
			}
		}
	});
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:20,代码来源:WebSocketServer.java

示例2: doCheck

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
private static void doCheck(final ManagedExecutorService es, final ManagedScheduledExecutorService ses, final ManagedThreadFactory tf) {
    assertNotNull(es);
    assertNotNull(ses);
    assertNotNull(tf);

    assertThat(es, instanceOf(ManagedExecutorServiceImpl.class));
    assertEquals(2, pool(es).getCorePoolSize());
    assertEquals(10, pool(es).getMaximumPoolSize());
    assertEquals(4, pool(es).getKeepAliveTime(TimeUnit.MINUTES));

    assertThat(ses, instanceOf(ManagedScheduledExecutorServiceImpl.class));
    assertEquals(12, pool(ses).getCorePoolSize());

    assertThat(tf, instanceOf(ManagedThreadFactoryImpl.class));
    assertEquals("custom-", Reflections.get(tf, "prefix"));
}
 
开发者ID:apache,项目名称:tomee,代码行数:17,代码来源:CustomInjectionTest.java

示例3: setup

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Before
    public void setup() throws NamingException {
        InitialContext ctx = new InitialContext();
        defaultExecutor = (ManagedExecutorService) ctx.lookup("java:comp/DefaultManagedExecutorService");
//        executorFromWebXml = (ManagedExecutorService) ctx.lookup("java:comp/env/concurrent/myExecutor");

        runnableTask = new MyRunnableTask();
        callableTask = new MyCallableTask(1);
        for (int i = 0; i < 5; i++) {
            callableTasks.add(new MyCallableTask(i));
        }
    }
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:13,代码来源:ExecutorJNDITest.java

示例4: taskStarting

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskStarting(Future<?> future, ManagedExecutorService mes, Object o) {
    // cancel task after 3 starts
    if (++startCount > 3) {
        future.cancel(true);
        System.out.println("cancelled periodic task");
    }
}
 
开发者ID:osmanpub,项目名称:oracle-samples,代码行数:9,代码来源:MyDelayedRunnableTask.java

示例5: add

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
private void add(final JndiConsumer jndi, final DeploymentModule module, final DeploymentModule app, final boolean defaults) {

        // Standard names
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:module/ModuleName").value(module.getModuleId()).type(String.class));
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:app/AppName").value(app.getModuleId()).type(String.class));

        // Standard References to built-in objects
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/BeanManager").type(BeanManager.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/Validator").type(Validator.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/ValidatorFactory").type(ValidatorFactory.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionManager").type(TransactionManager.class));
        add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/TransactionSynchronizationRegistry").type(TransactionSynchronizationRegistry.class));

        if (defaults) {
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedExecutorService").type(ManagedExecutorService.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedScheduledExecutorService").type(ManagedScheduledExecutorService.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultManagedThreadFactory").type(ManagedThreadFactory.class));
            add(jndi.getResourceEnvRefMap(), new ResourceEnvRef().name("java:comp/DefaultContextService").type(ContextService.class));
            try {
                final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
                contextClassLoader.loadClass("org.apache.activemq.ActiveMQSslConnectionFactory");
                final ResourceEnvRef ref = new ResourceEnvRef().name("java:comp/DefaultJMSConnectionFactory")
                    .type(contextClassLoader.loadClass("javax.jms.ConnectionFactory"));
                add(jndi.getResourceEnvRefMap(), ref);
            } catch (final ClassNotFoundException | NoClassDefFoundError notThere) {
                // no-op
            }
        }


        // OpenEJB specific feature
        add(jndi.getEnvEntryMap(), new EnvEntry().name("java:comp/ComponentName").value(jndi.getJndiConsumerName()).type(String.class));

    }
 
开发者ID:apache,项目名称:tomee,代码行数:35,代码来源:BuiltInEnvironmentEntries.java

示例6: taskSubmitted

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskSubmitted(final Future<?> future, final ManagedExecutorService executor, final Object task) {
    this.future = future;
    this.executor = executor;

    if (listener != null) {
        listener.taskSubmitted(future, executor, task);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:10,代码来源:ManagedTaskListenerTask.java

示例7: taskAborted

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskAborted(final Future<?> future, final ManagedExecutorService executor, final Object task, final Throwable exception) {
    if (listener != null) {
        // use saved values since called with null excepted for the exception
        listener.taskAborted(this.future, this.executor, this.delegate, exception);
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:8,代码来源:ManagedTaskListenerTask.java

示例8: doCheck

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
private static void doCheck(final ManagedExecutorService es, final ManagedScheduledExecutorService ses,
                            final ContextService ces, final ManagedThreadFactory tf) {
    assertNotNull(es);
    assertNotNull(ses);
    assertNotNull(ces);
    assertNotNull(tf);

    assertThat(es, instanceOf(ManagedExecutorServiceImpl.class));
    assertThat(ses, instanceOf(ManagedScheduledExecutorServiceImpl.class));
    assertThat(ces, instanceOf(ContextServiceImpl.class));
    assertThat(tf, instanceOf(ManagedThreadFactoryImpl.class));
}
 
开发者ID:apache,项目名称:tomee,代码行数:13,代码来源:InjectionTest.java

示例9: getManagedExecutorService

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
public ManagedExecutorService getManagedExecutorService() {
    return managedExecutorService;
}
 
开发者ID:dajudge,项目名称:testee.fi-examples,代码行数:4,代码来源:SessionBean.java

示例10: executorService

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
default ManagedExecutorService executorService() throws Exception {
    InitialContext ctx = new InitialContext();
    return (ManagedExecutorService) ctx.lookup("java:jboss/ee/concurrency/executor/default");
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:5,代码来源:ServiceClient.java

示例11: taskSubmitted

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskSubmitted(Future<?> future, ManagedExecutorService executor, Object task) {
    logger.info("Submitted " + task);
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:5,代码来源:TaskListener.java

示例12: taskAborted

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskAborted(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
    logger.log(Level.WARNING, "Aborted", exception);
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:5,代码来源:TaskListener.java

示例13: taskDone

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskDone(Future<?> future, ManagedExecutorService executor, Object task, Throwable exception) {
    logger.info("Finished task " + task);
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:5,代码来源:TaskListener.java

示例14: taskStarting

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskStarting(Future<?> future, ManagedExecutorService executor, Object task) {
    logger.info("Starting " + task);
}
 
开发者ID:packt-wildfly,项目名称:packt-java-ee-7-code-samples,代码行数:5,代码来源:TaskListener.java

示例15: taskAborted

import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskAborted(Future<?> future, ManagedExecutorService mes, Object o, Throwable t) {
    System.out.println("aborted");
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:5,代码来源:MyTaskWithListener.java


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