

Classes | |
| class | LoggingThreadGroup |
Public Member Functions | |
| CleaningDaemonThreadFactory (String name, Logger logger) | |
| CleaningDaemonThreadFactory (String name, Logger logger, String ownerName) | |
| Thread | newThread (Runnable command) |
| List< Thread > | _getAllThreadsCreated () |
| synchronized void | cleanUp () |
Package Functions | |
| void | setNewThreadContextClassLoader (ClassLoader cl) |
Private Member Functions | |
| synchronized void | ensureGroupCreated () |
Private Attributes | |
| final List< Thread > | threadList = new ArrayList<Thread>() |
| final AtomicInteger | threadNumber = new AtomicInteger(1) |
| final Logger | logger |
| final String | name |
| final String | ownerName |
| LoggingThreadGroup | group |
| ClassLoader | newThreadContextCL |
Thread factory that remembers all threads it creates. Method cleanUp allows killing all threads.
A ThreadGroup is used to deal with all threads at a time. Its name is that given in the constructor. Even though Josh Bloch tells us in "Effective Java", Item 53, that thread groups are almost useless, we like the UncaughtExceptionHandler which JDK 1.4 only offers through ThreadGroups. TODO: revisit this in JDK 1.5 where Thread itself has this handler.
| alma::acs::container::CleaningDaemonThreadFactory::CleaningDaemonThreadFactory | ( | String | name, | |
| Logger | logger | |||
| ) | [inline] |
Normal constructor.
| name | the name of the ThreadGroup to which all threads created by this factory will belong. | |
| logger | the logger to be used by this class |
| alma::acs::container::CleaningDaemonThreadFactory::CleaningDaemonThreadFactory | ( | String | name, | |
| Logger | logger, | |||
| String | ownerName | |||
| ) | [inline] |
Special constructor, e.g. when used internally by the container.
| name | the name of the ThreadGroup to which all threads created by this factory will belong. | |
| logger | the logger to be used by this class | |
| ownerName | Can show up in log messages such as warnings by LoggingThreadGroup#uncaughtException(Thread, Throwable). |
| List<Thread> alma::acs::container::CleaningDaemonThreadFactory::_getAllThreadsCreated | ( | ) | [inline] |
Gets a copy of the list of all threads created by this factory up to this call. This method should only be used for testing, but not in operational code.
References threadList.
Referenced by alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testMonitorEasy(), and alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::testResourceUnavailable().
| synchronized void alma::acs::container::CleaningDaemonThreadFactory::cleanUp | ( | ) | [inline] |
Kills running threads via Thread#interrupt() or Thread#stop(), see code comments about the two cases. Should be called by the container or similar classes when all threads created by this factory supposedly have terminated anyway thanks to smart applications. The safety concerns which led to the deprecation of the stop method thus don't seem to apply here.
References group, logger, alma::acs::container::CleaningDaemonThreadFactory::LoggingThreadGroup::setShuttingDown(), and threadList.
Referenced by alma::acs::container::ComponentAdapter::deactivateComponent(), alma::acs::container::ComponentAdapter::getComponentAbortionist(), alma::acs::component::client::ComponentClientTestCase::tearDown(), alma::acs::component::client::ComponentClient::tearDown(), alma::ACS::jbaci::test::BACIDispatchActionTest::tearDown(), alma::acs::container::CleaningThreadFactoryTest::testNoOp(), and alma::acs::container::CleaningThreadFactoryTest::testStoppingThreads().
| synchronized void alma::acs::container::CleaningDaemonThreadFactory::ensureGroupCreated | ( | ) | [inline, private] |
References group, logger, name, and ownerName.
Referenced by newThread().
| Thread alma::acs::container::CleaningDaemonThreadFactory::newThread | ( | Runnable | command | ) | [inline] |
Creates a new daemon thread that is part of the same factory thread group as all other threads created by this method. The thread's name will be that of the group, with an integer value appended.
References ensureGroupCreated(), group, newThreadContextCL, threadList, and threadNumber.
Referenced by alma::ACS::MasterComponentImpl::SubsysResourceMonitorTest::setUp(), alma::acs::container::CleaningThreadFactoryTest::testStoppingThreads(), and alma::acs::container::CleaningThreadFactoryTest::testUserThreadException().
| void alma::acs::container::CleaningDaemonThreadFactory::setNewThreadContextClassLoader | ( | ClassLoader | cl | ) | [inline, package] |
References newThreadContextCL.
Referenced by alma::acs::container::ComponentAdapter::ComponentAdapter().
Referenced by cleanUp(), ensureGroupCreated(), and newThread().
final Logger alma::acs::container::CleaningDaemonThreadFactory::logger [private] |
Referenced by cleanUp(), and ensureGroupCreated().
final String alma::acs::container::CleaningDaemonThreadFactory::name [private] |
Referenced by ensureGroupCreated().
ClassLoader alma::acs::container::CleaningDaemonThreadFactory::newThreadContextCL [private] |
Referenced by newThread(), and setNewThreadContextClassLoader().
final String alma::acs::container::CleaningDaemonThreadFactory::ownerName [private] |
Referenced by ensureGroupCreated().
final List<Thread> alma::acs::container::CleaningDaemonThreadFactory::threadList = new ArrayList<Thread>() [private] |
Referenced by _getAllThreadsCreated(), cleanUp(), and newThread().
final AtomicInteger alma::acs::container::CleaningDaemonThreadFactory::threadNumber = new AtomicInteger(1) [private] |
Referenced by newThread().
1.6.2