Sun Identity Manager 8.1 システム管理者ガイド

エントリと終了トレースポイントの使用方法

使用するコードにエントリおよび終了トレースポイントを追加する前に、これらのガイドラインをお読みください。

次に、簡易エントリと終了トレース文の例を示します。この例では、次の CLASS 変数が各文に宣言されているものとします。

private static final String CLASS = 
"com.waveset.adapter.MyResourceAdapter"; 
protected static Trace _trace = Trace.getTrace();

例 5–1 エントリトレースポイントの一例

final String METHOD = methodName; 
_trace.entry(_trace.LEVEL1, CLASS, METHOD);
_trace.entry(_trace.LEVEL1, CLASS, METHOD, user);
if (_trace.level1(CLASS, METHOD)) {    
_trace.entry(_trace.ALWAYS, CLASS, METHOD,
user= + user); 
}

// Show the size of an array argument
// ASSUME: password is an argument to the method
// Note the use of the Util.length() method. It is
// a convenience method that guards against null.
if (_trace.level1(CLASS, METHOD)) {
    StringBuffer sb = new StringBuffer(32);
    sb.append(password length=);
    ab.append(Util.length(password));
    _trace.entry(_trace.ALWAYS, CLASS, METHOD, sb.toString());
}


例 5–2 エントリトレースポイントの一例

_trace.exit(_trace.LEVEL1, CLASS, METHOD);

_trace.exit(_trace.LEVEL1, CLASS, METHOD, returnValue);
if (_trace.level1(CLASS, METHOD)) {
    _trace.exit(_trace.ALWAYS, CLASS, METHOD,
      returnValue != null ? returnValue.getName() : returnValue);
}

// Show the size of an array 
String[] accounts = ... 
if (_trace.level1(CLASS, METHOD)) {    
    StringBuffer sb = new StringBuffer(32)
    sb.append(accounts length=);    
    ab.append(accounts.length);    
    _trace.exit(_trace.ALWAYS, CLASS, METHOD, sb.toString()); 
}