Skip to content

Commit

Permalink
Added --auto-create
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Oct 28, 2007
1 parent 3eb9ab5 commit 5095aad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Expand Up @@ -39,13 +39,16 @@
import org.apache.ddlutils.model.Database;
import org.jumpmind.symmetric.common.Constants;
import org.jumpmind.symmetric.db.IDbDialect;
import org.jumpmind.symmetric.service.IBootstrapService;

/**
* Run symmetric utilities and/or launch an embedded version of Symmetric. If you run this
* program without any arguments 'help' will print out.
*/
public class SymmetricLauncher {

private static final String OPTION_AUTO_CREATE = "auto-create";

private static final String OPTION_PORT_SERVER = "port";

private static final String OPTION_DDL_GEN = "generate-config-dll";
Expand Down Expand Up @@ -89,6 +92,11 @@ public static void main(String[] args) throws Exception {
generateDDL(new SymmetricEngine(), line.getOptionValue(OPTION_DDL_GEN));
return;
}

if (line.hasOption(OPTION_AUTO_CREATE)) {
autoCreateDatabase(new SymmetricEngine());
return;
}

if (line.hasOption(OPTION_RUN_DDL_XML)) {
runDdlXml(new SymmetricEngine(), line.getOptionValue(OPTION_RUN_DDL_XML));
Expand Down Expand Up @@ -136,6 +144,10 @@ private static Options buildOptions() {
options
.addOption("r", OPTION_RUN_DDL_XML, true,
"Takes an argument of a DdlUtils xml file and applies it to the database configured in your symmetric properties file.");
options
.addOption("a", OPTION_AUTO_CREATE, false,
"Attempts to create the symmetric tables in the configured database.");


return options;
}
Expand Down Expand Up @@ -163,6 +175,12 @@ private static void generateDefaultProperties(String fileName) throws IOExceptio
is.close();
os.close();
}

private static void autoCreateDatabase(SymmetricEngine engine) {
IBootstrapService bootstrapService = (IBootstrapService)engine.getApplicationContext().getBean(Constants.BOOTSTRAP_SERVICE);
bootstrapService.setAutoConfigureDatabase(true);
bootstrapService.init();
}

private static void runDdlXml(SymmetricEngine engine, String fileName) throws FileNotFoundException {
IDbDialect dialect = (IDbDialect) engine.getApplicationContext().getBean(Constants.DB_DIALECT);
Expand Down
Expand Up @@ -32,5 +32,7 @@ public interface IBootstrapService {
public void register();

public void heartbeat();

public void setAutoConfigureDatabase(boolean autoConfigureDatabase);

}

0 comments on commit 5095aad

Please sign in to comment.