Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 2 12 package com.versant.core.jdo.tools.ant; 13 14 import org.apache.tools.ant.Task; 15 import org.apache.tools.ant.BuildException; 16 17 import java.io.InputStream ; 18 import java.io.IOException ; 19 import java.util.Properties ; 20 21 import com.versant.core.common.BindingSupportImpl; 22 23 28 public class CopyDatabaseTask extends Task { 29 30 private String config = "versant.properties"; 31 private CopyDatabaseBean cbean = new CopyDatabaseBean(); 32 33 public void execute() throws BuildException { 34 if (config == null) { 35 throw new BuildException("project attribute is required " + 36 "(name of .jdogenie project on the classpath)"); 37 } 38 try { 39 cbean.setSrcProps(loadProperties(config)); 40 cbean.copyDatabase(); 41 } catch (Throwable t) { 42 t.printStackTrace(System.out); 43 throw new BuildException(t); 44 } 45 } 46 47 private Properties loadProperties(String filename) throws IOException { 48 ClassLoader cl = getClass().getClassLoader(); 49 InputStream in = null; 50 try { 51 if (filename.startsWith("/")) filename = filename.substring(1); 52 in = cl.getResourceAsStream(filename); 53 if (in == null) { 54 throw BindingSupportImpl.getInstance().runtime("Resource not found: " + filename); 55 } 56 Properties p = new Properties (); 57 p.load(in); 58 return p; 59 } finally { 60 if (in != null) in.close(); 61 } 62 } 63 64 public void setConfig(String config) { 65 this.config = config; 66 } 67 68 public void setProject(String config) { 69 setConfig(config); 70 } 71 72 public void setDatastore(String datastore) { 73 cbean.setDatastore(datastore); 74 } 75 76 public void setDb(String db) { 77 cbean.setDb(db); 78 } 79 80 public void setUrl(String url) { 81 cbean.setUrl(url); 82 } 83 84 public void setDriver(String driver) { 85 cbean.setDriver(driver); 86 } 87 88 public void setUser(String user) { 89 cbean.setUser(user); 90 } 91 92 public void setPassword(String password) { 93 cbean.setPassword(password); 94 } 95 96 public void setProperties(String properties) { 97 cbean.setProperties(properties); 98 } 99 100 public void setDropTables(boolean dropTables) { 101 cbean.setDropTables(dropTables); 102 } 103 104 public void setCreateTables(boolean createTables) { 105 cbean.setCreateTables(createTables); 106 } 107 108 public void setRowsPerTransaction(int rowsPerTransaction) { 109 cbean.setRowsPerTransaction(rowsPerTransaction); 110 } 111 112 public void setLogEvents(String logEvents) { 113 cbean.setLogEvents(logEvents); 114 } 115 116 } 117
| Popular Tags
|