001: /*
002: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
003: * notice. All rights reserved.
004: */
005: package com.tc.object.config;
006:
007: import com.tc.asm.ClassVisitor;
008: import com.tc.aspectwerkz.reflect.ClassInfo;
009: import com.tc.aspectwerkz.reflect.FieldInfo;
010: import com.tc.aspectwerkz.reflect.MemberInfo;
011: import com.tc.aspectwerkz.reflect.MethodInfo;
012:
013: import com.tc.object.bytecode.ClassAdapterFactory;
014: import com.tc.object.bytecode.ManagerHelper;
015: import com.tc.object.bytecode.MethodAdapter;
016: import com.tc.object.bytecode.MethodCreator;
017: import com.tc.object.logging.InstrumentationLogger;
018:
019: /**
020: * Configure and describe the custom adaption of a class
021: */
022: public interface TransparencyClassSpec {
023:
024: public static final byte NOT_SET = 0x00;
025: public static final byte NOT_ADAPTABLE = 0x01;
026: public static final byte ADAPTABLE = 0x02;
027: public static final byte PORTABLE = 0x03;
028:
029: /**
030: * @param classInfo Class information
031: * @return True if physically instrumented and portable
032: */
033: public boolean hasPhysicallyPortableSpecs(ClassInfo classInfo);
034:
035: /**
036: * Add root field
037: * @param variableName Field name
038: * @param rootName Root name
039: * @return this
040: */
041: public TransparencyClassSpec addRoot(String variableName,
042: String rootName);
043:
044: /**
045: * Add root field
046: * @param variableName Field name
047: * @param rootName Root name
048: * @param dsoFinal True if final
049: * @return this
050: */
051: public TransparencyClassSpec addRoot(String variableName,
052: String rootName, boolean dsoFinal);
053:
054: /**
055: * Mark method as not instrumented
056: * @param methodName
057: */
058: public void addDoNotInstrument(String methodName);
059:
060: /**
061: * Check whether method is marked as do not instrument
062: * @param methodName Method name
063: * @return True if do not instrument
064: */
065: public boolean doNotInstrument(String methodName);
066:
067: /**
068: * Mark this class spec as being preinstrumented.
069: * @return this
070: */
071: public TransparencyClassSpec markPreInstrumented();
072:
073: /**
074: * Check whether this class is preinstrumented
075: * @return True if preinstrumented
076: */
077: public boolean isPreInstrumented();
078:
079: /**
080: * Get lock definitions for member
081: * @param memberInfo Member
082: * @return Locks
083: */
084: public LockDefinition[] lockDefinitionsFor(MemberInfo memberInfo);
085:
086: /**
087: * Get auto lock definition for member
088: * @param memberInfo Member
089: * @return Auto lock
090: */
091: public LockDefinition autoLockDefinitionFor(MethodInfo methodInfo);
092:
093: /**
094: * Examine lock definitions to find the the one that makes the method autolocked
095: * @param lds Lock defs
096: * @return null if no LockDefinitions exists that makes the method autolocked.
097: */
098: public LockDefinition getAutoLockDefinition(LockDefinition lds[]);
099:
100: /**
101: * Find lock definition that makes method not autolocked
102: * @param lds Lock defs
103: * @return Lock def or null if none
104: */
105: public LockDefinition getNonAutoLockDefinition(LockDefinition lds[]);
106:
107: /**
108: * Add support method creator
109: * @param creator Creator
110: * @return this
111: */
112: public TransparencyClassSpec addSupportMethodCreator(
113: MethodCreator creator);
114:
115: /**
116: * Add distributed method call
117: * @param methodName Method
118: * @param description Method signature
119: * @param runOnAllNodes True to run on all nodes, false for local
120: * @return this
121: */
122: public TransparencyClassSpec addDistributedMethodCall(
123: String methodName, String description, boolean runOnAllNodes);
124:
125: /**
126: * Add a transient field
127: * @param variableName Field name
128: * @return this
129: */
130: public TransparencyClassSpec addTransient(String variableName);
131:
132: /**
133: * Add method adapter
134: * @param method Method name
135: * @param adapter The adapter
136: * @return this
137: */
138: public TransparencyClassSpec addMethodAdapter(String method,
139: MethodAdapter adapter);
140:
141: /**
142: * Get the class name for this spec
143: * @return Name
144: */
145: public String getClassName();
146:
147: /**
148: * Call support method creators and add to the class via the visitor
149: * @param classVisitor Class visitor
150: */
151: public void createClassSupportMethods(ClassVisitor classVisitor);
152:
153: /**
154: * @return True if logical
155: */
156: public boolean isLogical();
157:
158: /**
159: * @return True if physical
160: */
161: public boolean isPhysical();
162:
163: /**
164: * @return True if checks should be ignored (only for special classes)
165: */
166: public boolean ignoreChecks();
167:
168: /**
169: * Check whether a field is a root in this class
170: * @param fieldInfo Field
171: * @return True if root
172: */
173: public boolean isRootInThisClass(FieldInfo fieldInfo);
174:
175: /**
176: * Check whether a field is a root in this class
177: * @param fieldInfo Field
178: * @return True if root
179: */
180: public boolean isRoot(FieldInfo fieldInfo);
181:
182: /**
183: * Check whether a field is a DSO final root
184: * @param fieldInfo Field
185: * @return True if DSO final root
186: */
187: public boolean isRootDSOFinal(FieldInfo fieldInfo);
188:
189: /**
190: * Check whether a field is transient
191: * @param access Access modifiers
192: * @param classInfo Class info
193: * @param fieldName Field name
194: * @return True if transient
195: */
196: public boolean isTransient(int access, ClassInfo classInfo,
197: String fieldName);
198:
199: /**
200: * Check whether a field is volatile
201: * @param access Access modifiers
202: * @param classInfo Class info
203: * @param fieldName Field name
204: * @return True if volatile
205: */
206: public boolean isVolatile(int access, ClassInfo classInfo,
207: String fieldName);
208:
209: /**
210: * @param fieldInfo Field
211: * @return Root name for field
212: */
213: public String rootNameFor(FieldInfo fieldInfo);
214:
215: /**
216: * Check whether this method is a locked method
217: * @param memberInfo Method
218: * @return True if locked
219: */
220: public boolean isLockMethod(MemberInfo memberInfo);
221:
222: /**
223: * Get lock definition for locked method
224: * @param access Access modifiers
225: * @param lds Lock defs
226: * @return Lock definition
227: */
228: public LockDefinition getLockMethodLockDefinition(int access,
229: LockDefinition lds[]);
230:
231: /**
232: * Check if has custom method adapter
233: * @param memberInfo Method
234: * @return True if has custom adapter
235: */
236: public boolean hasCustomMethodAdapter(MemberInfo memberInfo);
237:
238: /**
239: * Get custom method adapter
240: * @param managerHelper Manager helper
241: * @param access Access modifiers
242: * @param methodName Method name
243: * @param origMethodName Original method name
244: * @param description Method description
245: * @param signature Method signature
246: * @param exceptions Exceptions thrown
247: * @param logger Logger
248: * @param memberInfo Method
249: * @return Custom adapter
250: */
251: public MethodAdapter customMethodAdapterFor(
252: ManagerHelper managerHelper, int access, String methodName,
253: String origMethodName, String description,
254: String signature, String[] exceptions,
255: InstrumentationLogger logger, MemberInfo memberInfo);
256:
257: /**
258: * @return Change applicator specification
259: */
260: public ChangeApplicatorSpec getChangeApplicatorSpec();
261:
262: /**
263: * @return Logical class being extended
264: */
265: public String getLogicalExtendingClassName();
266:
267: /**
268: * Make this class extend a logically managed class
269: * @param superClassSpec The logically managed super class
270: */
271: public void moveToLogical(TransparencyClassSpec super ClassSpec);
272:
273: /**
274: * Add logical method adapter to always log access to method
275: * @param name Method signature
276: */
277: public void addAlwaysLogSpec(String name);
278:
279: /**
280: * Add logical method adapter to log if method returns true
281: * @param name Method signature
282: */
283: public void addIfTrueLogSpec(String name);
284:
285: /**
286: * Add logical method adapter to log calls to Set.iterator() impls
287: * @param name Method signature
288: */
289: public void addSetIteratorWrapperSpec(String name);
290:
291: /**
292: * Add logical method adapter to log calls to Set.subSet() on impls
293: * @param name Method signature
294: */
295: public void addViewSetWrapperSpec(String name);
296:
297: /**
298: * Add logical method adapter to log calls to Map.entrySet() on Map impls
299: * @param name Method signature
300: */
301: public void addEntrySetWrapperSpec(String name);
302:
303: /**
304: * Add logical method adapter to log calls to Map.keySet() on Map impls
305: * @param name Method signature
306: */
307: public void addKeySetWrapperSpec(String name);
308:
309: /**
310: * Add logical method adapter to log calls to Map.values() on Map impls
311: * @param name Method signature
312: */
313: public void addValuesWrapperSpec(String name);
314:
315: /**
316: * Add logical method adapter to log calls to Map.put() on Map impls
317: * @param name Method signature
318: */
319: public void addHashMapPutLogSpec(String name);
320:
321: /**
322: * Add logical method adapter to log calls to Hashtable.put()
323: * @param name Method signature
324: */
325: public void addHashtablePutLogSpec(String name);
326:
327: /**
328: * Add logical method adapter to log calls to THashMap.put()
329: * @param name Method signature
330: */
331: public void addTHashMapPutLogSpec(String name);
332:
333: /**
334: * Add logical method adapter to log calls to THashSet.add()
335: * @param name Method signature
336: */
337: public void addTHashSetAddLogSpec(String name);
338:
339: /**
340: * Add logical method adapter to log calls to THash.removeAt()
341: * @param name Method signature
342: */
343: public void addTHashRemoveAtLogSpec(String name);
344:
345: /**
346: * Add logical method adapter to log calls to THashSet.removeAt()
347: * @param name Method signature
348: */
349: public void addTHashSetRemoveAtLogSpec(String name);
350:
351: /**
352: * Add logical method adapter to log calls to Hashtable.clear()
353: * @param name Method signature
354: */
355: public void addHashtableClearLogSpec(String name);
356:
357: /**
358: * Add logical method adapter to log calls to Hashtable.remove()
359: * @param name Method signature
360: */
361: public void addHashtableRemoveLogSpec(String name);
362:
363: /**
364: * Add logical method adapter to log calls to HashMap.remove()
365: * @param name Method signature
366: */
367: public void addHashMapRemoveLogSpec(String name);
368:
369: /**
370: * Add logical method adapter to log calls to System.arraycopy()
371: * @param name Method signature
372: */
373: public void addArrayCopyMethodCodeSpec(String name);
374:
375: /**
376: * Add logical method adapter to disable wait/notify code
377: * @param name Method signature
378: */
379: public void disableWaitNotifyCodeSpec(String name);
380:
381: /**
382: * Add logical method adapter to log calls to Date.setTime()
383: * @param name Method signature
384: */
385: public void addDateMethodLogSpec(String name);
386:
387: /**
388: * Add logical method adapter to log calls to Date.setTime() in subclasses
389: * @param name Method signature
390: */
391: public void addDateMethodLogSpec(String name, int methodSpec);
392:
393: /**
394: * Add method code specification
395: * @param name Method name
396: * @param codeSpec Transparency spec
397: */
398: public void addMethodCodeSpec(String name,
399: TransparencyCodeSpec codeSpec);
400:
401: /**
402: * Set honor volatile flag
403: * @param b New flag value
404: * @return this
405: */
406: public TransparencyClassSpec setHonorVolatile(boolean b);
407:
408: /**
409: * @return True if is honor flag set
410: */
411: public boolean isHonorVolatileSet();
412:
413: /**
414: * @return Value of is honor flag
415: */
416: public boolean isHonorVolatile();
417:
418: /**
419: * Set honor transient flag
420: * @param b New flag value
421: * @return this
422: */
423: public TransparencyClassSpec setHonorTransient(boolean b);
424:
425: /**
426: * Set call constructor on load flag
427: * @param b New value
428: * @return this
429: */
430: public TransparencyClassSpec setCallConstructorOnLoad(boolean b);
431:
432: /**
433: * Set execute script on load flag
434: * @param script Script to load
435: * @return this
436: */
437: public TransparencyClassSpec setExecuteScriptOnLoad(String script);
438:
439: /**
440: * Set method to call on load
441: * @param method Method name
442: * @return this
443: */
444: public TransparencyClassSpec setCallMethodOnLoad(String method);
445:
446: /**
447: * @return True if call constructor flag is set
448: */
449: public boolean isCallConstructorSet();
450:
451: /**
452: * @return True if should honor transient
453: */
454: public boolean isHonorJavaTransient();
455:
456: /**
457: * @return Get value of call constructor on load flag
458: */
459: public boolean isCallConstructorOnLoad();
460:
461: /**
462: * @return True if is honor transient flag is set
463: */
464: public boolean isHonorTransientSet();
465:
466: /**
467: * Find code spec for method
468: * @param methodName Method name
469: * @param description Method signature
470: * @param isAutolock True if autolocked
471: * @return Transparency spec
472: */
473: public TransparencyCodeSpec getCodeSpec(String methodName,
474: String description, boolean isAutolock);
475:
476: /**
477: * @return True if execute script on load flag is set
478: */
479: public boolean isExecuteScriptOnLoadSet();
480:
481: /**
482: * @return True if call method on load flag is set
483: */
484: public boolean isCallMethodOnLoadSet();
485:
486: /**
487: * @return Get on load method to call
488: */
489: public String getOnLoadMethod();
490:
491: /**
492: * @return Get on load execute script to execute
493: */
494: public String getOnLoadExecuteScript();
495:
496: /**
497: * @return True if should use non-default constrcutor
498: */
499: public boolean isUseNonDefaultConstructor();
500:
501: /**
502: * Set to use non default constructor
503: * @param useNonDefaultConstructor True to use non-default
504: */
505: public void setUseNonDefaultConstructor(
506: boolean useNonDefaultConstructor);
507:
508: /**
509: * Set instrumentation action
510: * @param action Action constants defined in TransparencyClassSpecImpl
511: */
512: public void setInstrumentationAction(byte action);
513:
514: /**
515: * Get instrumentation action
516: * @return Action code ADAPTABLE, etc
517: */
518: public byte getInstrumentationAction();
519:
520: /**
521: * @return True if should honor JDK sub versions
522: */
523: public boolean isHonorJDKSubVersionSpecific();
524:
525: /**
526: * @param honorJDKSubVersionSpecific True to honor
527: */
528: public void setHonorJDKSubVersionSpecific(
529: boolean honorJDKSubVersionSpecific);
530:
531: /**
532: * Get method to call prior to create
533: * @return Method name
534: */
535: public String getPreCreateMethod();
536:
537: /**
538: * Get method to call post-create
539: * @return Method name
540: */
541: public String getPostCreateMethod();
542:
543: /**
544: * Set method to call pre-create
545: * @param preCreateMethod Method name
546: */
547: public void setPreCreateMethod(String preCreateMethod);
548:
549: /**
550: * Set method to call post-create
551: * @param postCreateMethod Method name
552: */
553: public void setPostCreateMethod(String postCreateMethod);
554:
555: /**
556: * Set custom class adapter factory
557: * @param customClassAdapter Custom factory
558: */
559: public void setCustomClassAdapter(
560: ClassAdapterFactory customClassAdapter);
561:
562: /**
563: * Get custom class adapter factory
564: * @return Adapter factory
565: */
566: public ClassAdapterFactory getCustomClassAdapter();
567:
568: /**
569: * @return Get name of change applicator class
570: */
571: public String getChangeApplicatorClassName();
572:
573: /**
574: * Get spec for super class
575: * @param superName Super class name
576: * @return Class spec for super class
577: */
578: public TransparencyClassSpec getClassSpec(String superName);
579:
580: }
|