[Idrs-commit] CVS: Idrs/dev/src/net/sourceforge/idrs/deploy HotDeploy.java,1.4,1.5 RMLDeploy.java,1.
Brought to you by:
bigman921
|
From: Marc B. <big...@us...> - 2003-02-06 20:13:49
|
Update of /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/deploy
In directory sc8-pr-cvs1:/tmp/cvs-serv26777/dev/src/net/sourceforge/idrs/deploy
Modified Files:
HotDeploy.java RMLDeploy.java
Log Message:
1. Moved controller code into servlet
2. Added the ability for properties to be arrays of strings
3. Moved config file into it's own xml file
4. Added better compile errors for rml pages
5. removed all debug printings
Index: HotDeploy.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/deploy/HotDeploy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** HotDeploy.java 23 Mar 2002 04:48:27 -0000 1.4
--- HotDeploy.java 6 Feb 2003 20:13:44 -0000 1.5
***************
*** 168,172 ****
dep.deploy();
!
if (dep.isError()) {
dep.getException().printStackTrace(out);
--- 168,172 ----
dep.deploy();
! dep.getPsUsed().close();
if (dep.isError()) {
dep.getException().printStackTrace(out);
Index: RMLDeploy.java
===================================================================
RCS file: /cvsroot/idrs/Idrs/dev/src/net/sourceforge/idrs/deploy/RMLDeploy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** RMLDeploy.java 23 Mar 2002 04:48:27 -0000 1.4
--- RMLDeploy.java 6 Feb 2003 20:13:44 -0000 1.5
***************
*** 23,359 ****
*/
public final class RMLDeploy {
! String name, groups, params, conns;
! int id, min, max, results;
! boolean compile, update, err;
! String src;
! IDRSRep report;
! Connection con;
! LinkedList names, vals;
! Exception exc;
! ByteArrayInputStream bais;
! byte[] bytes;
!
! /**
! * Initializes list of options
! */
! public RMLDeploy(Connection con) {
! this.con = con;
! this.names = new LinkedList();
! this.vals = new LinkedList();
! compile = true;
! update = false;
! err = false;
! }
! /**
! * Sets the update flag
! * @param update Wether or not this is an update of a current deployment or a new one
! */
! public void setUpdate(boolean update) {
! this.update = update;
! }
! /**
! * Sets the compile flag
! * @param compile Wether or not the RML needs to be compiled
! */
! public void setCompile(boolean compile) {
! this.compile = compile;
! }
! /**
! * Sets the ID of the page
! * @param id ID of the page
! */
! public void setID(int id) {
! this.id = id;
! names.add("DocID");
! vals.add(new Integer(id));
! }
! /**
! * Sets the Name of the page
! * @param name Name of the page
! */
! public void setName(String name) {
! this.name = name;
! names.add("DocName");
! vals.add(name);
! }
! /**
! * Sets the Groups of the page
! * @param groups Groups of the page
! */
! public void setGroups(String groups) {
! this.groups = groups;
! names.add("DocGroups");
! vals.add(groups);
! }
! /**
! * Sets the Params of the page
! * @param params Params of the page
! */
! public void setParams(String params) {
! this.params = params;
! names.add("DocParams");
! vals.add(params);
! }
! /**
! * Sets the Connections of the page
! * @param conns Connections of the page
! */
! public void setConns(String conns) {
! this.conns = conns;
! names.add("DocConns");
! vals.add(conns);
! }
! /**
! * Sets the minimum number of instances in the pool of the page
! * @param min Minimum instances of the page
! */
! public void setMin(int min) {
! this.min = min;
! names.add("DocMin");
! vals.add(new Integer(min));
! }
! /**
! * Sets the maximum number of instances in the pool of the page
! * @param max Maximum instances of the page
! */
! public void setMax(int max) {
! this.max = max;
! names.add("DocMax");
! vals.add(new Integer(max));
! }
! /**
! * Sets the page's source, wether it's been compiled or not and takes apropriate action.<br>
! * If compile is true, then the page is considered RML source and and compiled. Otherwise the compiled source is Deserialized.
! * @param src The source of the page
! * @param logger Either a PrintWriter or a PrintStream for logging output of the compile
! */
! public void setSrc(String src,Object logger) {
! if (compile) {
! try {
! report = (new IDRSCompiler((String) src, false)).setLogger(logger).buildReport();
!
! ByteArrayOutputStream baos = new ByteArrayOutputStream();
! ObjectOutputStream oos = new ObjectOutputStream(baos);
! oos.writeObject(report);
! bais = new ByteArrayInputStream(baos.toByteArray());
! bytes=baos.toByteArray();
! }
! catch (Exception e) {
! err = false;
! exc = e;
! return;
! }
! }
! else {
! bytes = src.getBytes();
! }
! bais = new ByteArrayInputStream(bytes);
! names.add("DocSrc");
! vals.add(bais);
! }
!
! public void setSrc(String src,PrintWriter logger,String parseClass,String rmlTrans,boolean isFile,String rmlSchema) {
! System.out.println("Compile : " + compile);
! if (compile) {
! try {
! //report = (new IDRSCompiler((String) src, false)).setLogger(logger).buildReport();
! RmlCompiler comp = new RmlCompiler(logger,src,parseClass,rmlTrans,isFile,rmlSchema);
!
! report = comp.getReport();
! ByteArrayOutputStream baos = new ByteArrayOutputStream();
! ObjectOutputStream oos = new ObjectOutputStream(baos);
! oos.writeObject(report);
! bais = new ByteArrayInputStream(baos.toByteArray());
! bytes=baos.toByteArray();
! }
! catch (Exception e) {
!
! e.printStackTrace(logger);
! err = true;
! exc = e;
! return;
! }
! }
! else {
! bytes = src.getBytes();
! }
! bais = new ByteArrayInputStream(bytes);
! names.add("DocSrc");
! vals.add(bais);
! }
! /**
! * Deploys the report to the database based on the connection provided to the constructor
! */
! public boolean deploy() throws Exception {
! String SQL;
! int i, m;
! Object[] vals;
! PreparedStatement ps;
! try {
! //Generate an SQL statement
! if (update) {
! SQL = deployUpdate();
! }
! else {
! SQL = deployInsert();
! }
!
! System.out.println(SQL);
! //Loop through all vals and set them using set object or as a strem if it's a report
! vals = this.vals.toArray();
! ps = con.prepareStatement(SQL);
! for (i = 0, m = vals.length; i < m; i++) {
! System.out.println(vals[i]);
! if (vals[i] instanceof ByteArrayInputStream) {
! ps.setBinaryStream(i + 1, bais, bytes.length);
! }
! else {
! ps.setObject(i + 1, vals[i]);
! }
! }
! if (update) {
! if (this.name != null) {
! ps.setString(vals.length+1, this.name);
! }
! else {
! ps.setInt(vals.length+1, this.id);
! }
! }
! this.results = ps.executeUpdate();
! ps.close();
! if (this.results < 1) {
! throw new Exception("No Rows Effected By Update");
! }
! }
! catch (Exception e) {
! this.exc = e;
! this.err = true;
! }
! return !this.err;
! }
! /**
! * Builds an SQL UPDATE statement for use in a PreparedStatement
! */
! protected String deployUpdate() throws Exception {
! try {
! Object[] vals, names;
! vals = this.vals.toArray();
! names = this.names.toArray();
! String snames = "", svals = "";
! int i, m;
! String SQL;
! //Construct A SQL string
! for (i = 0, m = names.length; i < m; i++) {
! snames += (String) names[i] + "=? ,";
! System.out.println(names[i]);
! }
! SQL =
! "UPDATE tblDoc SET "
! + snames.substring(0, snames.lastIndexOf(",") - 1)
! + " WHERE ";
! if (this.name != null) {
! SQL += "DocName=?";
! }
! else {
! SQL += "DocID=?";
! }
! return SQL;
! }
! catch (Exception e) {
! throw e;
! }
! }
! /**
! * Builds an SQL INSERT statement for use in a PreparedStatement
! */
! protected String deployInsert() throws Exception {
! try {
! Object[] vals, names;
! vals = this.vals.toArray();
! names = this.names.toArray();
! String snames = "", svals = "";
! int i, m;
! String SQL;
! //Construct A SQL string
! for (i = 0, m = names.length; i < m; i++) {
! snames += (String) names[i] + " ,";
! svals += "? , ";
! System.out.println(names[i]);
! }
! SQL =
! "INSERT INTO tblDoc ("
! + snames.substring(0, snames.lastIndexOf(",") - 1)
! + ") VALUES("
! + svals.substring(0, svals.lastIndexOf(",") - 1)
! + ")";
! return SQL;
! }
! catch (Exception e) {
! throw e;
! }
! }
!
! /**
! * Returns any eception that has occurred
! */
! public Exception getException() {
! return this.exc;
! }
! /**
! * Returns weth or not an error has occurred
! */
! public boolean isError() {
! return this.err;
! }
!
!
! }
--- 23,389 ----
*/
public final class RMLDeploy {
! String name, groups, params, conns;
! PreparedStatement psUsed;
! int id, min, max, results;
! boolean compile, update, err;
! RmlCompiler compiler;
! String src;
! IDRSRep report;
! Connection con;
! LinkedList names, vals;
! Exception exc;
! ByteArrayInputStream bais;
! byte[] bytes;
! /**
! * Initializes list of options
! */
! public RMLDeploy(Connection con) {
! this.con = con;
! this.names = new LinkedList();
! this.vals = new LinkedList();
! compile = true;
! update = false;
! err = false;
! }
! /**
! * Sets the update flag
! * @param update Wether or not this is an update of a current deployment or a new one
! */
! public void setUpdate(boolean update) {
! this.update = update;
! }
! /**
! * Sets the compile flag
! * @param compile Wether or not the RML needs to be compiled
! */
! public void setCompile(boolean compile) {
! this.compile = compile;
! }
! /**
! * Sets the ID of the page
! * @param id ID of the page
! */
! public void setID(int id) {
! this.id = id;
! names.add("DocID");
! vals.add(new Integer(id));
! }
! /**
! * Sets the Name of the page
! * @param name Name of the page
! */
! public void setName(String name) {
! this.name = name;
! names.add("DocName");
! vals.add(name);
! }
! /**
! * Sets the Groups of the page
! * @param groups Groups of the page
! */
! public void setGroups(String groups) {
! this.groups = groups;
! names.add("DocGroups");
! vals.add(groups);
! }
! /**
! * Sets the Params of the page
! * @param params Params of the page
! */
! public void setParams(String params) {
! this.params = params;
! names.add("DocParams");
! vals.add(params);
! }
! /**
! * Sets the Connections of the page
! * @param conns Connections of the page
! */
! public void setConns(String conns) {
! this.conns = conns;
! names.add("DocConns");
! vals.add(conns);
! }
! /**
! * Sets the minimum number of instances in the pool of the page
! * @param min Minimum instances of the page
! */
! public void setMin(int min) {
! this.min = min;
! names.add("DocMin");
! vals.add(new Integer(min));
! }
! /**
! * Sets the maximum number of instances in the pool of the page
! * @param max Maximum instances of the page
! */
! public void setMax(int max) {
! this.max = max;
! names.add("DocMax");
! vals.add(new Integer(max));
! }
! // /**
! // * Sets the page's source, wether it's been compiled or not and takes apropriate action.<br>
! // * If compile is true, then the page is considered RML source and and compiled. Otherwise the compiled source is Deserialized.
! // * @param src The source of the page
! // * @param logger Either a PrintWriter or a PrintStream for logging output of the compile
! // */
! //
! // public void setSrc(String src,Object logger) {
! // if (compile) {
! // try {
! // this.compiler = new IDRSCompiler((String) src, false);
! // report = compiler.setLogger(logger).buildReport();
! //
! // ByteArrayOutputStream baos = new ByteArrayOutputStream();
! // ObjectOutputStream oos = new ObjectOutputStream(baos);
! // oos.writeObject(report);
! // bais = new ByteArrayInputStream(baos.toByteArray());
! // bytes=baos.toByteArray();
! // }
! // catch (Exception e) {
! // err = false;
! // exc = e;
! // return;
! // }
! // }
! // else {
! // bytes = src.getBytes();
! // }
! //
! // bais = new ByteArrayInputStream(bytes);
! // names.add("DocSrc");
! // vals.add(bais);
! // }
! public void setSrc(
! String src,
! PrintWriter logger,
! String parseClass,
! String rmlTrans,
! boolean isFile,
! String rmlSchema) {
! //System.out.println("Compile : " + compile);
! if (compile) {
! try {
! //report = (new IDRSCompiler((String) src, false)).setLogger(logger).buildReport();
! this.compiler =
! new RmlCompiler(
! logger,
! src,
! parseClass,
! rmlTrans,
! isFile,
! rmlSchema);
! report = compiler.getReport();
! ByteArrayOutputStream baos = new ByteArrayOutputStream();
! ObjectOutputStream oos = new ObjectOutputStream(baos);
! oos.writeObject(report);
! bais = new ByteArrayInputStream(baos.toByteArray());
! bytes = baos.toByteArray();
! } catch (Exception e) {
! e.printStackTrace(logger);
! err = true;
! exc = e;
! return;
! }
! } else {
! bytes = src.getBytes();
! }
!
! this.err = compiler.getErr() != null;
! bais = new ByteArrayInputStream(bytes);
! names.add("DocSrc");
! vals.add(bais);
! }
! /**
! * Deploys the report to the database based on the connection provided to the constructor
! */
! public boolean deploy() throws Exception {
! String SQL;
! int i, m;
! Object[] vals;
! PreparedStatement ps;
! try {
! //Generate an SQL statement
! if (update) {
! SQL = deployUpdate();
! } else {
! SQL = deployInsert();
! }
! //System.out.println(SQL);
! //Loop through all vals and set them using set object or as a strem if it's a report
! vals = this.vals.toArray();
! ps = con.prepareStatement(SQL);
! for (i = 0, m = vals.length; i < m; i++) {
! //System.out.println(vals[i]);
! if (vals[i] instanceof ByteArrayInputStream) {
! ps.setBinaryStream(i + 1, bais, bytes.length);
! } else {
! ps.setObject(i + 1, vals[i]);
! }
! }
! if (update) {
! if (this.name != null) {
! ps.setString(vals.length + 1, this.name);
! } else {
! ps.setInt(vals.length + 1, this.id);
! }
! }
! this.results = ps.executeUpdate();
! //ps.close();
! this.psUsed = ps;
! if (this.results < 1) {
! throw new Exception("No Rows Effected By Update");
! }
! } catch (Exception e) {
! this.exc = e;
! this.err = true;
! }
! return !this.err;
! }
! /**
! * Builds an SQL UPDATE statement for use in a PreparedStatement
! */
! protected String deployUpdate() throws Exception {
! try {
! Object[] vals, names;
! vals = this.vals.toArray();
! names = this.names.toArray();
! String snames = "", svals = "";
! int i, m;
! String SQL;
! //Construct A SQL string
! for (i = 0, m = names.length; i < m; i++) {
! snames += (String) names[i] + "=? ,";
! System.out.println(names[i]);
! }
! SQL =
! "UPDATE tblDoc SET "
! + snames.substring(0, snames.lastIndexOf(",") - 1)
! + " WHERE ";
! if (this.name != null) {
! SQL += "DocName=?";
! } else {
! SQL += "DocID=?";
! }
! return SQL;
! } catch (Exception e) {
! throw e;
! }
! }
! /**
! * Builds an SQL INSERT statement for use in a PreparedStatement
! */
! protected String deployInsert() throws Exception {
! try {
! Object[] vals, names;
! vals = this.vals.toArray();
! names = this.names.toArray();
! String snames = "", svals = "";
! int i, m;
! String SQL;
! //Construct A SQL string
! for (i = 0, m = names.length; i < m; i++) {
! snames += (String) names[i] + " ,";
! svals += "? , ";
! System.out.println(names[i]);
! }
! SQL =
! "INSERT INTO tblDoc ("
! + snames.substring(0, snames.lastIndexOf(",") - 1)
! + ") VALUES("
! + svals.substring(0, svals.lastIndexOf(",") - 1)
! + ")";
! return SQL;
! } catch (Exception e) {
! throw e;
! }
! }
! /**
! * Returns any eception that has occurred
! */
! public Exception getException() {
! return this.exc;
! }
!
! /**
! * Returns weth or not an error has occurred
! */
+ public boolean isError() {
+ return this.err;
+ }
+
+ /**
+ * Returns the compiler.
+ * @return RmlCompiler
+ */
+ public RmlCompiler getCompiler() {
+ return compiler;
+ }
+
+ /**
+ * Sets the compiler.
+ * @param compiler The compiler to set
+ */
+ public void setCompiler(RmlCompiler compiler) {
+ this.compiler = compiler;
+ }
+
+ /**
+ * Returns the psUsed.
+ * @return PreparedStatement
+ */
+ public PreparedStatement getPsUsed() {
+ return psUsed;
+ }
+
+ }
|