Class FacilityManager
- java.lang.Object
-
- jj2000.j2k.util.FacilityManager
-
public class FacilityManager extends Object
This class manages common facilities for mutithreading environments, It can register different facilities for each thread, and also a default one, so that they can be referred by static methods, while possibly having different ones for different threads. Also a default facility exists that is used for threads for which no particular facility has been registerd registered.Currently the only kind of facilities managed is MsgLogger.
An example use of this class is if 2 instances of a decoder are running in different threads and the messages of the 2 instances should be separated.
The default MsgLogger is a StreamMsgLogger that uses System.out as the 'out' stream and System.err as the 'err' stream, and a line width of 78. This can be changed using the registerMsgLogger() method.
- See Also:
MsgLogger,StreamMsgLogger
-
-
Constructor Summary
Constructors Constructor Description FacilityManager()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static MsgLoggergetMsgLogger()Return the MsgLogger registered with the current thread (the thread that calls this method).static MsgLoggergetMsgLogger(Thread t)Return the MsgLogger registered with the thread 't'.static ProgressWatchgetProgressWatch()Return the ProgressWatch instance registered with the current thread (the thread that calls this method).static voidregisterMsgLogger(Thread t, MsgLogger ml)Register MsgLogger 'ml' as the logging facility of the given thread.static voidregisterProgressWatch(Thread t, ProgressWatch pw)Register the ProgressWatch for the given thread.static voidunregisterMsgLogger(Thread t)Unregister the MsgLogger previously registered for the given thread.static voidunregisterProgressWatch(Thread t)Unregister the ProgressWatch previously registered for the given thread.
-
-
-
Constructor Detail
-
FacilityManager
public FacilityManager()
-
-
Method Detail
-
registerProgressWatch
public static void registerProgressWatch(Thread t, ProgressWatch pw)
Register the ProgressWatch for the given thread.If any other logging facility was registered with the given thread, it is overridden. If the Thread is null then 'ml' is taken as the default message logger that is used for threads that have no ProgressWatch registered.
To unregister, use
unregisterProgressWatch(Thread)- Parameters:
t- The thread to associate with progress watcherpw- The ProgressWatch to associate with thread
-
unregisterProgressWatch
public static void unregisterProgressWatch(Thread t)
Unregister the ProgressWatch previously registered for the given thread.If t is null, the default progress watch is unregistered.
- Parameters:
t- Thread to unregister progress watch for, ornullto unregister the default progress watch.- See Also:
registerProgressWatch(Thread, ProgressWatch)
-
getProgressWatch
public static ProgressWatch getProgressWatch()
Return the ProgressWatch instance registered with the current thread (the thread that calls this method). If the current thread has no registered ProgressWatch, then the default one is used.
-
registerMsgLogger
public static void registerMsgLogger(Thread t, MsgLogger ml)
Register MsgLogger 'ml' as the logging facility of the given thread.If any other logging facility was registered with the thread, it is overriden. If the Thread is
null, then the given message logger will be set as the default for threads that have no MsgLogger registered.- Parameters:
t- The thread to associate a MsgLogger forml- The MsgLogger to associate- See Also:
unregisterMsgLogger(Thread)
-
unregisterMsgLogger
public static void unregisterMsgLogger(Thread t)
Unregister the MsgLogger previously registered for the given thread.If the Thread is
null, then the default logger is reset to aStreamMsgLoggerusingSystem.outandSystem.err.- Parameters:
t- The thread to remove the MsgLogger for, ornullto reset the default message logger.- See Also:
registerMsgLogger(Thread, MsgLogger)
-
getMsgLogger
public static MsgLogger getMsgLogger()
Return the MsgLogger registered with the current thread (the thread that calls this method).If the current thread has no registered
MsgLoggerthen the default message logger is returned.- Returns:
- The MsgLogger registered for the current thread, or the default one if there is none registered for it.
- See Also:
registerMsgLogger(Thread, MsgLogger),getMsgLogger(Thread)
-
getMsgLogger
public static MsgLogger getMsgLogger(Thread t)
Return the MsgLogger registered with the thread 't'.If the thread 't' has no registered
MsgLogger, then the default message logger is returned.- Parameters:
t- The thread for which to return the MsgLogger- Returns:
- The MsgLogger registered for the current thread, or the default one if there is none registered for it.
-
-