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 org.terracotta.modules.iBatis_2_2_0;
006:
007: import org.osgi.framework.BundleContext;
008: import org.osgi.framework.Constants;
009: import org.terracotta.modules.configuration.TerracottaConfiguratorModule;
010: import org.terracotta.modules.iBatis_2_2_0.object.config.IBatisChangeApplicatorSpec;
011: import org.terracotta.modules.iBatis_2_2_0.object.config.IBatisModuleSpec;
012:
013: import com.tc.object.bytecode.ClassAdapterFactory;
014: import com.tc.object.config.ConfigLockLevel;
015: import com.tc.object.config.TransparencyClassSpec;
016: import com.tc.object.config.ModuleSpec;
017:
018: import java.sql.SQLException;
019: import java.util.Dictionary;
020: import java.util.Hashtable;
021:
022: public final class IBatisTerracottaConfigurator extends
023: TerracottaConfiguratorModule {
024: protected final void addInstrumentation(final BundleContext context) {
025: configHelper.addAutolock(
026: "* java.util.Collections$SynchronizedList.*(..)",
027: ConfigLockLevel.WRITE);
028:
029: ClassAdapterFactory factory = new IBatisClassAdapter();
030:
031: TransparencyClassSpec spec = configHelper
032: .getOrCreateSpec("com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl");
033: configHelper
034: .addAutolock(
035: "* com.ibatis.sqlmap.engine.mapping.result.loader.EnhancedLazyResultLoader$EnhancedLazyResultLoaderImpl.loadObject(..)",
036: ConfigLockLevel.WRITE);
037:
038: spec = configHelper.getOrCreateSpec(SQLException.class
039: .getName());
040: spec.markPreInstrumented();
041:
042: spec = configHelper
043: .getOrCreateSpec("com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate");
044:
045: spec = configHelper
046: .getOrCreateSpec("com.ibatis.sqlmap.engine.impl.SqlMapClientImpl");
047: spec.setCallConstructorOnLoad(true);
048: spec.addTransient("localSqlMapSession");
049:
050: configHelper.addIncludePattern(
051: "com.ibatis.sqlmap.engine.execution.SqlExecutor",
052: false, false, false);
053:
054: spec = configHelper
055: .getOrCreateSpec("com.ibatis.common.jdbc.SimpleDataSource");
056: spec.setCallConstructorOnLoad(true);
057: spec.setCustomClassAdapter(factory);
058: spec.addTransient("activeConnections");
059: spec.addTransient("idleConnections");
060: configHelper.addAutolock(
061: "* com.ibatis.common.jdbc.SimpleDataSource.*(..)",
062: ConfigLockLevel.WRITE);
063:
064: configHelper
065: .addIncludePattern(
066: "com.ibatis.sqlmap.engine.transaction.jdbc.JdbcTransactionConfig",
067: false, false, false);
068: configHelper
069: .addIncludePattern(
070: "com.ibatis.sqlmap.engine.transaction.BaseTransactionConfig",
071: false, false, false);
072:
073: configHelper
074: .addIncludePattern(
075: "com.ibatis.sqlmap.engine.transaction.TransactionManager",
076: false, false, false);
077:
078: configHelper.addIncludePattern(
079: "com.ibatis.common.util.Throttle", false, false, false);
080: configHelper.addAutolock(
081: "* com.ibatis.common.util.Throttle.*(..)",
082: ConfigLockLevel.WRITE);
083: configHelper.addIncludePattern(
084: "com.ibatis.common.util.ThrottledPool", false, false,
085: false);
086:
087: configHelper.addIncludePattern(
088: "com.ibatis.sqlmap.engine.type.TypeHandlerFactory",
089: false, false, false);
090: configHelper.addIncludePattern(
091: "com.ibatis.sqlmap.engine.type.UnknownTypeHandler",
092: false, false, false);
093: configHelper.addIncludePattern(
094: "com.ibatis.sqlmap.engine.type.BaseTypeHandler", false,
095: false, false);
096:
097: configHelper.addIncludePattern(
098: "com.ibatis.sqlmap.engine.exchange.*", false, false,
099: false);
100: configHelper.addIncludePattern(
101: "com.ibatis.sqlmap.engine.mapping.statement.*", false,
102: false, false);
103:
104: configHelper.addIncludePattern(
105: "com.ibatis.sqlmap.engine.exchange.DomDataExchange",
106: false, false, false);
107: configHelper.addIncludePattern(
108: "com.ibatis.sqlmap.engine.exchange.ListDataExchange",
109: false, false, false);
110: configHelper
111: .addIncludePattern(
112: "com.ibatis.sqlmap.engine.exchange.ComplexDataExchange",
113: false, false, false);
114: configHelper
115: .addIncludePattern(
116: "com.ibatis.sqlmap.engine.exchange.PrimitiveDataExchange",
117: false, false, false);
118: configHelper
119: .addIncludePattern(
120: "com.ibatis.sqlmap.engine.exchange.ComplexDataExchange",
121: false, false, false);
122: configHelper.addIncludePattern(
123: "com.ibatis.sqlmap.engine.exchange.BaseDataExchange",
124: false, false, false);
125: configHelper
126: .addIncludePattern(
127: "com.ibatis.sqlmap.engine.exchange.DataExchangeFactory",
128: false, false, false);
129:
130: spec = configHelper
131: .getOrCreateSpec("com.ibatis.sqlmap.engine.exchange.JavaBeanDataExchange");
132: spec.addTransient("outParamPlan");
133: spec.addTransient("parameterPlan");
134:
135: spec = configHelper
136: .getOrCreateSpec("com.ibatis.sqlmap.engine.mapping.result.BasicResultMap");
137: spec.addTransient("remappableResultMappings");
138:
139: configHelper.addIncludePattern(
140: "com.ibatis.sqlmap.engine.mapping.parameter.*", false,
141: false, false);
142:
143: configHelper.addIncludePattern(
144: "com.ibatis.sqlmap.engine.mapping.sql.stat.StaticSql",
145: false, false, false);
146:
147: configHelper.addIncludePattern(
148: "com.ibatis.sqlmap.engine.type.*", false, false, false);
149:
150: configHelper
151: .addIncludePattern(
152: "com.ibatis.sqlmap.engine.mapping.result.BasicResultMapping",
153: false, false, false);
154: configHelper
155: .addIncludePattern(
156: "com.ibatis.sqlmap.engine.mapping.result.AutoResultMap",
157: false, false, false);
158:
159: configHelper
160: .addIncludePattern("com.ibatis.sqlmap.engine.scope.*",
161: false, false, false);
162:
163: spec = configHelper
164: .getOrCreateSpec("com.ibatis.sqlmap.engine.scope.SessionScope");
165: spec.addTransient("transaction");
166: spec.addTransient("transactionState");
167: spec.addTransient("savedTransactionState");
168:
169: spec = configHelper
170: .getOrCreateSpec("com.ibatis.sqlmap.engine.scope.RequestScope");
171: spec.addTransient("resultSet");
172:
173: configHelper
174: .addIncludePattern(
175: "com.ibatis.sqlmap.engine.mapping.sql.dynamic.DynamicSql",
176: false, false, false);
177: configHelper.addIncludePattern(
178: "com.ibatis.sqlmap.engine.mapping.sql.SqlText", false,
179: false, false);
180: configHelper
181: .addIncludePattern(
182: "com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.*",
183: false, false, false);
184: //addIncludePattern("com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.SqlTag", false, false, false);
185: //addIncludePattern("com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.DynamicTagHandler", false, false, false);
186: //addIncludePattern("com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.BaseTagHandler", false, false, false);
187: //addIncludePattern("com.ibatis.sqlmap.engine.mapping.sql.dynamic.elements.IterateTagHandler", false, false, false);
188: configHelper.addIncludePattern(
189: "com.ibatis.common.util.PaginatedArrayList", false,
190: false, false);
191:
192: /*
193: addIncludePattern("com.ibatis.sqlmap.engine.accessplan.EnhancedPropertyAccessPlan", false, false, false);
194: spec = getOrCreateSpec("com.ibatis.sqlmap.engine.accessplan.BaseAccessPlan");
195: spec.addTransient("clazz");
196: //spec.addTransient("propertyNames");
197: spec.addTransient("info");
198: */
199:
200: // IBatis DAO
201: configHelper.addIncludePattern(
202: "com.ibatis.dao.engine.impl.DaoProxy", false, false,
203: false);
204: spec = configHelper
205: .getOrCreateSpec("com.ibatis.dao.engine.impl.DaoImpl");
206:
207: spec = configHelper
208: .getOrCreateSpec("com.ibatis.dao.engine.impl.StandardDaoManager");
209: spec.setCallConstructorOnLoad(true);
210: spec.addTransient("transactionMode");
211: spec.addTransient("contextInTransactionList");
212:
213: spec = configHelper
214: .getOrCreateSpec("com.ibatis.dao.engine.impl.DaoContext");
215: spec.setCallConstructorOnLoad(true);
216: spec.addTransient("transaction");
217: spec.addTransient("state");
218:
219: configHelper.addIncludePattern(
220: "com.ibatis.dao.client.template.SqlMapDaoTemplate",
221: false, false, false);
222: configHelper.addIncludePattern(
223: "com.ibatis.dao.client.template.DaoTemplate", false,
224: false, false);
225:
226: configHelper
227: .addIncludePattern(
228: "com.ibatis.dao.engine.transaction.sqlmap.SqlMapDaoTransactionManager",
229: false, false, false);
230:
231: //addIncludePattern("com.ibatis.sqlmap.engine.accessplan.PropertyAccessPlan", false, false, false);
232:
233: configHelper.getOrCreateSpec(
234: "com.ibatis.sqlmap.engine.impl.SqlMapClientImpl")
235: .setCustomClassAdapter(factory);
236: }
237:
238: protected final void registerModuleSpec(final BundleContext context) {
239: final Dictionary serviceProps = new Hashtable();
240: serviceProps.put(Constants.SERVICE_VENDOR, "Terracotta, Inc.");
241: serviceProps.put(Constants.SERVICE_DESCRIPTION,
242: "IBatis Plugin Spec");
243: context.registerService(ModuleSpec.class.getName(),
244: new IBatisModuleSpec(new IBatisChangeApplicatorSpec(
245: getClass().getClassLoader())), serviceProps);
246: }
247:
248: }
|