01: /*
02: * Distributed as part of c3p0 v.0.9.1.2
03: *
04: * Copyright (C) 2005 Machinery For Change, Inc.
05: *
06: * Author: Steve Waldman <swaldman@mchange.com>
07: *
08: * This library is free software; you can redistribute it and/or modify
09: * it under the terms of the GNU Lesser General Public License version 2.1, as
10: * published by the Free Software Foundation.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public License
18: * along with this software; see the file LICENSE. If not, write to the
19: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20: * Boston, MA 02111-1307, USA.
21: */
22:
23: package com.mchange.v2.sql.filter;
24:
25: import java.io.*;
26: import java.sql.*;
27: import java.lang.reflect.*;
28: import com.mchange.v2.codegen.intfc.*;
29: import com.mchange.v1.lang.ClassUtils;
30: import javax.sql.DataSource;
31:
32: public final class RecreatePackage {
33: final static Class[] intfcs = new Class[] { Connection.class,
34: ResultSet.class, DatabaseMetaData.class, Statement.class,
35: PreparedStatement.class, CallableStatement.class,
36: DataSource.class };
37:
38: public static void main(String[] argv) {
39: try {
40: DelegatorGenerator dg = new DelegatorGenerator();
41: String this ClassName = RecreatePackage.class.getName();
42: String pkg = this ClassName.substring(0, this ClassName
43: .lastIndexOf('.'));
44: for (int i = 0; i < intfcs.length; ++i) {
45: Class intfcl = intfcs[i];
46: String sin = ClassUtils.simpleClassName(intfcl);
47: String sgenclass1 = "Filter" + sin;
48: String sgenclass2 = "SynchronizedFilter" + sin;
49:
50: Writer w = null;
51: try {
52: w = new BufferedWriter(new FileWriter(sgenclass1
53: + ".java"));
54: dg.setMethodModifiers(Modifier.PUBLIC);
55: dg
56: .writeDelegator(intfcl, pkg + '.'
57: + sgenclass1, w);
58: System.err.println(sgenclass1);
59: } finally {
60: try {
61: if (w != null)
62: w.close();
63: } catch (Exception e) {
64: e.printStackTrace();
65: }
66: }
67:
68: try {
69: w = new BufferedWriter(new FileWriter(sgenclass2
70: + ".java"));
71: dg.setMethodModifiers(Modifier.PUBLIC
72: | Modifier.SYNCHRONIZED);
73: dg
74: .writeDelegator(intfcl, pkg + '.'
75: + sgenclass2, w);
76: System.err.println(sgenclass2);
77: } finally {
78: try {
79: if (w != null)
80: w.close();
81: } catch (Exception e) {
82: e.printStackTrace();
83: }
84: }
85: }
86: } catch (Exception e) {
87: e.printStackTrace();
88: }
89: }
90:
91: private RecreatePackage() {
92: }
93: }
|