KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tc > object > logging > InstrumentationLoggerImpl


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.logging;
5
6 import com.tc.logging.CustomerLogging;
7 import com.tc.logging.TCLogger;
8 import com.tc.object.config.LockDefinition;
9 import com.tc.object.config.schema.DSOInstrumentationLoggingOptions;
10
11 import java.util.Collection JavaDoc;
12 import java.util.Iterator JavaDoc;
13
14 public class InstrumentationLoggerImpl implements InstrumentationLogger {
15
16   private final DSOInstrumentationLoggingOptions opts;
17   private final TCLogger logger;
18
19   public InstrumentationLoggerImpl(DSOInstrumentationLoggingOptions opts) {
20     this.opts = opts;
21     this.logger = CustomerLogging.getDSOInstrumentationLogger();
22   }
23
24   public boolean classInclusion() {
25     return opts.logClass().getBoolean();
26   }
27
28   public boolean lockInsertion() {
29     return opts.logLocks().getBoolean();
30   }
31
32   public boolean transientRootWarning() {
33     return opts.logTransientRoot().getBoolean();
34   }
35
36   public boolean rootInsertion() {
37     return opts.logRoots().getBoolean();
38   }
39
40   public boolean distMethodCallInsertion() {
41     return opts.logDistributedMethods().getBoolean();
42   }
43
44   public void classIncluded(String JavaDoc className) {
45     logger.info(className + " included for instrumentation");
46   }
47
48   public void subclassOfLogicallyManagedClasses(String JavaDoc className, Collection JavaDoc logicalSuperClasses) {
49     StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
50     buffer.append(className).append(" is a subclass of a logically managed superclass : (");
51
52     for (Iterator JavaDoc i = logicalSuperClasses.iterator(); i.hasNext();) {
53       buffer.append(i.next());
54       if (i.hasNext()) {
55         buffer.append(',');
56       }
57     }
58
59     buffer.append("). This is currently not supported! Perhaps it has overridden a protected method.");
60     logger.warn(buffer.toString());
61
62   }
63
64   public void autolockInserted(String JavaDoc className, String JavaDoc methodName, String JavaDoc methodDesc, LockDefinition lockDefinition) {
65     String JavaDoc level = lockDefinition.getLockLevel().toString();
66     logger.info("Inserting autolocks in method " + className + "." + methodName + methodDesc + ", level: " + level);
67   }
68
69   public void lockInserted(String JavaDoc className, String JavaDoc methodName, String JavaDoc methodDesc, LockDefinition[] locks) {
70     StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
71
72     String JavaDoc s = locks.length > 1 ? "locks" : "lock";
73
74     sb.append("Inserting named ").append(s).append(" in ").append(className).append('.').append(methodName)
75         .append(methodDesc);
76     for (int i = 0; i < locks.length; i++) {
77       sb.append("\n\tname: ").append(locks[i].getLockName()).append(", level: ").append(locks[i].getLockLevel());
78     }
79
80     logger.info(sb.toString());
81   }
82
83   public void transientRootWarning(String JavaDoc className, String JavaDoc fieldName) {
84     logger.warn("The java transient property is being ignored for root:" + className + "." + fieldName);
85   }
86
87   public void rootInserted(String JavaDoc className, String JavaDoc fieldName, String JavaDoc desc, boolean isStatic) {
88     logger.info("DSO root inserted for field " + className + "." + fieldName + ", type " + (isStatic ? "static " : "")
89                 + desc);
90   }
91
92   public void distMethodCallInserted(String JavaDoc className, String JavaDoc methodName, String JavaDoc desc) {
93     logger.info("Adding distributed call: " + methodName + desc + " to class:" + className);
94   }
95
96 }
97
Popular Tags