public abstract class MSink extends MBaseComponent
MSink
abstract class defines locations that can receive
messages from an MTrace
. These locations can be files,
TIBCO Rendezvous sessions, or other user-defined location.
The TIBCO Adapter SDK provides a few subclasses of MSink
:
MFileSink
, MRvSink
, MHawkSink
, MStdoutSink
, and MStderrSink
. Applications
can extend the list of available sinks by implementing other subclasses,
for example a DbSink
class.
To implement tracing, an application maps a trace to a sink by calling MTrace.addMapping(java.lang.String roleName, com.tibco.sdk.tools.MSink sink)
.
Once the mapping has been created, messages sent to the MTrace
object via its trace()
method are automatically logged into the specified file (MFileSink
) or sent as
a TIBCO Rendezvous message (MRvSink
).
m_registry
Modifier | Constructor and Description |
---|---|
protected |
MSink(MComponentRegistry reg,
java.lang.String name)
Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
closeSink()
If applicable, flushes data to this sink and closes it so it is no longer available for writing.
|
void |
flushSink()
If applicable, flush the sink.
|
java.lang.String |
toString() |
void |
write(MTree tree)
Serialize the specified MTree object to this sink
|
void |
write(MTree tree,
boolean flushNow)
Write and flush all data, if so desired
|
void |
write(java.lang.String msg)
Write the specified string message to this sink
|
abstract void |
write(java.lang.String msg,
boolean flushNow)
Writes the specified data to this
MSink . |
void |
write(java.lang.String msgPrefix,
MTree tree)
Serialize the specified MTree object to this sink
|
abstract void |
write(java.lang.String msgPrefix,
MTree tree,
boolean flushNow)
Write the specified data to this sink.
|
activate, deactivate, getComponentRegistry, getName, getStatus, isActivated, remove
protected MSink(MComponentRegistry reg, java.lang.String name)
public void write(java.lang.String msg)
public void write(java.lang.String msgPrefix, MTree tree)
public void write(MTree tree)
public abstract void write(java.lang.String msg, boolean flushNow)
MSink
.
This method writes the specified string message to this sink
and flushes all data if flushNow
is true
.
msg
- Message to send to this sink.flushNow
- If flushNow
is true
,
flush all data from this sink. If false
, add data to this sink.public abstract void write(java.lang.String msgPrefix, MTree tree, boolean flushNow)
This method adds a prefix to the data sent out.
msgPrefix
- A string you want to prepend to the message, for example your application name.tree
- MTree
to serialize and send to this sink.flushNow
- If flushNow
is true
,
flush all data from this sink. If false
, add data to this sink.public void write(MTree tree, boolean flushNow)
public void closeSink()
flushSink()
public void flushSink()
Flush data to the sink destination. Data to be written to a file are actually collected by the operating system and written out in batches when the cache reaches a certain limit. The file sink is the only predefined sink type where this method actually has an effect. Applications can call this method to force the data to the file system right away.
closeSink()
public java.lang.String toString()
toString
in class java.lang.Object