Websphere MQ Everyplace

com.ibm.mqe.trace
Class MQeTraceToBinaryMidp

java.lang.Object
  |
  +--com.ibm.mqe.trace.MQeTraceToBinary
        |
        +--com.ibm.mqe.trace.MQeTraceToBinaryMidp
All Implemented Interfaces:
MQeTraceHandler

public class MQeTraceToBinaryMidp
extends MQeTraceToBinary

A trace handler for MIDP devices.

Trace is stored as binary data either in an RMS store or in memory. This is decided when the handler in initialised in the following form:

MQeTraceHandler tracer = new MQeTraceToBinaryMidp(true); to use an RMS store

MQeTraceHandler tracer = new MQeTraceToBinaryMidp(false); to use memory

The function getData() can be used to retrieve the byte array that has so far been stored up.

Alternatively, sendDataToURL() will send the data to the default url as defined by DEFAULT_TRACE_URL.

An alternate location can be specified by calling sendDataToURL(url) instead.

If the application crashs while tracing, the static functions sendRMSDataToURL(url) or sendRMSDataToURL() (for the default url) can be used to send the data collected in the RecordStore to the specified url. Note that this will only work if the trace data is being stored in a RecordStore and not in memory.

MQeTraceServlet can be used to catch the data sent and is the default URL.

When sendDataToURL is called, the footer is automatically added to the data. This will not be present of the application crashes and the static method is used to send the data.

Once the adapter has been finished with, call stop() to ensure that the RecordStore is closed if it has been used during the tracing.

If using a record store, any trace left by a previous call will be cleared when a new instance is created, so calls to send the data must be made before closing the handler.

By default, trace will be send to examples.trace.MQeTraceServlet

Example of use:

|| Creates new midp trace handler that traces to memory

MQeTraceToBinaryMidp tracer = new MQeTraceToBinaryMidp(false);

|| Tells MQe to use this trace handler - from this point on, trace data will be collected by it

MQeTrace.setHandler(tracer);

... Some code to do stuff ...

|| Stop tracing

MQeTrace.setHandler(null);

|| Send collected data to DEFAULT_URL

tracer.sendDataToURL();


Field Summary
static java.lang.String DEFAULT_URL
          Default location to send trace to.
static short FOOTER_BECAUSE_OF_CLOSE
          Indicates that the end of the binary data was caused by a normal close.
 
Fields inherited from class com.ibm.mqe.trace.MQeTraceToBinary
UNICODE_CHARS_IN_MAX_LENGTH_STRING
 
Constructor Summary
MQeTraceToBinaryMidp(boolean traceToRMS)
          Constructor for MQeTraceToBinaryMidp.
 
Method Summary
 byte[] getData()
          Returns the trace data that has so far been collected.
 boolean sendDataToURL()
          Sends the collected trace output to the default URL.
 boolean sendDataToURL(java.lang.String url)
          Sends data to a specified location.
static boolean sendRMSDataToURL()
          Sends trace data that has been collected in a record store to the default url.
static boolean sendRMSDataToURL(java.lang.String url)
          Sends trace data that has been collected in a record store to a given url.
 void stop()
          If using a record store, this will close it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.mqe.MQeTraceHandler
setFilter, traceMessage, traceMessage, traceMessage, traceMessage, traceMessage
 

Field Detail

FOOTER_BECAUSE_OF_CLOSE

public static final short FOOTER_BECAUSE_OF_CLOSE
Indicates that the end of the binary data was caused by a normal close.

See Also:
Constant Field Values

DEFAULT_URL

public static final java.lang.String DEFAULT_URL
Default location to send trace to.

See Also:
Constant Field Values
Constructor Detail

MQeTraceToBinaryMidp

public MQeTraceToBinaryMidp(boolean traceToRMS)
Constructor for MQeTraceToBinaryMidp.

Parameters:
traceToRMS - Set to true for tracing to a record store, or false for tracing to memory.
Method Detail

stop

public void stop()
If using a record store, this will close it.

Returns:
void

getData

public byte[] getData()
Returns the trace data that has so far been collected.

Returns:
byte[]

sendDataToURL

public boolean sendDataToURL()
Sends the collected trace output to the default URL.

Returns:
boolean success

sendDataToURL

public boolean sendDataToURL(java.lang.String url)
Sends data to a specified location.

Parameters:
url - The location to send the data
Returns:
boolean success

sendRMSDataToURL

public static boolean sendRMSDataToURL()
Sends trace data that has been collected in a record store to the default url. This is useful if the application crashes in an unusual manner and breaks before the trace data could be sent.

Returns:
boolean success

sendRMSDataToURL

public static boolean sendRMSDataToURL(java.lang.String url)
Sends trace data that has been collected in a record store to a given url. This is useful if the application crashes in an unusual manner and breaks before the trace data could be sent.

Parameters:
url - The location to send the data
Returns:
boolean success

Websphere MQ Everyplace