[New] added StrolchAgent.getSingleThreadExecutor()
This commit is contained in:
parent
21aa92182c
commit
cee1ac4f82
|
@ -104,6 +104,26 @@ public class StrolchAgent {
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link ExecutorService} instantiated for this agent
|
||||||
|
*
|
||||||
|
* @return the {@link ExecutorService} instantiated for this agent
|
||||||
|
*/
|
||||||
|
public ExecutorService getSingleThreadExecutor() {
|
||||||
|
return getSingleThreadExecutor("Agent");
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized ExecutorService getSingleThreadExecutor(String poolName) {
|
||||||
|
DBC.PRE.assertNotEmpty("poolName must be set!", poolName);
|
||||||
|
ExecutorService executor = this.executors.get(poolName);
|
||||||
|
if (executor == null) {
|
||||||
|
executor = Executors.newSingleThreadExecutor(new ThreadPoolFactory(poolName));
|
||||||
|
this.executors.put(poolName, executor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link ScheduledExecutorService} instantiated for this agent
|
* Return the {@link ScheduledExecutorService} instantiated for this agent
|
||||||
*
|
*
|
||||||
|
@ -125,8 +145,8 @@ public class StrolchAgent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the underlying container and prepares the executor services. Before calling this method,
|
* Initializes the underlying container and prepares the executor services. Before calling this method, {@link
|
||||||
* {@link #setup(String, File, File, File)} must have ben called
|
* #setup(String, File, File, File)} must have ben called
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
if (this.container == null)
|
if (this.container == null)
|
||||||
|
|
|
@ -136,6 +136,27 @@ public class StrolchComponent {
|
||||||
return this.container.getAgent().getExecutor(poolName);
|
return this.container.getAgent().getExecutor(poolName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link ExecutorService} instantiated for this agent
|
||||||
|
*
|
||||||
|
* @return the {@link ExecutorService} instantiated for this agent
|
||||||
|
*/
|
||||||
|
protected ExecutorService getSingleThreadExecutor() {
|
||||||
|
return this.container.getAgent().getSingleThreadExecutor();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the {@link ExecutorService} for the given poolName instantiated for this agent
|
||||||
|
*
|
||||||
|
* @param poolName
|
||||||
|
* the name of the pool
|
||||||
|
*
|
||||||
|
* @return the {@link ExecutorService} for the given poolName instantiated for this agent
|
||||||
|
*/
|
||||||
|
protected ExecutorService getSingleThreadExecutor(String poolName) {
|
||||||
|
return this.container.getAgent().getSingleThreadExecutor(poolName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the {@link ScheduledExecutorService} instantiated for this agent
|
* Return the {@link ScheduledExecutorService} instantiated for this agent
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue