alma::acs::container::CleaningDaemonThreadFactory Class Reference

Inheritance diagram for alma::acs::container::CleaningDaemonThreadFactory:
Inheritance graph
[legend]
Collaboration diagram for alma::acs::container::CleaningDaemonThreadFactory:
Collaboration graph
[legend]

List of all members.

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

Detailed Description

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.

Author:
hsommer created Mar 8, 2005 1:27:38 PM

Constructor & Destructor Documentation

alma::acs::container::CleaningDaemonThreadFactory::CleaningDaemonThreadFactory ( String  name,
Logger  logger 
) [inline]

Normal constructor.

Parameters:
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.

Parameters:
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).

Member Function Documentation

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.

See also:
java.util.concurrent.ThreadFactory::newThread(java.lang.Runnable)

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]

Member Data Documentation

Referenced by cleanUp(), and ensureGroupCreated().

Referenced by ensureGroupCreated().

Referenced by ensureGroupCreated().

final List<Thread> alma::acs::container::CleaningDaemonThreadFactory::threadList = new ArrayList<Thread>() [private]
final AtomicInteger alma::acs::container::CleaningDaemonThreadFactory::threadNumber = new AtomicInteger(1) [private]

Referenced by newThread().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2