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: */package org.terracotta.modules;
005:
006: import org.osgi.framework.BundleContext;
007: import org.terracotta.modules.configuration.TerracottaConfiguratorModule;
008:
009: import com.tc.object.config.ConfigLockLevel;
010: import com.tc.object.config.LockDefinition;
011: import com.tc.object.config.TransparencyClassSpec;
012: import com.tc.util.runtime.Vm;
013:
014: public class GUIModelsConfiguration extends
015: TerracottaConfiguratorModule {
016:
017: protected void addInstrumentation(final BundleContext context) {
018: super .addInstrumentation(context);
019: configAWTModels();
020: configSwingModels();
021: }
022:
023: private void configAWTModels() {
024: // Color
025: configHelper.addIncludePattern("java.awt.Color", true);
026: TransparencyClassSpec spec = getOrCreateSpec("java.awt.Color");
027: spec.addTransient("cs");
028:
029: // MouseMotionAdapter, MouseAdapter
030: getOrCreateSpec("java.awt.event.MouseMotionAdapter");
031: getOrCreateSpec("java.awt.event.MouseAdapter");
032:
033: // Point
034: getOrCreateSpec("java.awt.Point");
035: getOrCreateSpec("java.awt.geom.Point2D");
036: getOrCreateSpec("java.awt.geom.Point2D$Double");
037: getOrCreateSpec("java.awt.geom.Point2D$Float");
038:
039: // Line
040: getOrCreateSpec("java.awt.geom.Line2D");
041: getOrCreateSpec("java.awt.geom.Line2D$Double");
042: getOrCreateSpec("java.awt.geom.Line2D$Float");
043:
044: // Rectangle
045: getOrCreateSpec("java.awt.Rectangle");
046: getOrCreateSpec("java.awt.geom.Rectangle2D");
047: getOrCreateSpec("java.awt.geom.RectangularShape");
048: getOrCreateSpec("java.awt.geom.Rectangle2D$Double");
049: getOrCreateSpec("java.awt.geom.Rectangle2D$Float");
050: getOrCreateSpec("java.awt.geom.RoundRectangle2D");
051: getOrCreateSpec("java.awt.geom.RoundRectangle2D$Double");
052: getOrCreateSpec("java.awt.geom.RoundRectangle2D$Float");
053:
054: // Ellipse2D
055: getOrCreateSpec("java.awt.geom.Ellipse2D");
056: getOrCreateSpec("java.awt.geom.Ellipse2D$Double");
057: getOrCreateSpec("java.awt.geom.Ellipse2D$Float");
058:
059: // java.awt.geom.Path2D
060: if (Vm.isJDK16Compliant()) {
061: getOrCreateSpec("java.awt.geom.Path2D");
062: getOrCreateSpec("java.awt.geom.Path2D$Double");
063: getOrCreateSpec("java.awt.geom.Path2D$Float");
064: }
065:
066: // GeneralPath
067: getOrCreateSpec("java.awt.geom.GeneralPath");
068: //
069: // BasicStroke
070: getOrCreateSpec("java.awt.BasicStroke");
071:
072: // Dimension
073: getOrCreateSpec("java.awt.Dimension");
074: getOrCreateSpec("java.awt.geom.Dimension2D");
075: }
076:
077: private void configSwingModels() {
078: // TableModelEvent
079: configHelper.addIncludePattern(
080: "javax.swing.event.TableModelEvent", true);
081: getOrCreateSpec("javax.swing.event.TableModelEvent");
082:
083: // AbstractTableModel
084: configHelper.addIncludePattern(
085: "javax.swing.table.AbstractTableModel", true);
086: TransparencyClassSpec spec = getOrCreateSpec("javax.swing.table.AbstractTableModel");
087: spec.addDistributedMethodCall("fireTableChanged",
088: "(Ljavax/swing/event/TableModelEvent;)V", false);
089: spec.addTransient("listenerList");
090:
091: // DefaultTableModel
092: spec = getOrCreateSpec("javax.swing.table.DefaultTableModel");
093: spec.setCallConstructorOnLoad(true);
094: LockDefinition ld = configHelper.createLockDefinition(
095: "tcdefaultTableLock", ConfigLockLevel.WRITE);
096: ld.commit();
097: addLock("* javax.swing.table.DefaultTableModel.set*(..)", ld);
098: addLock("* javax.swing.table.DefaultTableModel.insert*(..)", ld);
099: addLock("* javax.swing.table.DefaultTableModel.move*(..)", ld);
100: addLock("* javax.swing.table.DefaultTableModel.remove*(..)", ld);
101: ld = configHelper.createLockDefinition("tcdefaultTableLock",
102: ConfigLockLevel.READ);
103: ld.commit();
104: addLock("* javax.swing.table.DefaultTableModel.get*(..)", ld);
105:
106: // DefaultListModel
107: spec = getOrCreateSpec("javax.swing.DefaultListModel");
108: spec.setCallConstructorOnLoad(true);
109: ld = configHelper.createLockDefinition("tcdefaultListLock",
110: ConfigLockLevel.WRITE);
111: ld.commit();
112: addLock("* javax.swing.DefaultListModel.*(..)", ld);
113:
114: // TreePath
115: configHelper.addIncludePattern("javax.swing.tree.TreePath",
116: false);
117: getOrCreateSpec("javax.swing.tree.TreePath");
118:
119: // DefaultMutableTreeNode
120: configHelper.addIncludePattern(
121: "javax.swing.tree.DefaultMutableTreeNode", false);
122: getOrCreateSpec("javax.swing.tree.DefaultMutableTreeNode");
123:
124: // DefaultTreeModel
125: spec = getOrCreateSpec("javax.swing.tree.DefaultTreeModel");
126: ld = configHelper.createLockDefinition("tcdefaultTreeLock",
127: ConfigLockLevel.WRITE);
128: ld.commit();
129: addLock("* javax.swing.tree.DefaultTreeModel.get*(..)", ld);
130: addLock("* javax.swing.tree.DefaultTreeModel.set*(..)", ld);
131: addLock("* javax.swing.tree.DefaultTreeModel.insert*(..)", ld);
132: spec.addTransient("listenerList");
133: spec
134: .addDistributedMethodCall(
135: "fireTreeNodesChanged",
136: "(Ljava/lang/Object;[Ljava/lang/Object;[I[Ljava/lang/Object;)V",
137: false);
138: spec
139: .addDistributedMethodCall(
140: "fireTreeNodesInserted",
141: "(Ljava/lang/Object;[Ljava/lang/Object;[I[Ljava/lang/Object;)V",
142: false);
143: spec
144: .addDistributedMethodCall(
145: "fireTreeNodesRemoved",
146: "(Ljava/lang/Object;[Ljava/lang/Object;[I[Ljava/lang/Object;)V",
147: false);
148: spec
149: .addDistributedMethodCall(
150: "fireTreeStructureChanged",
151: "(Ljava/lang/Object;[Ljava/lang/Object;[I[Ljava/lang/Object;)V",
152: false);
153: spec.addDistributedMethodCall("fireTreeStructureChanged",
154: "(Ljava/lang/Object;Ljavax/swing/tree/TreePath;)V",
155: false);
156:
157: // AbstractListModel
158: spec = getOrCreateSpec("javax.swing.AbstractListModel");
159: spec.addTransient("listenerList");
160: spec.addDistributedMethodCall("fireContentsChanged",
161: "(Ljava/lang/Object;II)V", false);
162: spec.addDistributedMethodCall("fireIntervalAdded",
163: "(Ljava/lang/Object;II)V", false);
164: spec.addDistributedMethodCall("fireIntervalRemoved",
165: "(Ljava/lang/Object;II)V", false);
166: }
167: }
|