1 22 23 24 package com.mchange.v2.sql.filter; 25 26 import java.io.*; 27 import java.sql.*; 28 import java.lang.reflect.*; 29 import com.mchange.v2.codegen.intfc.*; 30 import com.mchange.v1.lang.ClassUtils; 31 import javax.sql.DataSource ; 32 33 public final class RecreatePackage 34 { 35 final static Class [] intfcs 36 = new Class [] 37 { 38 Connection.class, 39 ResultSet.class, 40 DatabaseMetaData.class, 41 Statement.class, 42 PreparedStatement.class, 43 CallableStatement.class, 44 DataSource .class 45 }; 46 47 public static void main( String [] argv ) 48 { 49 try 50 { 51 DelegatorGenerator dg = new DelegatorGenerator(); 52 String thisClassName = RecreatePackage.class.getName(); 53 String pkg = thisClassName.substring(0, thisClassName.lastIndexOf('.')); 54 for (int i = 0; i < intfcs.length; ++i) 55 { 56 Class intfcl = intfcs[i]; 57 String sin = ClassUtils.simpleClassName( intfcl ); 58 String sgenclass1 = "Filter" + sin; 59 String sgenclass2 = "SynchronizedFilter" + sin; 60 61 Writer w = null; 62 try 63 { 64 w = new BufferedWriter( new FileWriter( sgenclass1 + ".java" ) ); 65 dg.setMethodModifiers( Modifier.PUBLIC ); 66 dg.writeDelegator( intfcl, pkg + '.' + sgenclass1, w ); 67 System.err.println( sgenclass1 ); 68 } 69 finally 70 { 71 try { if (w != null) w.close(); } 72 catch (Exception e) 73 { e.printStackTrace(); } 74 } 75 76 try 77 { 78 w = new BufferedWriter( new FileWriter( sgenclass2 + ".java" ) ); 79 dg.setMethodModifiers( Modifier.PUBLIC | Modifier.SYNCHRONIZED ); 80 dg.writeDelegator( intfcl, pkg + '.' + sgenclass2, w ); 81 System.err.println( sgenclass2 ); 82 } 83 finally 84 { 85 try { if (w != null) w.close(); } 86 catch (Exception e) 87 { e.printStackTrace(); } 88 } 89 } 90 } 91 catch ( Exception e ) 92 { e.printStackTrace(); } 93 } 94 95 private RecreatePackage() 96 {} 97 } 98 | Popular Tags |