abeans::pluggable::acs::LoggingExceptionHandlerService Class Reference
List of all members.
|
Public Member Functions |
| LoggingExceptionHandlerService () |
String | createExceptionReport (Throwable ex) |
void | exceptionInstantiated (CommonThrowable ex) |
ComponentDescriptor | getComponentDescriptor () |
Throwable[] | getExceptions () |
ExceptionTreeNode[] | getRootExceptions () |
void | initialize (ComponentManager manager, Object state, ComponentDescriptor cdesc) throws ComponentInitializationException, IllegalComponentStateException |
void | addExceptionListener (AbeansExceptionListener listener) |
void | removeExceptionListener (AbeansExceptionListener listener) |
AbeansExceptionListener[] | getExceptionListeners () |
void | notifyListeners (NodeImpl node) |
String | toString () |
boolean | isDebug () |
Class[] | getSupportedPolicies () |
PolicyList | installPolicies (PolicyList policies) |
void | refreshHierarchicalPolicies () |
Private Member Functions |
StringBuffer | insertPrefix (StringBuffer sb, String prefix) |
String | createSingleExceptionReport (Throwable t) |
long | generateSingleExceptionMessageLog (Throwable t, long closestTimeStamp, String stackId, int level) |
NodeImpl | findParent (NodeImpl node) |
void | resetTimer (NodeImpl node) |
Private Attributes |
ComponentDescriptor | cdesc = null |
ArrayList | rootExceptions = new ArrayList() |
HashMap | exceptionToNode = new HashMap() |
SimpleDateFormat | sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS") |
ObjectList | exceptionListeners = new ObjectList(AbeansExceptionListener.class) |
long | waitTimeForExceptionTree = 2000 |
int | reportLevel = 1 |
boolean | showStackTrace = true |
boolean | showExceptionTree = false |
Class[] | supportedPolicies = { EHSReportLevel.class, EHSStackTrace.class, EHSWaitTimeForTree.class, EHSExceptionTree.class } |
Detailed Description
TODO replace this implementation with DefaultExceptionHandlerService and handle logging via notification callback
The default ACS implementation of exception handler service heavily beased on abeans.core.defaults.DefaultExceptionHandlerService
. This implementation forwards all exceptions to MessageLog
service.
This implementation of exception handler service stores the exceptions in an array list in the order in which they were reported to the service. This java.util.List
also constitutes the state of this service, that may be exchanged in the state transfer with other services. The default processing of this service is to integrate the reports and send them to:
1. Resource location "Errors" if it is available.
2. Normal message log, if it is available. If none of these services is available when exception handler is initializing, the installation of this service will fail.
This service intercepts all instances of either AssertionFailed
or CoreException
, because they report to this service (if available) in their constructors. Whenever an exception is constructed, this service waits for a certain time interval (typically of the order of several seconds) and listens for other exceptions. All exceptions caught in such time interval are examined for interrelations (by traversing their getCause()
lists) and for correlated exceptions, a single exception report will be created.
Note that this service returns all exceptions as instances of Throwable
and not more specific class (for example CoreException
). The reason is the following: in the case where one exception causes another, the first exception may be, for example, one of the standard Java exceptions (like IllegalStateException
). The users of this service (for example visualization tools) should, on each exception, try instanceof com.cosylab.util.CommonThrowable
test before casting. If the test succeeds, a lot of additional information can be obtained through CommonThrowable
interface.
This service implementation should not create excessive logs to prevent recursion in log generation in case exceptions are thrown in the logging service.
For integrating exceptions in a separate thread this service will use ThreadPoolService
if it is available; otherwise new thread will be launched for each exception.
- Author:
- Gasper Tkacik (gasper.tkacik@cosylab.com)
Matej Sekoranja (matej.sekoranja@cosylab.com)
- Version:
- @VERSION@
- See also:
- abeans.core.CoreException
abeans.core.AssertionFailed
Constructor & Destructor Documentation
abeans::pluggable::acs::LoggingExceptionHandlerService::LoggingExceptionHandlerService |
( |
|
) |
[inline] |
|
|
Default constructor as prescribed by component interface. Delegates to super constructor. |
Member Function Documentation
void abeans::pluggable::acs::LoggingExceptionHandlerService::addExceptionListener |
( |
AbeansExceptionListener |
listener |
) |
[inline] |
|
String abeans::pluggable::acs::LoggingExceptionHandlerService::createExceptionReport |
( |
Throwable |
ex |
) |
[inline] |
|
|
Creates the exception report by extracting the data from the exception. Additional information may be appended by the handler service, for instance information concerning the username, current host, current application etc. The report will be delivered either to the "Error" resource location or to the message log.
- Parameters:
-
| ex | exception for which the report will be generated, non-null |
|
String abeans::pluggable::acs::LoggingExceptionHandlerService::createSingleExceptionReport |
( |
Throwable |
t |
) |
[inline, private] |
|
|
Creates an exception report.
- Parameters:
-
| t | exception for which the report will be generated, non-null |
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::exceptionInstantiated |
( |
CommonThrowable |
ex |
) |
[inline] |
|
|
This method should be invoked by the exception in its constructor after the internal state of the exception has been set. In response, the exception handler may query the exception immediately for the report generation, or it may store the exception for later processing. Do not generate log entries, because this may cause infinite loops if the exception is instantiated in the loggers.
- Parameters:
-
| ex | exception that has been instantiated, must extend Throwable , non-null |
|
NodeImpl abeans::pluggable::acs::LoggingExceptionHandlerService::findParent |
( |
NodeImpl |
node |
) |
[inline, private] |
|
|
Finds the root node for a given node.
- Parameters:
-
| node | the node for which the parent is to be found, non-null |
- Returns:
- the parent of the
impl parameter, or null if the parent does not exist
|
long abeans::pluggable::acs::LoggingExceptionHandlerService::generateSingleExceptionMessageLog |
( |
Throwable |
t, |
|
|
long |
closestTimeStamp, |
|
|
String |
stackId, |
|
|
int |
level |
|
) |
[inline, private] |
|
|
Creates an exception report.
- Parameters:
-
| t | exception for which the report will be generated, non-null |
- Returns:
- timestamp of generated exception (if not deteminate, closesTimeStamp should be returned)
|
ComponentDescriptor abeans::pluggable::acs::LoggingExceptionHandlerService::getComponentDescriptor |
( |
|
) |
[inline] |
|
|
Returns an instance of the ComponentDescriptor that parametrizes this component. The component should create an immutable descriptor instance only once and always return the same instance.
- Returns:
- a description of this component
|
AbeansExceptionListener [] abeans::pluggable::acs::LoggingExceptionHandlerService::getExceptionListeners |
( |
|
) |
[inline] |
|
Throwable [] abeans::pluggable::acs::LoggingExceptionHandlerService::getExceptions |
( |
|
) |
[inline] |
|
|
The service returns all of the exceptions that have been reported through exceptionInstantiated() since the installation of the service. Notice that this also includes exceptions created, thrown, caught and handled.
- Returns:
- a list of all exceptions thrown during the lifetime of this service
|
ExceptionTreeNode [] abeans::pluggable::acs::LoggingExceptionHandlerService::getRootExceptions |
( |
|
) |
[inline] |
|
|
Returns all "first" exceptions, i.e. exceptions that do not declare any parent throwable (see CoreException documentation for details). It is possible then to browse the exception tree by doing traversals of the tree nodes and hence discovering which further exceptions have been caused by the this exception tree node.
- Returns:
- a list of root "first" exceptions
|
Class [] abeans::pluggable::acs::LoggingExceptionHandlerService::getSupportedPolicies |
( |
|
) |
[inline] |
|
|
- See also:
- abeans.core.QoSProvider#getSupportedPolicies()
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::initialize |
( |
ComponentManager |
manager, |
|
|
Object |
state, |
|
|
ComponentDescriptor |
cdesc |
|
) |
throws ComponentInitializationException, IllegalComponentStateException [inline] |
|
|
Initializes the component. This includes examination of other installed components to determine if message log or error resource location are available. If none are availabe, the installation fails.
- Parameters:
-
| manager | manager into which this component will be instantiated, non-null |
| state | must be null , this component does not support state transfer |
| cdesc | must be null , this component does not support state transfer |
- Exceptions:
-
| IllegalComponentStateException | when the state or descriptor parameters are not null |
| ComponentInitializationException | when neither the message log nor error resource location are present |
|
StringBuffer abeans::pluggable::acs::LoggingExceptionHandlerService::insertPrefix |
( |
StringBuffer |
sb, |
|
|
String |
prefix |
|
) |
[inline, private] |
|
|
Prefixes each line stored in the string buffer array with the string specified by prefix .
- Parameters:
-
| sb | the array in which each line (delimeted by newline character) will be prefixed |
| prefix | the string inserted after each newline character into string buffer |
|
PolicyList abeans::pluggable::acs::LoggingExceptionHandlerService::installPolicies |
( |
PolicyList |
policies |
) |
[inline] |
|
|
- See also:
- abeans.core.QoSProvider#installPolicies(abeans.core.PolicyList)
|
boolean abeans::pluggable::acs::LoggingExceptionHandlerService::isDebug |
( |
|
) |
[inline] |
|
|
No not work in debug mode at all (generates to much overhead).
- See also:
- abeans.core.Identifiable#isDebug()
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::notifyListeners |
( |
NodeImpl |
node |
) |
[inline] |
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::refreshHierarchicalPolicies |
( |
|
) |
[inline] |
|
|
- See also:
- abeans.core.QoSProvider#refreshHierarchicalPolicies()
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::removeExceptionListener |
( |
AbeansExceptionListener |
listener |
) |
[inline] |
|
void abeans::pluggable::acs::LoggingExceptionHandlerService::resetTimer |
( |
NodeImpl |
node |
) |
[inline, private] |
|
|
Starts the timer from when the exception is thrown until the timer expires. During this time exceptions are integrated and correlated. After the timer expires, the exception report is created and delivered to target (message log or error resource location).
- Parameters:
-
| node | the node which is to be timed, non-null |
|
String abeans::pluggable::acs::LoggingExceptionHandlerService::toString |
( |
|
) |
[inline] |
|
|
Returns a short summary about this instance.
- Returns:
- internal state of this
|
Member Data Documentation
The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:43:16 2009 for ACS Java API by
1.3.8