01: /**
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright
03: * notice. All rights reserved.
04: */package org.terracotta.modules;
05:
06: import org.osgi.framework.BundleContext;
07: import org.terracotta.modules.configuration.TerracottaConfiguratorModule;
08:
09: import com.tc.object.config.TransparencyClassSpec;
10: import com.tc.util.runtime.Vm;
11:
12: public class Jdk15PreInstrumentedConfiguration extends
13: TerracottaConfiguratorModule {
14:
15: protected void addInstrumentation(final BundleContext context) {
16: super .addInstrumentation(context);
17: addJDK15PreInstrumentedSpec();
18: }
19:
20: private void addJDK15PreInstrumentedSpec() {
21: if (Vm.getMegaVersion() >= 1 && Vm.getMajorVersion() > 4) {
22: getOrCreateSpec("java.util.concurrent.CyclicBarrier");
23: TransparencyClassSpec spec = getOrCreateSpec("java.util.concurrent.CyclicBarrier$Generation");
24: spec.setHonorJDKSubVersionSpecific(true);
25: getOrCreateSpec("java.util.concurrent.TimeUnit");
26:
27: // ---------------------------------------------------------------------
28: // The following section of specs are specified in the BootJarTool
29: // also.
30: // They are placed again so that the honorTransient flag will
31: // be honored during runtime.
32: // ---------------------------------------------------------------------
33:
34: // ---------------------------------------------------------------------
35: // SECTION BEGINS
36: // ---------------------------------------------------------------------
37:
38: spec = getOrCreateSpec("java.util.concurrent.locks.ReentrantLock");
39: spec.setHonorTransient(true);
40: spec.setCallConstructorOnLoad(true);
41:
42: // addJavaUtilConcurrentHashMapSpec();
43: // addLogicalAdaptedLinkedBlockingQueueSpec();
44: addJavaUtilConcurrentFutureTaskSpec();
45:
46: // ---------------------------------------------------------------------
47: // SECTION ENDS
48: // ---------------------------------------------------------------------
49: }
50: }
51:
52: private void addJavaUtilConcurrentFutureTaskSpec() {
53: TransparencyClassSpec spec = getOrCreateSpec("java.util.concurrent.FutureTask$Sync");
54: configHelper
55: .addWriteAutolock("* java.util.concurrent.FutureTask$Sync.*(..)");
56: spec.setHonorTransient(true);
57: spec.addDistributedMethodCall("managedInnerCancel", "()V",
58: false);
59: getOrCreateSpec("java.util.concurrent.FutureTask");
60: getOrCreateSpec("java.util.concurrent.Executors$RunnableAdapter");
61: }
62: }
|