01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tc.object.config;
05:
06: import com.tc.aspectwerkz.reflect.ClassInfo;
07: import com.tc.object.config.schema.InstrumentedClass;
08:
09: final class InstrumentationDescriptorImpl implements
10: InstrumentationDescriptor {
11: private final InstrumentedClass classDescriptor;
12: private final ClassExpressionMatcher expressionMatcher;
13:
14: public InstrumentationDescriptorImpl(
15: InstrumentedClass classDescriptor,
16: ClassExpressionMatcher expressionMatcher) {
17: this .classDescriptor = classDescriptor;
18: this .expressionMatcher = expressionMatcher;
19: }
20:
21: public String getOnLoadMethodIfDefined() {
22: if (isExclude()) {
23: return null;
24: }
25: return classDescriptor.onLoad().isCallMethodOnLoadType() ? classDescriptor
26: .onLoad().getMethod()
27: : null;
28: }
29:
30: public String getOnLoadScriptIfDefined() {
31: if (isExclude()) {
32: return null;
33: }
34: return classDescriptor.onLoad().isExecuteScriptOnLoadType() ? classDescriptor
35: .onLoad().getExecuteScript()
36: : null;
37: }
38:
39: public boolean isCallConstructorOnLoad() {
40: return isExclude() ? false : classDescriptor.onLoad()
41: .isCallConstructorOnLoad();
42: }
43:
44: public boolean isHonorTransient() {
45: return isExclude() ? false : classDescriptor.honorTransient();
46: }
47:
48: public boolean isHonorVolatile() {
49: return isExclude() ? false : classDescriptor.honorVolatile();
50: }
51:
52: public boolean matches(ClassInfo classInfo) {
53: return expressionMatcher.match(classInfo);
54: }
55:
56: public boolean isInclude() {
57: return classDescriptor.isInclude();
58: }
59:
60: public boolean isExclude() {
61: return !isInclude();
62: }
63:
64: public String toString() {
65: return "InstrumentationDescriptorImpl["
66: + classDescriptor.classExpression() + "]";
67: }
68:
69: }
|