本文整理汇总了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"));
}
示例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));
}
}
示例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");
}
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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));
}
示例9: getManagedExecutorService
import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
public ManagedExecutorService getManagedExecutorService() {
return managedExecutorService;
}
示例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");
}
示例11: taskSubmitted
import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskSubmitted(Future<?> future, ManagedExecutorService executor, Object task) {
logger.info("Submitted " + task);
}
示例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);
}
示例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);
}
示例14: taskStarting
import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskStarting(Future<?> future, ManagedExecutorService executor, Object task) {
logger.info("Starting " + task);
}
示例15: taskAborted
import javax.enterprise.concurrent.ManagedExecutorService; //导入依赖的package包/类
@Override
public void taskAborted(Future<?> future, ManagedExecutorService mes, Object o, Throwable t) {
System.out.println("aborted");
}