I have successfully created a Guice binding annotation to inject single threaded java.util.concurrent.ExecutorService instances into a constructor.
here is an example usage:
public class ContainsSingleThreadedExecutorService {
private final ExecutorService executorService;
@Inject
public ContainsSingleThreadedExecutorService(@SingleThreaded ExecutorService executorService) {
this.executorService = executorService;
}
}
I now want to create a similar annotation for multi-threaded executors, specifying the ThreadPool size in the annotation. For example:
public class ContainsMultiThreadedExecutorService {
private final ExecutorService executorService;
@Inject
public ContainsMultiThreadedExecutorService(@MultiThreaded(poolSize = 5) ExecutorService executorService) {
this.executorService = executorService;
}
}
Does anyone out there know how I can access the value of the "poolSize" parameter from a Guice Provider?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…