net.larsan.urd.impl
Class DefaultErrorHandler

java.lang.Object
  |
  +--net.larsan.urd.util.ErrorHandler
        |
        +--net.larsan.urd.impl.DefaultErrorHandler
All Implemented Interfaces:
Destroyable, LogHandle, RegistryListener, ServiceHandle

public class DefaultErrorHandler
extends ErrorHandler
implements LogHandle, RegistryListener, Destroyable

A default error handler class. This class wraps the log service and buffers log calls if the log service is unavailable. The buffer may contain 100 records after which it starts to drop them.

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Field Summary
 
Fields inherited from interface net.larsan.norna.service.log.LogHandle
NAMESPACE_ID
 
Constructor Summary
DefaultErrorHandler(javax.naming.Context context)
          Create new error handler
 
Method Summary
 void addFilter(Filter filter)
          Add a log filter to the handle.
 boolean checkAccess(Level level)
          Check if the handle would accept a log record based on a level.
 boolean checkAccess(Level level, Type type)
          Check if the handle would accept a log record with a level and type.
 void destroy()
          Destroy component.
 void flush()
          Flush this log handle to make sure no log records are cached.
 Status getStatus()
          Get the status of the service.
 void handleException(java.lang.String msg, java.lang.Object src, java.lang.Throwable th)
          Handle exception with a source and a message.
 void log(Record record)
          Log a record.
 void logError(java.lang.String id, java.lang.String msg, java.lang.Throwable th)
           
 void receiveRegistryEvent(RegistryEvent e)
          Receive registry event.
 void removeFilter(Filter filter)
          Remove a log filter to the handle.
 
Methods inherited from class net.larsan.urd.util.ErrorHandler
handleException, handleException, handleException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultErrorHandler

public DefaultErrorHandler(javax.naming.Context context)
                    throws javax.naming.NamingException
Create new error handler

Parameters:
context - Context to get real log from
Throws:
javax.naming.NamingException - If the service registry cannot be found
Method Detail

checkAccess

public boolean checkAccess(Level level,
                           Type type)
Description copied from interface: LogHandle
Check if the handle would accept a log record with a level and type. This thin check should be used as a preliminary before any log records are actually created in order to improve speed.

Specified by:
checkAccess in interface LogHandle
Parameters:
level - Log level to check
type - Log record type
Returns:
true If the handle would accept records of given type and level

checkAccess

public boolean checkAccess(Level level)
Description copied from interface: LogHandle
Check if the handle would accept a log record based on a level. This thin check should be used as a preliminary before any log records are actually created in order to improve speed.

Specified by:
checkAccess in interface LogHandle
Parameters:
level - Log level to check
Returns:
true If the handle would accept records of given level

log

public void log(Record record)
Description copied from interface: LogHandle
Log a record. This method is never guarrantied to actually commit the record to store. Only if the record is of level and types that the log implementation accepts and the record passes the log filter chain will it be recorded.

Specified by:
log in interface LogHandle
Parameters:
record - Log record, must not be null

addFilter

public void addFilter(Filter filter)
Description copied from interface: LogHandle
Add a log filter to the handle. The filter will be added to the bottom of the chain if this method succeed. Should the caller not have permission to add filters a security exception will be raised.

Specified by:
addFilter in interface LogHandle
Parameters:
filter - Log filter to add to chain, must not be null

removeFilter

public void removeFilter(Filter filter)
Description copied from interface: LogHandle
Remove a log filter to the handle. Should the caller not have permission to remove filters a security exception will be raised.

Specified by:
removeFilter in interface LogHandle
Parameters:
filter - Log filter to remove from chain, must not be null

flush

public void flush()
Description copied from interface: LogHandle
Flush this log handle to make sure no log records are cached. This method should throw a security exception if the caller does not have right to change the log.

Specified by:
flush in interface LogHandle

getStatus

public Status getStatus()
Description copied from interface: ServiceHandle
Get the status of the service. The service is free to do a security check before returning the status, but must never return null.

Specified by:
getStatus in interface ServiceHandle
Returns:
A status object, never null

receiveRegistryEvent

public void receiveRegistryEvent(RegistryEvent e)
Description copied from interface: RegistryListener
Receive registry event.

Specified by:
receiveRegistryEvent in interface RegistryListener

destroy

public void destroy()
Description copied from interface: Destroyable
Destroy component. No is allowed on aother components which also are instances of this interface to avoid mismatches in destruction order.

Specified by:
destroy in interface Destroyable

logError

public void logError(java.lang.String id,
                     java.lang.String msg,
                     java.lang.Throwable th)

handleException

public void handleException(java.lang.String msg,
                            java.lang.Object src,
                            java.lang.Throwable th)
Description copied from class: ErrorHandler
Handle exception with a source and a message. Any of the given arguments may be null and should be gracefully handles.

Specified by:
handleException in class ErrorHandler
Parameters:
msg - Error to msg, may be null
src - Roor source object, may be null
th - Error to handle, may be null