X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Fenterprise%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2FDatabaseStarter.java;h=1afefd808046667b129f91de6cfafd4fcb36ea37;hb=ec9582b50e9c74b08b14c79d7d16de5d0fc2851e;hp=2fe0683afa73acb0636d581a7eec12fe62c63ab0;hpb=0d8d8f24656e585ee75558cfd6a4c661f8f14985;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 2fe0683a..1afefd80 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 @@ -1,5 +1,5 @@ /* - * Copyright 2005 the original author or authors. + * Copyright 2005-2010 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,9 +15,8 @@ */ package org.wamblee.support.persistence; - /** - * This class is used for starting the database from ant. + * This class is used for starting the database as a main program. */ public class DatabaseStarter { @@ -32,22 +31,21 @@ public class DatabaseStarter { *
      * 
      *    DatabaseStarter <databaseClassName>
-     *  
+     * 
      * 
* * where the database class name must be the name of a concrete subclass of * {@link Database}. * - * @param args + * @param aArgs */ - public static void main( String[] args ) throws Exception { - String clazz = args[0]; + public static void main(String[] aArgs) throws Exception { + String clazz = aArgs[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,11 +56,10 @@ 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; } @@ -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); } } }