net.sourceforge.acelogger.factory
Class ExecutorManagerFactory

java.lang.Object
  extended by net.sourceforge.acelogger.factory.ExecutorManagerFactory

public final class ExecutorManagerFactory
extends Object

Factory for managing instances of configured executor managers.

Since:
1.0.0
Version:
1.0.0
Author:
Zardi (https://sourceforge.net/users/daniel_zardi)

Method Summary
static boolean awaitExecutorManagersShutdown(long terminationTimeout)
          Awaits for the execution of the remaining tasks in executor managers registered in this factory.
static boolean doProperExecutorManagersShutdown()
          Shuts down each of the registered executor managers, this should be called to guarantee that all tasks submitted will be run before termination.
static ExecutorManager getDefaultExecutorManager()
          Returns the default manager of this factory, the one used when no manager is found for a given identifier.
static ExecutorManager getExecutorManager(String identifier)
          Obtains a properly configured manager for the given identifier.
static List<ExecutorManager> getRegisteredExecutorManagers()
          Returns a list of all managers registered in this factory.
static boolean isShutdown()
          Indicates if this factory has ordered all of its managers a shutdown or not.
static ExecutorManager registerExecutorManager(ExecutorManager manager)
          Registers an appender within this factory.
static ExecutorManager setDefaultExecutorManager(ExecutorManager manager)
          Sets the default manager of this factory, the one used when no manager is found for a given identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getExecutorManager

public static ExecutorManager getExecutorManager(String identifier)
Obtains a properly configured manager for the given identifier.

Parameters:
identifier - The identifier of the intended manager.
Returns:
A properly configured manager for the given identifier. If the identifier is not found, then the default manager is returned.
Since:
1.0.0
See Also:
getDefaultExecutorManager()

setDefaultExecutorManager

public static ExecutorManager setDefaultExecutorManager(ExecutorManager manager)
Sets the default manager of this factory, the one used when no manager is found for a given identifier.

Parameters:
manager - The manager that will be used as the default one from now.
Returns:
The previous default manager.
Since:
1.0.0

getDefaultExecutorManager

public static ExecutorManager getDefaultExecutorManager()
Returns the default manager of this factory, the one used when no manager is found for a given identifier.

Returns:
The default manager.
Since:
1.0.0

registerExecutorManager

public static ExecutorManager registerExecutorManager(ExecutorManager manager)
Registers an appender within this factory. The mapped identifier will be the managers identifier.

Parameters:
manager - The manager to be registered.
Returns:
The default manager if there was no previous mapping for the identifier or the previous configured manager otherwise.
Since:
1.0.0
See Also:
getDefaultExecutorManager()

getRegisteredExecutorManagers

public static List<ExecutorManager> getRegisteredExecutorManagers()
Returns a list of all managers registered in this factory.

Returns:
A list of managers.
Since:
1.0.0

isShutdown

public static boolean isShutdown()
Indicates if this factory has ordered all of its managers a shutdown or not. If this factory has ordered shutdown, it is not safe to execute any task.

Returns:
True id the shutdown was previously ordered, false otherwise.
Since:
1.0.0

doProperExecutorManagersShutdown

public static boolean doProperExecutorManagersShutdown()
Shuts down each of the registered executor managers, this should be called to guarantee that all tasks submitted will be run before termination.

Returns:
True if all executors finished their tasks properly, false if there are tasks under or awaiting execution.
Since:
1.0.0

awaitExecutorManagersShutdown

public static boolean awaitExecutorManagersShutdown(long terminationTimeout)
                                             throws TerminationException
Awaits for the execution of the remaining tasks in executor managers registered in this factory. This method should be called after ordering a proper shutdown of the executors.

Parameters:
terminationTimeout - The maximum time (in ms) to wait while executing the remaining tasks.
Returns:
True if all executor managers terminated execution of its tasks before the supplied timeout; False otherwise.
Throws:
TerminationException - if interrupted while waiting for managers to shutdown.
Since:
1.0.0
See Also:
doProperExecutorManagersShutdown()


Copyright © 2007-2010 The AceLogger Team. All Rights Reserved.