KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > bytecode > PhysicalClassAdapterLogger


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package com.tc.object.bytecode;
5
6 import org.apache.commons.lang.ArrayUtils;
7
8 import com.tc.asm.MethodVisitor;
9 import com.tc.logging.TCLogger;
10 import com.tc.object.config.LockDefinition;
11
12 /**
13  * Logger class for PhysicalClassAdapter
14  */

15 public class PhysicalClassAdapterLogger {
16   private final TCLogger logger;
17
18   PhysicalClassAdapterLogger(TCLogger l) {
19     this.logger = l;
20   }
21
22   void logVisitMethodCreateLockMethod(String JavaDoc name) {
23     if (logger.isDebugEnabled()) logger.debug("Creating lock:" + name);
24   }
25
26   void logVisitMethodNotALockMethod(final int access, final String JavaDoc ownerClass, String JavaDoc name, final String JavaDoc desc,
27                                     final String JavaDoc[] exceptions) {
28     if (logger.isDebugEnabled()) logger.debug("visitMethod(): Not a lock method: " + access + " " + ownerClass + "."
29                                               + name + desc + " " + arrayToString(exceptions));
30   }
31
32   void logVisitMethodBegin(final int access, String JavaDoc name, String JavaDoc signature, final String JavaDoc desc, final String JavaDoc[] exceptions) {
33     if (logger.isDebugEnabled()) logger.debug("visitMethod(" + access + ", " + name + ", " + desc + ", "
34                                               + arrayToString(exceptions) + ", " + signature + ")");
35   }
36
37   void logVisitMethodIgnoring(String JavaDoc name, final String JavaDoc desc) {
38     if (logger.isDebugEnabled()) logger.debug("Ignoring:" + name + " desc:" + desc);
39   }
40
41   void logVisitMethodCheckIsLockMethod() {
42     if (logger.isDebugEnabled()) logger.debug("Checking isLockMethod()");
43   }
44
45   void logCallTCBeginWithLocksStart(int access, String JavaDoc name, String JavaDoc desc, LockDefinition[] locks, MethodVisitor c) {
46     if (logger.isDebugEnabled()) {
47       logger.debug("callTCBeginWithLocks(access=" + access + ", name=" + name + ", desc=" + desc + ", locks="
48                    + arrayToString(locks) + ", c= " + c + ")");
49     }
50   }
51
52   void logCallTCBeginWithLocksAutolock() {
53     if (logger.isDebugEnabled()) logger.debug("callTCBeginWithLocks(): lock is autolock.");
54   }
55
56   void logCallTCBeginWithLocksAutolockSynchronized(String JavaDoc name, String JavaDoc desc) {
57     if (logger.isDebugEnabled()) {
58       logger.debug("callTCBeginWithLocks(): method is synchronized, calling __tcmonitorenter() for method " + name
59                    + "." + desc);
60     }
61   }
62
63   void logCallTCBeginWithLocksAutolockNotSynchronized(String JavaDoc name, String JavaDoc desc) {
64     if (logger.isDebugEnabled()) {
65       logger.debug("callTCBeginWithLocks(): method is not synchronized, ignoring autolock for method " + name + "."
66                    + desc);
67     }
68   }
69
70   void logCallTCBeginWithLocksNoAutolock(LockDefinition lock) {
71     if (logger.isDebugEnabled()) logger.debug("calling callTCBeginWithLock() for lock " + lock);
72   }
73
74   void logCreateLockMethodBegin(int access, String JavaDoc name, String JavaDoc signature, String JavaDoc desc, final String JavaDoc[] exceptions,
75                                 LockDefinition[] locks) {
76     if (logger.isDebugEnabled()) logger.debug("createLockMethod(access=" + access + ", name=" + name + ", desc=" + desc
77                                               + ", exceptions=" + arrayToString(exceptions) + ", " + signature + ", "
78                                               + arrayToString(locks) + ")");
79   }
80
81   void logCreateLockMethodVoidBegin(int access, String JavaDoc name, String JavaDoc signature, String JavaDoc desc, final String JavaDoc[] exceptions,
82                                     LockDefinition[] locks) {
83     if (logger.isDebugEnabled()) {
84       logger.debug("createLockMethodVoid(access=" + access + ", name=" + name + ", desc=" + desc + ", exceptions="
85                    + arrayToString(exceptions) + ", sig=" + signature + ", locks=" + arrayToString(locks));
86     }
87   }
88
89   void logCallTCCommitBegin(int access, String JavaDoc name, String JavaDoc desc, LockDefinition[] locks, MethodVisitor c) {
90     if (logger.isDebugEnabled()) logger.debug("callTCCommit(access=" + access + ", name=" + name + ", desc=" + desc
91                                               + ", locks=" + arrayToString(locks) + ", c=" + c + ")");
92   }
93
94   void logCreateLockMethodReturnBegin(int access, String JavaDoc name, String JavaDoc signature, String JavaDoc desc,
95                                       final String JavaDoc[] exceptions, LockDefinition[] locks) {
96     if (logger.isDebugEnabled()) logger.debug("createLockMethodReturn(access=" + access + ", name=" + name + ", desc="
97                                               + desc + ", exceptions=" + arrayToString(exceptions) + ", signature="
98                                               + signature + ", locks=" + arrayToString(locks) + ")");
99   }
100
101   private String JavaDoc arrayToString(Object JavaDoc obj) {
102     return obj == null ? "null" : ArrayUtils.toString(obj);
103   }
104 }
Popular Tags