package com.amebame.triton.server;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.amebame.triton.config.TritonServerConfiguration;
import com.amebame.triton.util.NamedThreadFactory;

@Singleton
public class TritonServerContext {
	
	private TritonServerMethodMap methodMap;
	
	private ExecutorService executor;
	
	@Inject
	public TritonServerContext(TritonServerConfiguration config) {
		methodMap = new TritonServerMethodMap();
		executor = new ThreadPoolExecutor(
				1,
				config.getNetty().getWorker(),
				60L,
				TimeUnit.SECONDS,
				new LinkedBlockingQueue<Runnable>(),
				new NamedThreadFactory("triton-worker-")
		);
	}
	
	/**
	 * Add server methods from the target object
	 * @param target
	 */
	public void addServerMethod(Object target) {
		methodMap.register(target);
	}
	
	/**
	 * Get server method by name
	 * @param name
	 * @return
	 */
	public TritonServerMethod getServerMethod(String name) {
		return methodMap.getMethod(name);
	}

	/**
	 * Get worker executor
	 * @return
	 */
	public ExecutorService getWorkerExecutor() {
		return executor;
	}
}

@@ -106,113 +106,17 @@
 ent.
-LinkedBlockingQueue;%0Aimport java.util.concurrent.ThreadPoolExecutor;%0Aimport java.util.concurrent.TimeUnit
+Executors
 ;%0A%0Ai
@@ -548,38 +548,37 @@
 r = 
-new ThreadPoolExecutor(%0A%09%09%09%091,
+Executors.newFixedThreadPool(
 %0A%09%09%09
@@ -613,80 +613,8 @@
 (),%0A
-%09%09%09%0960L,%0A%09%09%09%09TimeUnit.SECONDS,%0A%09%09%09%09new LinkedBlockingQueue%3CRunnable%3E(),%0A
 %09%09%09%09
@@ -653,19 +653,16 @@
 orker-%22)
-%0A%09%09
 );%0A%09%7D%0A%09%0A

Make worker executor to FixedThreadPoolExecutor.