X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2FDatabaseStarter.java;h=a3174190c4979c8447857b829e5371bade93d53f;hb=539c6d91b7a34e32c6669445d00e9275c337530a;hp=44294e351916cd335f4deb019fe3a9ea7b1c7142;hpb=062bbb86bce78fd1328ccfa718c491db465bc1f4;p=utils diff --git a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java index 44294e35..a3174190 100644 --- a/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java +++ b/test/enterprise/src/main/java/org/wamblee/support/persistence/DatabaseStarter.java @@ -12,10 +12,9 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ + */ package org.wamblee.support.persistence; - /** * This class is used for starting the database from ant. */ @@ -24,7 +23,7 @@ public class DatabaseStarter { /** * Database class which encapsulates management of the database. */ - private Class _databaseClass; + private Class databaseClass; /** * Execution as a main program. Commandline @@ -32,7 +31,7 @@ public class DatabaseStarter { *
      * 
      *    DatabaseStarter <databaseClassName>
-     *  
+     * 
      * 
* * where the database class name must be the name of a concrete subclass of @@ -40,14 +39,13 @@ public class DatabaseStarter { * * @param args */ - public static void main( String[] args ) throws Exception { + public static void main(String[] args) throws Exception { String clazz = args[0]; try { - new DatabaseStarter( Class.forName( clazz ) ).start( ); - } catch ( Exception e ) { - e.printStackTrace( ); - System.out - .println( "\nUsage: ant dbClass "); + new DatabaseStarter(Class.forName(clazz)).start(); + } catch (Exception e) { + e.printStackTrace(); + System.out.println("\nUsage: ant dbClass "); } } @@ -58,13 +56,12 @@ public class DatabaseStarter { * Classname of the database class to use. * @throws Exception */ - public DatabaseStarter( Class aClass ) throws Exception { - if ( !Database.class.isAssignableFrom( aClass ) ) { - throw new IllegalArgumentException( "Class '" - + aClass.getName( ) - + "' is not a subclass of Database" ); + public DatabaseStarter(Class aClass) throws Exception { + if (!Database.class.isAssignableFrom(aClass)) { + throw new IllegalArgumentException("Class '" + aClass.getName() + + "' is not a subclass of Database"); } - _databaseClass = aClass; + databaseClass = aClass; } /** @@ -72,8 +69,8 @@ public class DatabaseStarter { * * @throws Exception */ - public DatabaseStarter( ) throws Exception { - this( DerbyDatabase.class ); + public DatabaseStarter() throws Exception { + this(DerbyDatabase.class); } /** @@ -81,26 +78,26 @@ public class DatabaseStarter { * * @throws Exception */ - public void start( ) throws Exception { - Database lDatabase = (Database) _databaseClass.newInstance( ); - lDatabase.start( ); - System.out.println( "Database has been started. " ); - System.out.println( ); - System.out.println("======================================================="); - System.out.println( "Connection details:" ); - // System.out.println( " Driver class: " - // + lDatabase.getDriverClassName( ) ); - System.out.println( " JDBC URL: " - + lDatabase.getExternalJdbcUrl( ) ); - System.out.println( " username: '" + lDatabase.getUsername( ) - + "'" ); - System.out.println( " password: '" + lDatabase.getPassword( ) - + "'" ); - System.out.println( "Interrupt the program to stop the database." ); - System.out.println("======================================================="); - System.out.println("You must now populate the database with a schema. Use 'ant help' for information."); - for ( ;; ) { - Thread.sleep( 1000 ); + public void start() throws Exception { + Database lDatabase = (Database) databaseClass.newInstance(); + lDatabase.start(); + System.out.println("Database has been started. "); + System.out.println(); + System.out + .println("======================================================="); + System.out.println("Connection details:"); + // System.out.println( " Driver class: " + // + lDatabase.getDriverClassName( ) ); + System.out.println(" JDBC URL: " + lDatabase.getExternalJdbcUrl()); + System.out.println(" username: '" + lDatabase.getUsername() + "'"); + System.out.println(" password: '" + lDatabase.getPassword() + "'"); + System.out.println("Interrupt the program to stop the database."); + System.out + .println("======================================================="); + System.out + .println("You must now populate the database with a schema. Use 'ant help' for information."); + for (;;) { + Thread.sleep(1000); } } }