001: /*
002: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
003: */
004: package com.tc.object.bytecode;
005:
006: import org.apache.commons.lang.ArrayUtils;
007:
008: import com.tc.asm.MethodVisitor;
009: import com.tc.logging.TCLogger;
010: import com.tc.object.config.LockDefinition;
011:
012: /**
013: * Logger class for PhysicalClassAdapter
014: */
015: public class PhysicalClassAdapterLogger {
016: private final TCLogger logger;
017:
018: PhysicalClassAdapterLogger(TCLogger l) {
019: this .logger = l;
020: }
021:
022: void logVisitMethodCreateLockMethod(String name) {
023: if (logger.isDebugEnabled())
024: logger.debug("Creating lock:" + name);
025: }
026:
027: void logVisitMethodNotALockMethod(final int access,
028: final String ownerClass, String name, final String desc,
029: final String[] exceptions) {
030: if (logger.isDebugEnabled())
031: logger.debug("visitMethod(): Not a lock method: " + access
032: + " " + ownerClass + "." + name + desc + " "
033: + arrayToString(exceptions));
034: }
035:
036: void logVisitMethodBegin(final int access, String name,
037: String signature, final String desc,
038: final String[] exceptions) {
039: if (logger.isDebugEnabled())
040: logger.debug("visitMethod(" + access + ", " + name + ", "
041: + desc + ", " + arrayToString(exceptions) + ", "
042: + signature + ")");
043: }
044:
045: void logVisitMethodIgnoring(String name, final String desc) {
046: if (logger.isDebugEnabled())
047: logger.debug("Ignoring:" + name + " desc:" + desc);
048: }
049:
050: void logVisitMethodCheckIsLockMethod() {
051: if (logger.isDebugEnabled())
052: logger.debug("Checking isLockMethod()");
053: }
054:
055: void logCallTCBeginWithLocksStart(int access, String name,
056: String desc, LockDefinition[] locks, MethodVisitor c) {
057: if (logger.isDebugEnabled()) {
058: logger.debug("callTCBeginWithLocks(access=" + access
059: + ", name=" + name + ", desc=" + desc + ", locks="
060: + arrayToString(locks) + ", c= " + c + ")");
061: }
062: }
063:
064: void logCallTCBeginWithLocksAutolock() {
065: if (logger.isDebugEnabled())
066: logger.debug("callTCBeginWithLocks(): lock is autolock.");
067: }
068:
069: void logCallTCBeginWithLocksAutolockSynchronized(String name,
070: String desc) {
071: if (logger.isDebugEnabled()) {
072: logger
073: .debug("callTCBeginWithLocks(): method is synchronized, calling __tcmonitorenter() for method "
074: + name + "." + desc);
075: }
076: }
077:
078: void logCallTCBeginWithLocksAutolockNotSynchronized(String name,
079: String desc) {
080: if (logger.isDebugEnabled()) {
081: logger
082: .debug("callTCBeginWithLocks(): method is not synchronized, ignoring autolock for method "
083: + name + "." + desc);
084: }
085: }
086:
087: void logCallTCBeginWithLocksNoAutolock(LockDefinition lock) {
088: if (logger.isDebugEnabled())
089: logger.debug("calling callTCBeginWithLock() for lock "
090: + lock);
091: }
092:
093: void logCreateLockMethodBegin(int access, String name,
094: String signature, String desc, final String[] exceptions,
095: LockDefinition[] locks) {
096: if (logger.isDebugEnabled())
097: logger.debug("createLockMethod(access=" + access
098: + ", name=" + name + ", desc=" + desc
099: + ", exceptions=" + arrayToString(exceptions)
100: + ", " + signature + ", " + arrayToString(locks)
101: + ")");
102: }
103:
104: void logCreateLockMethodVoidBegin(int access, String name,
105: String signature, String desc, final String[] exceptions,
106: LockDefinition[] locks) {
107: if (logger.isDebugEnabled()) {
108: logger.debug("createLockMethodVoid(access=" + access
109: + ", name=" + name + ", desc=" + desc
110: + ", exceptions=" + arrayToString(exceptions)
111: + ", sig=" + signature + ", locks="
112: + arrayToString(locks));
113: }
114: }
115:
116: void logCallTCCommitBegin(int access, String name, String desc,
117: LockDefinition[] locks, MethodVisitor c) {
118: if (logger.isDebugEnabled())
119: logger.debug("callTCCommit(access=" + access + ", name="
120: + name + ", desc=" + desc + ", locks="
121: + arrayToString(locks) + ", c=" + c + ")");
122: }
123:
124: void logCreateLockMethodReturnBegin(int access, String name,
125: String signature, String desc, final String[] exceptions,
126: LockDefinition[] locks) {
127: if (logger.isDebugEnabled())
128: logger.debug("createLockMethodReturn(access=" + access
129: + ", name=" + name + ", desc=" + desc
130: + ", exceptions=" + arrayToString(exceptions)
131: + ", signature=" + signature + ", locks="
132: + arrayToString(locks) + ")");
133: }
134:
135: private String arrayToString(Object obj) {
136: return obj == null ? "null" : ArrayUtils.toString(obj);
137: }
138: }
|