use of org.jboss.threads.JBossThreadFactory in project wildfly by wildfly.
the class KeyAffinityServiceFactoryBuilder method build.
@Override
public ServiceBuilder<KeyAffinityServiceFactory> build(ServiceTarget target) {
int bufferSize = this.bufferSize;
Function<ExecutorService, KeyAffinityServiceFactory> mapper = executor -> new KeyAffinityServiceFactory() {
@Override
public <K> KeyAffinityService<K> createService(Cache<K, ?> cache, KeyGenerator<K> generator) {
CacheMode mode = cache.getCacheConfiguration().clustering().cacheMode();
return mode.isDistributed() || mode.isReplicated() ? new KeyAffinityServiceImpl<>(executor, cache, generator, bufferSize, Collections.singleton(cache.getCacheManager().getAddress()), false) : new SimpleKeyAffinityService<>(generator);
}
};
Supplier<ExecutorService> supplier = () -> {
ThreadGroup threadGroup = new ThreadGroup("KeyAffinityService ThreadGroup");
String namePattern = "KeyAffinityService Thread Pool -- %t";
PrivilegedAction<ThreadFactory> action = () -> new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null);
return Executors.newCachedThreadPool(doPrivileged(action));
};
Service<KeyAffinityServiceFactory> service = new SuppliedValueService<>(mapper, supplier, ExecutorService::shutdown);
return new AsynchronousServiceBuilder<>(this.getServiceName(), service).startSynchronously().build(target).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
use of org.jboss.threads.JBossThreadFactory in project wildfly by wildfly.
the class UndertowEventHandlerAdapter method start.
@Override
public void start(StartContext context) {
UndertowService service = this.service.getValue();
ContainerEventHandler eventHandler = this.eventHandler.getValue();
this.connector = new UndertowConnector(this.listener.getValue());
this.server = new UndertowServer(service, connector);
// Register ourselves as a listener to the container events
service.registerListener(this);
// Initialize mod_cluster and start it now
eventHandler.init(this.server);
eventHandler.start(this.server);
// Start the periodic STATUS thread
ThreadGroup group = new ThreadGroup(UndertowEventHandlerAdapter.class.getSimpleName());
ThreadFactory factory = doPrivileged(new PrivilegedAction<ThreadFactory>() {
public ThreadFactory run() {
return new JBossThreadFactory(group, Boolean.FALSE, null, "%G - %t", null, null);
}
});
this.executor = Executors.newScheduledThreadPool(1, factory);
this.executor.scheduleWithFixedDelay(this, 0, statusInterval, TimeUnit.SECONDS);
suspendController.getValue().registerActivity(this);
}
use of org.jboss.threads.JBossThreadFactory in project wildfly by wildfly.
the class WeldExecutorServices method start.
@Override
public void start(final StartContext context) throws StartException {
final ThreadGroup threadGroup = new ThreadGroup("Weld ThreadGroup");
final ThreadFactory factory = new JBossThreadFactory(threadGroup, Boolean.FALSE, null, THREAD_NAME_PATTERN, null, null);
// set TCCL to null for new threads to make sure no deployment classloader leaks through this executor's TCCL
// Weld does not mind having null TCCL in this executor
this.executor = new WeldExecutor(bound, runnable -> {
Thread thread = factory.newThread(runnable);
if (WildFlySecurityManager.isChecking()) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
thread.setContextClassLoader(null);
return null;
}
});
} else {
thread.setContextClassLoader(null);
}
return thread;
});
if (executorServicesConsumer != null)
executorServicesConsumer.accept(this);
}
use of org.jboss.threads.JBossThreadFactory in project wildfly by wildfly.
the class JdrReportService method start.
public synchronized void start(StartContext context) throws StartException {
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<JBossThreadFactory>() {
public JBossThreadFactory run() {
return new JBossThreadFactory(new ThreadGroup("JdrReportCollector-threads"), Boolean.FALSE, null, "%G - %t", null, null);
}
});
executorService = Executors.newCachedThreadPool(threadFactory);
serverEnvironment = serverEnvironmentValue.getValue();
controllerClient = modelControllerValue.getValue().createClient(executorService);
}
use of org.jboss.threads.JBossThreadFactory in project wildfly by wildfly.
the class AbstractResourceAdapterDeploymentService method getLifecycleExecutorService.
protected final ExecutorService getLifecycleExecutorService() {
ExecutorService result = executorServiceInjector.getOptionalValue();
if (result == null) {
// We added injection of the server executor late in WF 8, so in case some
// add-on projects don't know to inject it....
final ThreadGroup threadGroup = new ThreadGroup("ResourceAdapterDeploymentService ThreadGroup");
final String namePattern = "ResourceAdapterDeploymentService Thread Pool -- %t";
final ThreadFactory threadFactory = doPrivileged(new PrivilegedAction<JBossThreadFactory>() {
public JBossThreadFactory run() {
return new JBossThreadFactory(threadGroup, Boolean.FALSE, null, namePattern, null, null);
}
});
result = Executors.newSingleThreadExecutor(threadFactory);
}
return result;
}
Aggregations