org.jcoderz.commons
Interface Loggable

All Superinterfaces:
Serializable
All Known Implementing Classes:
ArgumentFractionDigitsViolationException, ArgumentMalformedException, ArgumentMaxLengthViolationException, ArgumentMaxValueViolationException, ArgumentMinLengthViolationException, ArgumentMinValueViolationException, ArgumentPatternViolationException, AssertionFailedException, AuditLogEvent, BaseException, BaseRuntimeException, ConfigurationFactoryFailedException, ConfigurationInitializationFailedException, ConfigurationServiceException, ConfigurationServiceRuntimeException, ConfigurationTypeConversionFailedException, ConfigurationValueNotFoundException, ConnectionRequestFailedException, ConnectionResponseFailedException, ConnectionTimeoutErrorException, ConnectorException, ConnectorRuntimeException, CreatingConnectorFailedException, DatabaseAccessFailedException, DatabaseIntegrityErrorException, EntityNotFoundException, FunnyRuntimeException, ImpliedParameters2Exception, ImpliedParameters3Exception, ImpliedParametersException, InconsistentDatabaseException, InitializingSslFailedException, InternalErrorException, LogEvent, LoggableImpl, LogMessageInfoTest.SampleError, RemoteCallFailureException, RuntimeErrorException, TestServiceException, TestServiceRuntimeException, UnexpectedExceptionException

public interface Loggable
extends Serializable

Interface for all loggable objects.

Author:
Andreas Mandel

Method Summary
 void addParameter(String name, Serializable value)
          Add a new parameter to the Loggable.
 Throwable getCause()
          Returns the cause of this throwable or null if the cause is nonexistent or unknown.
 long getEventTime()
          Returns the point in time when the event occurred.
 String getInstanceId()
          Returns the instance identifier of the process that generated this Loggable.
 LogMessageInfo getLogMessageInfo()
          Returns the LogMessageInfo for this Loggable.
 String getMessage()
          Returns the (Detail) message of this loggable.
 String getNodeId()
          Returns the ip-address or the host name where the Loggable was created.
 List getParameter(String name)
          Returns a list of all parameters with the given name.
 Set getParameterNames()
          Returns a set of available parameters.
 String getSourceClass()
          Tries to find the source class name where this log event was fired.
 String getSourceMethod()
          Tries to find the source method where this log event was fired.
 long getThreadId()
          Returns the thread id of the thread that created this Loggable.
 String getThreadName()
          Returns the thread name as it was valid at the time of creation of this Loggable.
 String getTrackingNumber()
          Returns the (unique) tracking number of this Loggable instance.
 void log()
          Logs this Loggable into the appropriate log sink.
 String toDetailedString()
          The toString method of Loggable must dump out all information stored within this loggable in a readable way.
 String toString()
          The toString method of Loggable dumps the String representation of the class name of the loggable and the contained message.
 

Method Detail

addParameter

void addParameter(String name,
                  Serializable value)
Add a new parameter to the Loggable. All parameters are always added to the Loggable. There is no way of changing or removing a parameter. Once the Loggable was asked for one of it's values there should not be a new parameter. Nevertheless implementations of this interface MUST not throw an exception if this happens. Multiple parameters with the same name are stored within the Loggable. Values must be Serializable and have a useful to String representation. If the value is not serializable it might be sufficient to store the String representation of the value. The Loggable is not responsible to make a deep copy of the value. The calling code should take care for this. To solve this a possible solution would again be to use the String representation of the value.

Parameters:
name - the name of the parameter to be added.
value - the value for the parameter.

getParameter

List getParameter(String name)
Returns a list of all parameters with the given name. Even if the objects in the list are mutable clients are expected not to modify them and to make deep copies as needed. The name must not start with an _ character. These are reserved for internal use.

Parameters:
name - The name of the parameter to be retrieved.
Returns:
a list of serializable objects representing the values of the parameters with the given name.

getParameterNames

Set getParameterNames()
Returns a set of available parameters.

Returns:
a set of available parameters.

getLogMessageInfo

LogMessageInfo getLogMessageInfo()
Returns the LogMessageInfo for this Loggable.

Returns:
the LogMessageInfo for this Loggable.

getTrackingNumber

String getTrackingNumber()
Returns the (unique) tracking number of this Loggable instance.

Returns:
the (unique) tracking number of this Loggable instance.

getMessage

String getMessage()
Returns the (Detail) message of this loggable. The message is created using the pattern of the associated LogMessageInfo and parameters. The field might get truncated on the presentation layer.

Returns:
the (Detail) message of this loggable.

getEventTime

long getEventTime()
Returns the point in time when the event occurred. More general this is the point in time when the Loggable object was created.

Returns:
the point in time when the event occurred, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.

getNodeId

String getNodeId()
Returns the ip-address or the host name where the Loggable was created. The field might get truncated on the presentation layer.

Returns:
the ip-address or the host name where the process is running on.

getInstanceId

String getInstanceId()
Returns the instance identifier of the process that generated this Loggable. The instance id should be a descriptive name for the process running the application. For example, on Bea WLS, we could use the Server name. If no such information is available, the OS Process ID should be used. The field might get truncated on the presentation layer.

Returns:
the instance identifier of the process that generated this Loggable.

getThreadId

long getThreadId()
Returns the thread id of the thread that created this Loggable.

Returns:
the thread id of the thread that created this Loggable.

getThreadName

String getThreadName()
Returns the thread name as it was valid at the time of creation of this Loggable.

Returns:
the thread name as it was valid at the time of creation of this Loggable.
See Also:
Thread.getName()

getCause

Throwable getCause()
Returns the cause of this throwable or null if the cause is nonexistent or unknown. (The cause is the throwable that caused this throwable to get thrown.) The returned object might be a Loggable.

Returns:
the cause of this throwable or null if the cause is nonexistent or unknown.

toString

String toString()
The toString method of Loggable dumps the String representation of the class name of the loggable and the contained message.

Overrides:
toString in class Object
Returns:
one line information about this Loggable.

toDetailedString

String toDetailedString()
The toString method of Loggable must dump out all information stored within this loggable in a readable way. This includes the information of possible nested data.

Returns:
a exhaustive dump of the data stored within this Loggable.

log

void log()
Logs this Loggable into the appropriate log sink.


getSourceMethod

String getSourceMethod()
Tries to find the source method where this log event was fired.

Returns:
the name of the method including the line number if available
See Also:
StackTraceElement.getMethodName(), StackTraceElement.getLineNumber()

getSourceClass

String getSourceClass()
Tries to find the source class name where this log event was fired.

Returns:
the name of the class
See Also:
StackTraceElement.getClassName()


Copyright 2007 The jCoderZ Project.