public final class TraceNotification extends Notification implements VendorExtensions
TraceMBean
. Trace notifications
for a particular notification source are enabled by setting the appropriate trace
level for the notification source using the methods on the TraceMBean
interface. If a trace message is generated in the SLEE, typically using a
Tracer
object, at a trace level lower than
the trace level set for the notification source in the Trace MBean, the message is
discarded by the SLEE and no trace notification is generated.
Trace notifications contain a NotificationSource
object that can be used to
obtain more information about the object that caused the trace notification to be
generated. The type of a trace notification can be used to infer the type of the
notification source object contained in the notification:
Notification.getType()
== SbbNotification.TRACE_NOTIFICATION_TYPE
then the type of the notification source object is SbbNotification
.
Notification.getType()
== ResourceAdaptorEntityNotification.TRACE_NOTIFICATION_TYPE
then the type of the notification source object is ResourceAdaptorEntityNotification
.
Notification.getType()
== ProfileTableNotification.TRACE_NOTIFICATION_TYPE
then the type of the notification source object is ProfileTableNotification
.
Notification.getType()
== SubsystemNotification.TRACE_NOTIFICATION_TYPE
then the type of the notification source object is SubsystemNotification
.
As of SLEE 1.1, serialization of this class has been modified to take into account cause
Throwable
objects that may not be deserializable client-side due to classloader
issues. For example, if the cause of a trace message is an object of a custom exception
class included in the deployable unit of a component, a generic client may not have
that class available in its classpath or be able to load it via Java's remote class loading
mechanisms (eg. the codebase URL could be a file://
URL on a different host
that cannot be resolved on the client host). Serialization of a TraceNotification
object containing a cause now includes the stack trace of that cause in the serialization
stream. If the cause Throwable
cannot be later deserialized with the
TraceNotification
object, a generic java.lang.Exception
with a message containing the original stack trace is returned as the trace's cause
instead.
source
Constructor and Description |
---|
TraceNotification(String type,
TraceMBean traceMBean,
NotificationSource notificationSource,
String tracerName,
TraceLevel traceLevel,
String message,
Throwable cause,
long sequenceNumber,
long timestamp)
Create a
TraceNotification to notify listeners of a trace message. |
TraceNotification(TraceMBean traceMBean,
String messageType,
Object messageSource,
Level traceLevel,
String message,
Throwable cause,
long sequenceNumber,
long timestamp)
Deprecated.
Trace notifications have been expanded with new attributes to take advantage
of the new features provided by the SLEE specification. The
TraceNotification(String, TraceMBean, NotificationSource, String, javax.slee.facilities.TraceLevel, String, Throwable, long, long)
constructor should be used instead of this constructor. |
Modifier and Type | Method and Description |
---|---|
static void |
disableVendorDataDeserialization()
Disable the deserialization of vendor-specific data for objects of this class.
|
static void |
disableVendorDataSerialization()
Disable the serialization of vendor-specific data for objects of this class.
|
static void |
enableVendorDataDeserialization()
Enable the deserialization of vendor-specific data for objects of this class.
|
static void |
enableVendorDataSerialization()
Enable the serialization of vendor-specific data for objects of this class.
|
boolean |
equals(Object obj)
Compare this notification for equality with another object.
|
Throwable |
getCause()
Get the cause (if any) for this trace notification.
|
Level |
getLevel()
Deprecated.
Replaced with
getTraceLevel() as trace and alarm levels have
been split into different classes. |
Object |
getMessageSource()
Deprecated.
Replaced with
getNotificationSource() . |
String |
getMessageType()
Deprecated.
Replaced with
getTracerName() . |
NotificationSource |
getNotificationSource()
Get the object that identifies the component or subsystem in the SLEE
that caused this trace notification to be generated.
|
TraceLevel |
getTraceLevel()
Get the trace level of the trace message.
|
String |
getTracerName()
Get the name of the tracer to which the trace message was emitted.
|
Object |
getVendorData()
Get the vendor-specific data.
|
int |
hashCode()
Get a hash code value for this notification.
|
void |
setVendorData(Object vendorData)
Set the vendor-specific data.
|
String |
toString()
Get a string representation for this notification.
|
getMessage, getSequenceNumber, getTimeStamp, getType, getUserData, setSequenceNumber, setSource, setTimeStamp, setUserData
getSource
public TraceNotification(TraceMBean traceMBean, String messageType, Object messageSource, Level traceLevel, String message, Throwable cause, long sequenceNumber, long timestamp) throws NullPointerException, IllegalArgumentException
TraceNotification(String, TraceMBean, NotificationSource, String, javax.slee.facilities.TraceLevel, String, Throwable, long, long)
constructor should be used instead of this constructor.TraceNotification
to notify listeners of a trace message.traceMBean
- the TraceMBean
object that is emitting
this notification.messageType
- the type of the trace message being generated and
correspondingly the sub-type of the notification.messageSource
- a component identifier that identifies the component that
generated the trace message, for example an SbbID
.traceLevel
- the trace level.message
- the trace message.cause
- an optional cause for the trace message.sequenceNumber
- the notification sequence number within the source
TraceMBean
object.timestamp
- the time (in ms since January 1, 1970 UTC) that the trace message
was generated.NullPointerException
- if notificationSource
, messageType
,
traceLevel
, or message
is null
.IllegalArgumentException
- if traceLevel ==
Level.OFF
.public TraceNotification(String type, TraceMBean traceMBean, NotificationSource notificationSource, String tracerName, TraceLevel traceLevel, String message, Throwable cause, long sequenceNumber, long timestamp) throws NullPointerException, IllegalArgumentException
TraceNotification
to notify listeners of a trace message.type
- the JMX type of the notification. The type of the notification
is typically obtained from the NotificationSource
parameter when
this notification object is created, and can be used by notification listeners
to infer the type of the NotificationSource
and hence obtain
further information about the source of the notification.traceMBean
- the TraceMBean
object that is emitting this notification.notificationSource
- the component or subsystem in the SLEE that caused this
notification to be generated.tracerName
- the name of the tracer to which the trace message was emitted.traceLevel
- the trace level.message
- the trace message.cause
- an optional cause for the trace message.sequenceNumber
- the notification sequence number within the source TraceMBean
object.timestamp
- the time (in ms since January 1, 1970 UTC) that the trace message was emitted.NullPointerException
- if type
, traceMBean
,
notificationSource
, tracerName
, traceLevel
,
or message
is null
.IllegalArgumentException
- if traceLevel ==
TraceLevel.OFF
.public NotificationSource getNotificationSource()
null
for SLEE 1.0-compliant notifications.public String getMessageType()
getTracerName()
.getTracerName()
for SLEE 1.1-compliant notifications.public String getTracerName()
getMessageType()
for SLEE 1.0-compliant notifications.public Object getMessageSource()
getNotificationSource()
.getNotificationSource()
for SLEE 1.1-compliant notifications.public Level getLevel()
getTraceLevel()
as trace and alarm levels have
been split into different classes.Level
equivalent of the traceLevel
attribute for SLEE 1.1-compliant notifications.public TraceLevel getTraceLevel()
null
for SLEE 1.0-compliant notifications.public Throwable getCause()
null
if there wasn't a cause.public static void enableVendorDataSerialization()
By default, any vendor-specific data included in an object of this class will not be included in the serialization stream when the object is serialized. Invoking this method changes this behavior so that vendor-specific data is included in the serialization stream when an object of this class is serialized.
This method should only be invoked if the vendor-specific data is serializable via standard Java serialization means.
disableVendorDataSerialization()
,
setVendorData(java.lang.Object)
public static void disableVendorDataSerialization()
If the serialization of vendor-specific data for objects of this class has
been enabled via the enableVendorDataSerialization()
method, this
method disables that behavior again.
public static void enableVendorDataDeserialization()
By default, any vendor-specific data included in the serialization stream of objects of this class is discarded upon deserialization. Invoking this method changes that behavior so that the vendor-specific data is also deserialized when an object of this class is deserialized. A management client that enables the deserialization of vendor-specific data must ensure that any necessary classes required to deserialize that data is available in the relevant classloader.
disableVendorDataDeserialization()
,
getVendorData()
public static void disableVendorDataDeserialization()
If the deserialization of vendor-specific data for objects of this class has
been enabled via the enableVendorDataDeserialization()
method, this
method disables that behavior again.
public void setVendorData(Object vendorData)
setVendorData
in interface VendorExtensions
vendorData
- the vendor-specific data.public Object getVendorData()
getVendorData
in interface VendorExtensions
public boolean equals(Object obj)
For backwards compatibility, this method performs either a SLEE 1.0-based comparison or a SLEE 1.1-based comparison based on the state of this notification object. If this notification contains a non-null message source reference, a SLEE 1.0-based comparison is performed, using the SLEE 1.0 trace levels. Otherwise, a SLEE 1.1-based comparison is performed using the SLEE 1.1 trace levels.
The SLEE 1.0-based comparison considers two notifications to be equal if obj
is an instance of this class and the message type, message source, trace level and
message attributes of obj
are the same as the corresponding attributes of
this
.
The SLEE 1.1-based comparison considers two notifications to be equal if obj
if an instance of this class and the tracer name, notification source, trace level
and message attributes obj
are the same as the corresponding attributes
of this
.
Note that a SLEE 1.0-compliant trace notification can never be equal to a SLEE 1.1-compliant trace notification.
public int hashCode()
public String toString()
toString
in class Notification