mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-08 06:25:45 +01:00
set names for threads
This commit is contained in:
@@ -26,16 +26,28 @@
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.eventbus.AsyncEventBus;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.ThrowingEventBus;
|
||||
import java.util.concurrent.Executors;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
|
||||
import org.apache.shiro.concurrent.SubjectAwareExecutorService;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
@@ -43,12 +55,16 @@ import org.slf4j.LoggerFactory;
|
||||
public class GuavaScmEventBus extends ScmEventBus
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String THREAD_NAME = "EventBus-%s";
|
||||
|
||||
/**
|
||||
* the logger for GuavaScmEventBus
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(
|
||||
GuavaScmEventBus.class);
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(GuavaScmEventBus.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new ScmEventBus
|
||||
@@ -57,10 +73,17 @@ public class GuavaScmEventBus extends ScmEventBus
|
||||
public GuavaScmEventBus()
|
||||
{
|
||||
eventBus = new ThrowingEventBus();
|
||||
|
||||
//J-
|
||||
ThreadFactory factory = new ThreadFactoryBuilder()
|
||||
.setNameFormat(THREAD_NAME).build();
|
||||
asyncEventBus = new AsyncEventBus(
|
||||
new SubjectAwareExecutorService(Executors.newCachedThreadPool()));
|
||||
new SubjectAwareExecutorService(Executors.newCachedThreadPool(factory))
|
||||
);
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
||||
@@ -37,6 +37,7 @@ package sonia.scm.repository;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -76,6 +77,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
@@ -93,6 +95,8 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
private static final String THREAD_NAME = "Hook-%s";
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
@@ -118,8 +122,14 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
|
||||
this.repositoryListenersProvider = repositoryListenersProvider;
|
||||
this.repositoryHooksProvider = repositoryHooksProvider;
|
||||
|
||||
this.executorService =
|
||||
new SubjectAwareExecutorService(Executors.newCachedThreadPool());
|
||||
//J-
|
||||
ThreadFactory factory = new ThreadFactoryBuilder()
|
||||
.setNameFormat(THREAD_NAME).build();
|
||||
this.executorService = new SubjectAwareExecutorService(
|
||||
Executors.newCachedThreadPool(factory)
|
||||
);
|
||||
//J+
|
||||
|
||||
handlerMap = new HashMap<String, RepositoryHandler>();
|
||||
types = new HashSet<Type>();
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ package sonia.scm.template;
|
||||
import com.github.mustachejava.Mustache;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
@@ -50,6 +51,7 @@ import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
@@ -65,6 +67,9 @@ public class MustacheTemplateEngine implements TemplateEngine
|
||||
public static final TemplateType TYPE = new TemplateType("mustache",
|
||||
"Mustache", "mustache");
|
||||
|
||||
/** Field description */
|
||||
private static final String THREAD_NAME = "Mustache-%s";
|
||||
|
||||
/**
|
||||
* the logger for MustacheTemplateEngine
|
||||
*/
|
||||
@@ -83,7 +88,11 @@ public class MustacheTemplateEngine implements TemplateEngine
|
||||
public MustacheTemplateEngine(ServletContext context)
|
||||
{
|
||||
factory = new ServletMustacheFactory(context);
|
||||
factory.setExecutorService(Executors.newCachedThreadPool());
|
||||
|
||||
ThreadFactory threadFactory =
|
||||
new ThreadFactoryBuilder().setNameFormat(THREAD_NAME).build();
|
||||
|
||||
factory.setExecutorService(Executors.newCachedThreadPool(threadFactory));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user