|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ca.idms.io.TraceObject
public class TraceObject
This serves as a general base class and provides some basic debugging routines to print trace information and display the contents of class variables.
Static trace methods are no longer supported as of Server 5.0, in order to enable tracing to separate log writers for each JDBC data source.
Field Summary | |
---|---|
protected static java.lang.Class<?>[] |
exclude
Trace all but these classes if not null. |
static java.lang.String |
EXCLUDE
Property name to exclude the specified classes from the trace. |
static java.lang.String |
FALSE
|
protected static java.lang.Class<?>[] |
include
Trace only these classes if not null. |
static java.lang.String |
INCLUDE
Property name to include only the specified classes in the the trace. |
protected TraceOutput |
logWriter
Instance specific log writer. |
static java.lang.String |
PREFIX
System property name prefix. |
static java.lang.String |
PROPERTIES_FILE
Default CA IDMS properties file name. |
static java.lang.String |
PROPERTIES_KEY
System properties key name to specify the CA IDMS properties file. |
static boolean |
snap
Can be used as a general snap option. |
static java.lang.String |
SNAP
The "snap" property can be used as a general snap option. |
static java.lang.String |
SNAP_BYTES
The "snap.bytes" property can be use to snap buffers in the trace. |
static java.lang.String |
SNAP_NATIVE
The "snap.native" property can be used to trace display write native data buffers in the trace as it is read or written. |
static java.lang.String |
SNAP_OBJECT
The "snap.object" property can be use to display object fields in the trace. |
static java.lang.String |
SNAP_SQL
The "snap.sql" property can be use to display SQL control blocks, SQL syntax and buffers in the trace. |
static boolean |
snapBytes
Enables display of byte array data in trace stream. |
static boolean |
snapNative
Enables display of objects read and written by readNative and writeNative methods. |
static boolean |
snapObject
Enables formatted display of objects in trace stream. |
static boolean |
snapSql
Enables formatted display of SQL objects in trace stream. |
static boolean |
stub
Enables calls to stub routines for local testing. |
static boolean |
trace
Global trace option flag. |
static java.lang.String |
TRACE
The property name to enable global tracing is "trace". |
static java.lang.String |
TRACE_FILE
The "trace.file" property can be used to specify the global trace file. |
static java.lang.String |
TRACE_LIFE
The "trace.life" property can be used to trace when an object is created and finalized. |
static java.lang.String |
TRACE_NATIVE
The "trace.native" property can be used to trace when native data is read or written. |
static java.lang.String |
TRACE_PRODUCT
The "trace.product" property can be used to set a product name in the trace. |
static boolean |
traceLife
Enables printing of trace messages when a TraceObject is initialized and finalized. |
static boolean |
traceNative
Enables printing of readNative and writeNative trace messages. |
static TraceOutput |
traceStream
Global trace output stream. |
static java.lang.String |
TRUE
|
Constructor Summary | |
---|---|
TraceObject()
The 0 argument constructor sets the log and traces object creation. |
Method Summary | |
---|---|
protected void |
finalize()
The finalizer traces object destruction. |
protected java.lang.Object |
get(java.lang.reflect.Field f)
Provides a default get(Field) method that will attempt to retrieve the value of a declared variable of the class, and will work for the public variables variables of a derived class. |
static boolean |
getBoolean(java.lang.String key,
boolean val)
Gets a boolean value from the System or CA IDMS properties. |
protected static java.lang.Class<?>[] |
getClasses(java.util.Vector<java.lang.String> v)
Gets classes to be included or excluded from trace. |
static int |
getInteger(java.lang.String key,
int val)
Gets a integer value from the System or CA IDMS properties. |
static java.lang.String |
getProperty(java.lang.String key,
java.lang.String val)
Gets a string value from the System or CA IDMS properties. |
static void |
listProperties(java.io.PrintStream out)
Lists CA IDMS properties, loading them if necessary. |
void |
message(java.lang.String s)
Writes a message to the trace file. |
static java.util.Vector<java.lang.String> |
parseList(java.lang.String s)
Parses a list of arguments. |
protected void |
print(char c)
Appends a character to the trace line buffer. |
protected void |
print(java.lang.Object o)
Appends an object's value to the trace line buffer. |
protected void |
print(java.lang.String s)
Appends a string to the trace line buffer. |
protected void |
println(java.lang.Object o)
Writes the value of object to the trace stream. |
protected void |
println(java.lang.String s)
Writes a line to the trace stream and log writer. |
void |
snap()
Displays object member variables. |
void |
snap(java.lang.Object o,
byte[] b)
Displays a byte array in memory dump format. |
void |
snap(java.lang.Object o,
byte[] b,
int l)
Displays a byte array in memory dump format. |
void |
snap(java.lang.String t,
byte[] b)
Displays a byte array in memory dump format. |
void |
snap(java.lang.String t,
byte[] b,
int l)
Displays a byte array in memory dump format. |
void |
snap(java.lang.String t,
byte[] b,
int s,
int l)
Displays a byte array in memory dump format. |
void |
snap(java.lang.String t,
java.lang.String s)
Displays a "long" String. |
static java.lang.String |
toHex(byte v)
Converts a byte to a hex string. |
static java.lang.String |
toHex(byte[] v)
Converts a byte array to a hex string. |
static java.lang.String |
toHex(int v)
Converts an int to a hex string. |
static java.lang.String |
toHex(long v)
Converts a long to a hex string. |
static java.lang.String |
toHex(short v)
Converts a short to a hex string. |
static java.lang.String |
toString(java.lang.Object o)
Gets the string repesentation of an object. |
boolean |
trace()
Checks if tracing is enabled. |
boolean |
trace(boolean f)
Checks if tracing is enabled. |
void |
trace(java.lang.Object o,
java.lang.String s)
Writes a line to the trace file. |
void |
trace(java.lang.String s)
Writes a line to the trace file. |
static boolean |
trace(TraceObject t)
Checks if tracing is enabled. |
static boolean |
trace(TraceObject t,
boolean f)
Checks if tracing is enabled. |
boolean |
traceEntry()
Checks if trace enabled and sets the log writer for the current thread. |
protected static void |
unloadProperties()
Clears the IDMS properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTIES_FILE
public static final java.lang.String PROPERTIES_KEY
public static final java.lang.String PREFIX
IDMS properties file
, but can also be specified as system properties
when prefixed with "ca.idms.".
Note that this has changed from "ca.jdbc." in Server 5.0,
to avoid any possible collisions with other CA products.
public static final java.lang.String TRACE
PREFIX
,
getProperty(String, String)
,
Constant Field Valuespublic static final java.lang.String TRACE_FILE
public static final java.lang.String TRACE_PRODUCT
public static final java.lang.String TRACE_LIFE
public static final java.lang.String TRACE_NATIVE
public static final java.lang.String SNAP_NATIVE
public static final java.lang.String SNAP
public static final java.lang.String SNAP_BYTES
public static final java.lang.String SNAP_OBJECT
public static final java.lang.String SNAP_SQL
public static final java.lang.String INCLUDE
public static final java.lang.String EXCLUDE
public static final java.lang.String TRUE
public static final java.lang.String FALSE
public static boolean trace
traceStream
. The global trace is independent of any
JDBC log writer
that might be set.
Classes should generally use the trace()
method to determine
if tracing is enabled to either the global trace or a log writer to
avoid the overhead of building trace message when disabled.
TRACE
public static boolean traceLife
TRACE_LIFE
public static boolean traceNative
TRACE_NATIVE
,
Native
public static boolean snap
SNAP
public static boolean snapNative
SNAP_NATIVE
,
snap(String,byte[],int,int)
,
Native
public static boolean snapBytes
SNAP_BYTES
,
snap(String,byte[],int,int)
public static boolean snapObject
SNAP_OBJECT
,
snap()
public static boolean snapSql
SNAP_SQL
,
snap()
public static boolean stub
protected static java.lang.Class<?>[] include
INCLUDE
protected static java.lang.Class<?>[] exclude
EXCLUDE
public static TraceOutput traceStream
JDBC log writer
that might be set.
By default trace information is written to System.out.
The IDMS JDBC Driver and JDBC Server override this and set the trace stream to use the native trace methods on platforms where they are available. This allows Java trace information to be integrated with the native client interface tracing.
On platforms where the native methods are not supported the
TRACE_FILE
property can be used to specify a trace file name.
If this file cannot be opened for any reason the standard output
will be used.
TraceOutput
,
TraceStream
protected TraceOutput logWriter
It is independent of the traceStream
and is used to
print messages to the log writer specified by the JDBC DriverManager
or DataSource or equivalent class.
Constructor Detail |
---|
public TraceObject()
Method Detail |
---|
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- not reallypublic static boolean getBoolean(java.lang.String key, boolean val)
key
- the name of the property.val
- the default value of the property.
getProperty(String, String)
public static int getInteger(java.lang.String key, int val)
key
- the name of the property.val
- the default value of the property.
getProperty(String, String)
public static java.lang.String getProperty(java.lang.String key, java.lang.String val)
PREFIX
and
searches the System properties for the value. It then uses
the original key to search the CA IDMS properties. The last
value found is returned.
key
- the name of the property.val
- the default value of the property.
public static final void listProperties(java.io.PrintStream out)
out
- the output print streamprotected static void unloadProperties()
public boolean traceEntry()
constructor
sets logWriter
to the value in effect for the
current thread.
This method should be invoked on entry by every public method exposed to the application to check if tracing is enabled and ensure that the connection specific log writer, if any, is set in the ThreadLocal variable for the current thread.
For example, the IDMS JDBC Driver uses this to support a separate log writer for each DataSource, and invokes this method first in every public method that can cause a TraceObject to be created.
Note: This method must be invoked every time the thread could change. Multi-threaded applications are responsible for ensuring that this is set correctly before creating any objects derived from this class.
public static final boolean trace(TraceObject t)
trace option
and the instance specific
logWriter
in the specified trace object.
If t == null
only the global flag is checked.
t
- trace object to test or null
trace()
public static final boolean trace(TraceObject t, boolean f)
f && TraceObject.trace(t)
t
- trace object to test or nullf
- additional trace flag
trace()
public final boolean trace()
trace flag
and the instance specific
logWriter
in this object.
public final boolean trace(boolean f)
f && trace()
f
- additional trace flag
protected static java.lang.Class<?>[] getClasses(java.util.Vector<java.lang.String> v)
v
- vector containing class names
public static java.util.Vector<java.lang.String> parseList(java.lang.String s)
s
- comma delimited argument string
public void message(java.lang.String s)
s
- String to write.public void trace(java.lang.Object o, java.lang.String s)
o
- the that will be identified in the traces
- String to write.trace(String)
,
include
,
exclude
public void trace(java.lang.String s)
The caller of this method can check the trace flags to selectively trace information. This method does not check these flags, however it does check the include and exclude Class arrays.
trace
in interface Trace
s
- String to write.trace()
,
include
,
exclude
public void snap(java.lang.Object o, byte[] b)
o
- the object for the title.b
- the array to snap.public void snap(java.lang.Object o, byte[] b, int l)
o
- the object for the title.b
- the array to snap.l
- length to snap.public void snap(java.lang.String t, byte[] b)
t
- title for array in trace streamb
- the array to snap.public void snap(java.lang.String t, byte[] b, int l)
t
- title for array in trace streamb
- the array to snap.l
- length to snap.public void snap(java.lang.String t, byte[] b, int s, int l)
t
- title for array in trace streamb
- the array to snap.s
- start offset.l
- length to snap, -1 means use b,length.snap(String,byte[],int)
,
snap(String,byte[])
,
snap(Object,byte[],int)
,
snap(Object,byte[])
public void snap(java.lang.String t, java.lang.String s)
t
- title for string in trace streams
- the string to snap.protected java.lang.Object get(java.lang.reflect.Field f) throws java.lang.IllegalAccessException
f
- a Field returned by GetDeclaredFields()
java.lang.IllegalAccessException
- if the variable is
not declared as public in the derived classsnap
,
snap()
public void snap()
get(java.lang.reflect.Field)
, this method will also display the values of private,
protected, and package variables.
This method checks the include and exclude Class arrays.
snap
in interface Trace
get(java.lang.reflect.Field)
protected void print(char c)
c
- character to print.print(String)
,
println(String)
protected void print(java.lang.Object o)
o
- object to print.print(String)
,
println(String)
protected void print(java.lang.String s)
s
- partial line String.println(String)
protected void println(java.lang.Object o)
o
- Object to write.println(String)
protected void println(java.lang.String s)
Note that the calling object is responsible for ensuring that output from other threads does not get mixed up in the trace output.
s
- String to write.public static java.lang.String toHex(byte v)
v
- byte to convert.
public static java.lang.String toHex(byte[] v)
v
- byte array to convert.
public static java.lang.String toHex(short v)
v
- short to convert
public static java.lang.String toHex(int v)
v
- int to convert
public static java.lang.String toHex(long v)
v
- long to convert
public static java.lang.String toString(java.lang.Object o)
o
- the object.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |