edu.mit.ai.psg.traveler
Class Trace

java.lang.Object
  |
  +--edu.mit.ai.psg.traveler.Trace

public class Trace
extends Object

Trace recording facility which creates a tree of nested ActivityRecords for each thread invoking traced methods, and a biography sequencing records of entrances into synchronized activities for each synchronized object. Trace provides a static parameter traceRecorder which holds a system TraceRecorder, and static methods for conveniently invoking methods of the trace recorder. For convenience, the the reflected Method or Constructor required for the invoking(java.lang.Object, java.lang.reflect.Member, java.lang.Object[]) method can be obtained using without a try block thru getMethod(java.lang.Class, java.lang.String, java.lang.Class[]) or getConstructor(java.lang.Class, java.lang.Class[]), respectively. (Based in part on "Traveler: the Apiary Observatory", ECOOP'1987).

See Also:
TraceRecorder

Field Summary
static TraceRecorder traceRecorder
          travelerTrace: the single instance through which static methods indirectly invoke their implementation methods.
 
Constructor Summary
protected Trace()
           
 
Method Summary
static void addEntryToBiography(SynchronizationRecord record)
           
static void addExitToBiography(SynchronizationRecord record)
           
static ActivityRecord beganSynchronization(Object target, Member inMember)
           
static ActivityRecord beginning(String description)
           
static void clearBiographies()
           
static void clearBiography(Object target)
           
static ActivityRecord doing(ActivityRecord record)
           
static ActivityRecord doing(String description)
           
static SynchronizationRecord enteredSynchronization(SynchronizationRecord record)
           
static ActivityRecord entering(ActivityRecord record)
           
static ActivityRecord exitting(ActivityRecord record)
           
static List getBiography(Object target)
           
static Constructor getConstructor(Class aClass, Class[] parameters)
          convenience method for calling aClass.getConstructor, reports NoSuchMethodException as an Error
static ActivityRecord getCurrentRecord()
           
static Method getMethod(Class aClass, String name, Class[] parameters)
          convenience method for getting method.
static SynchronizationRecord getSynchronizationHolder(Object target)
           
static ActivityRecord getThreadOutermostRecord()
           
static CallRecord invoking(Object target, Member member, Object[] parameters)
          For recording from caller before method is invoked.
static CallRecord invokingStatic(Member method, Object[] parameters)
          For recording from caller before static method is invoked.
static CallRecord received(Object target, Member member, Object[] params)
          For recording from callee, within method being traced.
static CallRecord receivedStatic(Member member, Object[] params)
          For recording from callee, within static method being traced.
static boolean returning(CallRecord record, boolean value)
          convenience method wrapping recorded value in Boolean
static byte returning(CallRecord record, byte value)
          convenience method wrapping recorded value in Byte
static char returning(CallRecord record, char value)
          convenience method wrapping recorded value in Character
static double returning(CallRecord record, double value)
          convenience method wrapping recorded value in Double
static float returning(CallRecord record, float value)
          convenience method wrapping recorded value in Float
static int returning(CallRecord record, int value)
          convenience method wrapping recorded value in Integer
static long returning(CallRecord record, long value)
          convenience method wrapping recorded value in Long
static Object returning(CallRecord record, Object value)
           
static short returning(CallRecord record, short value)
          convenience method wrapping recorded value in Short
static void returningVoid(CallRecord record)
           
static Throwable throwing(CallRecord record, Throwable thrown)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

traceRecorder

public static TraceRecorder traceRecorder
travelerTrace: the single instance through which static methods indirectly invoke their implementation methods. Allows implementations of these methods to be overridden in a subclass, yet programs can still invoke them through the static methods of this class. If overriding, initialize this with instance of subclass.
Constructor Detail

Trace

protected Trace()
Method Detail

received

public static CallRecord received(Object target,
                                  Member member,
                                  Object[] params)
For recording from callee, within method being traced. Should be followed by call to returning(edu.mit.ai.psg.traveler.CallRecord, java.lang.Object), returningVoid(edu.mit.ai.psg.traveler.CallRecord), or throwing(edu.mit.ai.psg.traveler.CallRecord, java.lang.Throwable) to record completion of call.
See Also:
TraceRecorder.received(java.lang.Object, java.lang.reflect.Member, java.lang.Object[])

receivedStatic

public static CallRecord receivedStatic(Member member,
                                        Object[] params)
For recording from callee, within static method being traced. Should be followed by call to returningVoid(edu.mit.ai.psg.traveler.CallRecord), returning(edu.mit.ai.psg.traveler.CallRecord, java.lang.Object), or throwing(edu.mit.ai.psg.traveler.CallRecord, java.lang.Throwable) to record completion of call.
See Also:
TraceRecorder.received(java.lang.Object, java.lang.reflect.Member, java.lang.Object[])

invoking

public static CallRecord invoking(Object target,
                                  Member member,
                                  Object[] parameters)
For recording from caller before method is invoked. Should be followed by call to returningVoid(edu.mit.ai.psg.traveler.CallRecord), returning(edu.mit.ai.psg.traveler.CallRecord, java.lang.Object), or throwing(edu.mit.ai.psg.traveler.CallRecord, java.lang.Throwable) to record completion of call.
See Also:
TraceRecorder.invoking(java.lang.Object, java.lang.reflect.Member, java.lang.Object[])

invokingStatic

public static CallRecord invokingStatic(Member method,
                                        Object[] parameters)
For recording from caller before static method is invoked. Should be followed by call to returningVoid(edu.mit.ai.psg.traveler.CallRecord), returning(edu.mit.ai.psg.traveler.CallRecord, java.lang.Object), or throwing(edu.mit.ai.psg.traveler.CallRecord, java.lang.Throwable) to record completion of call.
See Also:
TraceRecorder.invoking(java.lang.Object, java.lang.reflect.Member, java.lang.Object[])

throwing

public static Throwable throwing(CallRecord record,
                                 Throwable thrown)
See Also:
TraceRecorder.throwing(edu.mit.ai.psg.traveler.CallRecord, java.lang.Throwable)

returningVoid

public static void returningVoid(CallRecord record)
See Also:
TraceRecorder.returningVoid(edu.mit.ai.psg.traveler.CallRecord)

returning

public static Object returning(CallRecord record,
                               Object value)
See Also:
TraceRecorder.returning(edu.mit.ai.psg.traveler.CallRecord, java.lang.Object)

returning

public static boolean returning(CallRecord record,
                                boolean value)
convenience method wrapping recorded value in Boolean
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static byte returning(CallRecord record,
                             byte value)
convenience method wrapping recorded value in Byte
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static short returning(CallRecord record,
                              short value)
convenience method wrapping recorded value in Short
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static char returning(CallRecord record,
                             char value)
convenience method wrapping recorded value in Character
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static int returning(CallRecord record,
                            int value)
convenience method wrapping recorded value in Integer
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static long returning(CallRecord record,
                             long value)
convenience method wrapping recorded value in Long
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static float returning(CallRecord record,
                              float value)
convenience method wrapping recorded value in Float
See Also:
TraceRecorder.returning(CallRecord, Object)

returning

public static double returning(CallRecord record,
                               double value)
convenience method wrapping recorded value in Double
See Also:
TraceRecorder.returning(CallRecord, Object)

beginning

public static ActivityRecord beginning(String description)
See Also:
TraceRecorder.beginning(java.lang.String)

doing

public static ActivityRecord doing(String description)
See Also:
TraceRecorder.doing(java.lang.String)

beganSynchronization

public static ActivityRecord beganSynchronization(Object target,
                                                  Member inMember)
See Also:
TraceRecorder.beganSynchronization(java.lang.Object, java.lang.reflect.Member)

entering

public static ActivityRecord entering(ActivityRecord record)
See Also:
TraceRecorder.entering(edu.mit.ai.psg.traveler.ActivityRecord)

enteredSynchronization

public static SynchronizationRecord enteredSynchronization(SynchronizationRecord record)
See Also:
TraceRecorder.enteredSynchronization(edu.mit.ai.psg.traveler.SynchronizationRecord)

exitting

public static ActivityRecord exitting(ActivityRecord record)
See Also:
TraceRecorder.exitting(edu.mit.ai.psg.traveler.ActivityRecord)

doing

public static ActivityRecord doing(ActivityRecord record)
See Also:
TraceRecorder.doing(java.lang.String)

getCurrentRecord

public static ActivityRecord getCurrentRecord()
See Also:
TraceRecorder.getCurrentRecord()

getThreadOutermostRecord

public static ActivityRecord getThreadOutermostRecord()
See Also:
TraceRecorder.getThreadOutermostRecord()

clearBiographies

public static void clearBiographies()
See Also:
TraceRecorder.clearBiographies()

clearBiography

public static void clearBiography(Object target)
See Also:
TraceRecorder.clearBiography(java.lang.Object)

getBiography

public static List getBiography(Object target)
See Also:
TraceRecorder.getBiography(java.lang.Object)

getSynchronizationHolder

public static SynchronizationRecord getSynchronizationHolder(Object target)
See Also:
TraceRecorder.getSynchronizationHolder(java.lang.Object)

addEntryToBiography

public static void addEntryToBiography(SynchronizationRecord record)
See Also:
TraceRecorder.addEntryToBiography(edu.mit.ai.psg.traveler.SynchronizationRecord)

addExitToBiography

public static void addExitToBiography(SynchronizationRecord record)
See Also:
TraceRecorder.addExitToBiography(edu.mit.ai.psg.traveler.SynchronizationRecord)

getMethod

public static Method getMethod(Class aClass,
                               String name,
                               Class[] parameters)
convenience method for getting method. Searches class and superclasses with getDeclaredMethod
Throws:
Error - if not found

getConstructor

public static Constructor getConstructor(Class aClass,
                                         Class[] parameters)
convenience method for calling aClass.getConstructor, reports NoSuchMethodException as an Error

Copyright (c) 1996-1999
Massachusetts Institute of Technology

Feedback: jeva-feedback@ai.mit.edu