Skip to content

Commit

Permalink
Use generics in ThreadPoolExecutorFactory properly to avoid compiler …
Browse files Browse the repository at this point in the history
…warnings
  • Loading branch information
rhusar authored and galderz committed Mar 25, 2015
1 parent 10e4b97 commit 2dce32f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/** /**
* @author Galder Zamarreño * @author Galder Zamarreño
*/ */
public class BlockingThreadPoolExecutorFactory implements ThreadPoolExecutorFactory { public class BlockingThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ExecutorService> {


private static final Log log = LogFactory.getLog(BlockingThreadPoolExecutorFactory.class); private static final Log log = LogFactory.getLog(BlockingThreadPoolExecutorFactory.class);


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** /**
* @author Galder Zamarreño * @author Galder Zamarreño
*/ */
public class CachedThreadPoolExecutorFactory implements ThreadPoolExecutorFactory { public class CachedThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ExecutorService> {


private static final CachedThreadPoolExecutorFactory INSTANCE = new CachedThreadPoolExecutorFactory(); private static final CachedThreadPoolExecutorFactory INSTANCE = new CachedThreadPoolExecutorFactory();


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/** /**
* @author Galder Zamarreño * @author Galder Zamarreño
*/ */
public class ScheduledThreadPoolExecutorFactory implements ThreadPoolExecutorFactory { public class ScheduledThreadPoolExecutorFactory implements ThreadPoolExecutorFactory<ScheduledExecutorService> {


private static final ScheduledThreadPoolExecutorFactory INSTANCE = new ScheduledThreadPoolExecutorFactory(); private static final ScheduledThreadPoolExecutorFactory INSTANCE = new ScheduledThreadPoolExecutorFactory();


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
/** /**
* @author Galder Zamarreño * @author Galder Zamarreño
*/ */
public interface ThreadPoolExecutorFactory { public interface ThreadPoolExecutorFactory<T extends ExecutorService> {


<T extends ExecutorService> T createExecutor(ThreadFactory factory); T createExecutor(ThreadFactory factory);


/** /**
* Validate parameters for the thread pool executor factory * Validate parameters for the thread pool executor factory
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List; import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
Expand All @@ -24,13 +25,13 @@
*/ */
public final class LazyInitializingBlockingTaskAwareExecutorService implements BlockingTaskAwareExecutorService { public final class LazyInitializingBlockingTaskAwareExecutorService implements BlockingTaskAwareExecutorService {


private final ThreadPoolExecutorFactory executorFactory; private final ThreadPoolExecutorFactory<ExecutorService> executorFactory;
private final ThreadFactory threadFactory; private final ThreadFactory threadFactory;
private final TimeService timeService; private final TimeService timeService;
private volatile BlockingTaskAwareExecutorService delegate; private volatile BlockingTaskAwareExecutorService delegate;


public LazyInitializingBlockingTaskAwareExecutorService( public LazyInitializingBlockingTaskAwareExecutorService(
ThreadPoolExecutorFactory executorFactory, ThreadFactory threadFactory, ThreadPoolExecutorFactory<ExecutorService> executorFactory, ThreadFactory threadFactory,
TimeService timeService) { TimeService timeService) {
this.executorFactory = executorFactory; this.executorFactory = executorFactory;
this.threadFactory = threadFactory; this.threadFactory = threadFactory;
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
public final class LazyInitializingExecutorService implements ExecutorService { public final class LazyInitializingExecutorService implements ExecutorService {


private volatile ExecutorService delegate; private volatile ExecutorService delegate;
private final ThreadPoolExecutorFactory executorFactory; private final ThreadPoolExecutorFactory<ExecutorService> executorFactory;
private final ThreadFactory threadFactory; private final ThreadFactory threadFactory;


public LazyInitializingExecutorService( public LazyInitializingExecutorService(
ThreadPoolExecutorFactory executorFactory, ThreadFactory threadFactory) { ThreadPoolExecutorFactory<ExecutorService> executorFactory, ThreadFactory threadFactory) {
this.executorFactory = executorFactory; this.executorFactory = executorFactory;
this.threadFactory = threadFactory; this.threadFactory = threadFactory;
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;


/** /**
* A delegating scheduled executor that lazily constructs and initalizes the underlying scheduled executor, since * A delegating scheduled executor that lazily constructs and initializes the underlying scheduled executor, since
* unused JDK executors are expensive. * unused JDK executors are expensive.
* *
* @author Manik Surtani * @author Manik Surtani
Expand All @@ -24,11 +24,11 @@
public class LazyInitializingScheduledExecutorService implements ScheduledExecutorService { public class LazyInitializingScheduledExecutorService implements ScheduledExecutorService {


private volatile ScheduledExecutorService delegate; private volatile ScheduledExecutorService delegate;
private final ThreadPoolExecutorFactory executorFactory; private final ThreadPoolExecutorFactory<ScheduledExecutorService> executorFactory;
private final ThreadFactory threadFactory; private final ThreadFactory threadFactory;


public LazyInitializingScheduledExecutorService( public LazyInitializingScheduledExecutorService(
ThreadPoolExecutorFactory executorFactory, ThreadFactory threadFactory) { ThreadPoolExecutorFactory<ScheduledExecutorService> executorFactory, ThreadFactory threadFactory) {
this.executorFactory = executorFactory; this.executorFactory = executorFactory;
this.threadFactory = threadFactory; this.threadFactory = threadFactory;
} }
Expand Down

0 comments on commit 2dce32f

Please sign in to comment.