cziegeler 2003/02/26 02:47:40
Modified: tools/src blocks-build.xsl src/blocks/databases build.xml Added: src/blocks/databases/java1.4/org/apache/cocoon/components/language/markup/xsp AbstractEsqlConnection.java src/blocks/databases/java1.2/org/apache/cocoon/components/language/markup/xsp AbstractEsqlConnection.java Removed: src/blocks/databases/java/org/apache/cocoon/components/language/markup/xsp AbstractEsqlConnection.java Log: Proof of concept for jdk dependent compilation - so again, no filtering required Revision Changes Path 1.23 +18 -7 xml-cocoon2/tools/src/blocks-build.xsl Index: blocks-build.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/tools/src/blocks-build.xsl,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- blocks-build.xsl 24 Feb 2003 18:38:04 -0000 1.22 +++ blocks-build.xsl 26 Feb 2003 10:47:40 -0000 1.23 @@ -141,12 +141,6 @@ <target name="{$block-name}-compile" depends="{$block-name}-build,{$block-name}-mocks,{$block-name}-prepare"> - <copy filtering="on" todir="{string('${build.blocks}')}/{$block-name}/src"> - <fileset dir="{string('${blocks}')}/{$block-name}/java"> - <include name="**/*.java" /> - </fileset> - </copy> - <copy filtering="on" todir="{string('${build.blocks}')}/{$block-name}/dest"> <fileset dir="{string('${blocks}')}/{$block-name}/java"> <include name="**/*.xsl"/> @@ -162,8 +156,23 @@ <xpatch extension="xroles" directory="{string('${blocks}')}/{$block-name}/conf" configuration="{string('${build.dest}/org/apache/cocoon/cocoon.roles')}"/> + <!-- This is a little bit tricky: + As the javac task checks, if a src directory is available and + stops if its not available, we use the following property + to either point to a jdk dependent directory or - if not + available - to the usual java source directory. + If someone knows a better solution... + --> + <condition property="dependend.vm" value="{string('${target.vm}')}"> + <available file="{string('${blocks}')}/{$block-name}/java{string('${target.vm}')}"/> + </condition> + <condition property="dependend.vm" value=""> + <not> + <available file="{string('${blocks}')}/{$block-name}/java{string('${target.vm}')}"/> + </not> + </condition> + <javac - srcdir="{string('${build.blocks}')}/{$block-name}/src" destdir="{string('${build.blocks}')}/{$block-name}/dest" debug="{string('${compiler.debug}')}" optimize="{string('${compiler.optimize}')}" @@ -171,6 +180,8 @@ target="{string('${target.vm}')}" nowarn="{string('${compiler.nowarn}')}" compiler="{string('${compiler}')}"> + <src path="{string('${blocks}')}/{$block-name}/java"/> + <src path="{string('${blocks}')}/{$block-name}/java{string('${dependend.vm}')}"/> <classpath refid="{$block-name}.classpath" /> </javac> 1.1 xml-cocoon2/src/blocks/databases/java1.4/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlConnection.java Index: AbstractEsqlConnection.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.language.markup.xsp; import org.apache.avalon.framework.logger.AbstractLogEnabled; import java.sql.Connection; import java.util.Properties; import java.sql.SQLException; /** * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> */ public abstract class AbstractEsqlConnection extends AbstractLogEnabled implements Connection { private String url = null; private Properties properties = null; private boolean multipleResults = false; protected AbstractEsqlConnection() { } protected abstract Connection getConnection() throws SQLException; /** * It appears that some commercial DBMSs like Oracle and Informix * are broken in that they don't follow the JDBC standard and * calls to getUpdateCount after getMoreResults result either in * an exception (Informix) or return the same value (i.e. not -1) (Oracle). * In addition, this feature is only useful with stored procedures. * Hence we disable it per default. **/ public void setMultipleResults(String value) { this.multipleResults = ("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value)); } public boolean getMultipleResults() { return (this.multipleResults); } public Properties getProperties() { return (properties); } public void setProperty(final String name, final Object value) { if (properties == null) properties = new Properties(); properties.put(name, value); } public void setUser(String user) { setProperty("user", user); } public void setPassword(String password) { setProperty("password", password); } public String getURL() throws SQLException { if (this.url == null) { this.url = getConnection().getMetaData().getURL(); } return (this.url); } public void setURL(final String url) { this.url = url; } /** * Factory method for creating an EsqlQuery object. If type is set to * "" or "auto" it will try to find type from the JDBC connection URL. * If this does not succeed the generic JDBC type will be assumed. * (This type does not work for some databases like mssql though) * * @param type {sybase|postgresql|mysql|oracle|jdbc} * @param queryString * @return implementation of the AbstractEsqlQuery * @throws SQLException */ public AbstractEsqlQuery createQuery(final String type, final String queryString) throws SQLException { AbstractEsqlQuery query; if ("".equals(type) || "auto".equalsIgnoreCase(type)) { String url = getURL(); if (url.startsWith("jdbc:postgresql:")) { query = new PostgresEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:mysql:")) { query = new MysqlEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:sybase:")) { query = new SybaseEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:oracle:")) { query = new OracleEsqlQuery(this,queryString); } else { getLogger().warn("Cannot guess database type from jdbc url: " + String.valueOf(url) +" - Defaulting to JDBC"); query = new JdbcEsqlQuery(this,queryString); } } else if ("sybase".equalsIgnoreCase(type)) { query = new SybaseEsqlQuery(this,queryString); } else if ("postgresql".equalsIgnoreCase(type)) { query = new PostgresEsqlQuery(this,queryString); } else if ("postgresql-old".equalsIgnoreCase(type)) { query = new PostgresOldEsqlQuery(this,queryString); } else if ("mysql".equalsIgnoreCase(type)) { query = new MysqlEsqlQuery(this,queryString); } else if ("oracle".equalsIgnoreCase(type)) { query = new OracleEsqlQuery(this,queryString); } else if ("jdbc".equalsIgnoreCase(type)) { query = new JdbcEsqlQuery(this,queryString); } else { getLogger().error("Unknown database type: " + String.valueOf(type)); throw new SQLException("Unknown database type: " + String.valueOf(type)); } setupLogger(query); return(query); } /* just wrap methods below */ public java.sql.Statement createStatement() throws SQLException { return (getConnection().createStatement()); } public java.sql.Statement createStatement(int i1, int i2) throws SQLException { return (getConnection().createStatement(i1, i2)); } public java.sql.PreparedStatement prepareStatement(String s) throws SQLException { return (getConnection().prepareStatement(s)); } public java.sql.PreparedStatement prepareStatement(String s, int i1, int i2) throws SQLException { return (getConnection().prepareStatement(s, i1, i2)); } public void close() throws SQLException { getConnection().close(); } public void commit() throws SQLException { getConnection().commit(); } public void rollback() throws SQLException { getConnection().rollback(); } public boolean getAutoCommit() throws SQLException { return (getConnection().getAutoCommit()); } public void setAutoCommit(boolean autocommit) throws SQLException { getConnection().setAutoCommit(autocommit); } public void setTransactionIsolation(int i) throws SQLException { getConnection().setTransactionIsolation(i); } public int getTransactionIsolation() throws SQLException { return (getConnection().getTransactionIsolation()); } public String getCatalog() throws SQLException { return (getConnection().getCatalog()); } public java.sql.SQLWarning getWarnings() throws SQLException { return (getConnection().getWarnings()); } public java.util.Map getTypeMap() throws SQLException { return (getConnection().getTypeMap()); } public boolean isClosed() throws SQLException { return (getConnection().isClosed()); } public java.sql.DatabaseMetaData getMetaData() throws SQLException { return (getConnection().getMetaData()); } public void setCatalog(String s) throws SQLException { getConnection().setCatalog(s); } public void setTypeMap(java.util.Map m) throws SQLException { getConnection().setTypeMap(m); } public void setReadOnly(boolean b) throws SQLException { getConnection().setReadOnly(b); } public void clearWarnings() throws SQLException { getConnection().clearWarnings(); } public boolean isReadOnly() throws SQLException { return (getConnection().isReadOnly()); } public String nativeSQL(String s) throws SQLException { return (getConnection().nativeSQL(s)); } public java.sql.CallableStatement prepareCall(String s) throws SQLException { return (getConnection().prepareCall(s)); } public java.sql.CallableStatement prepareCall(String s, int i1, int i2) throws SQLException { return (getConnection().prepareCall(s, i1, i2)); } public void setHoldability(int holdability) throws SQLException { getConnection().setHoldability(holdability); } public int getHoldability() throws SQLException { return getConnection().getHoldability(); } public java.sql.Savepoint setSavepoint() throws SQLException { return getConnection().setSavepoint(); } public java.sql.Savepoint setSavepoint(String savepoint) throws SQLException { return getConnection().setSavepoint(savepoint); } public void rollback(java.sql.Savepoint savepoint) throws SQLException { getConnection().rollback(savepoint); } public void releaseSavepoint(java.sql.Savepoint savepoint) throws SQLException { getConnection().releaseSavepoint(savepoint); } public java.sql.Statement createStatement(int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().createStatement(resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.PreparedStatement prepareStatement(String sql, int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().prepareStatement(sql, resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.CallableStatement prepareCall(String sql, int resulSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { return getConnection().prepareCall(sql, resulSetType, resultSetConcurrency, resultSetHoldability); } public java.sql.PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { return getConnection().prepareStatement(sql, autoGeneratedKeys); } public java.sql.PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { return getConnection().prepareStatement(sql, columnIndexes); } public java.sql.PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { return getConnection().prepareStatement(sql, columnNames); } } 1.2 +1 -13 xml-cocoon2/src/blocks/databases/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/src/blocks/databases/build.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- build.xml 20 Feb 2003 20:25:35 -0000 1.1 +++ build.xml 26 Feb 2003 10:47:40 -0000 1.2 @@ -1,6 +1,6 @@ <project default="main" basedir="."> - <target name="main" depends="prepare-jdbc, prepare-database-connection"/> + <target name="main" depends="prepare-database-connection"/> <target name="prepare-database-connection" depends="prepare-database-connection-pw,prepare-database-connection-no-pw"> <filter token="db_driver" value="${webapp.samples.database.driver}"/> @@ -14,18 +14,6 @@ <target name="prepare-database-connection-no-pw" unless="webapp.samples.database.password"> <filter token="db_password" value=""/> - </target> - - <target name="prepare-jdbc" depends="filter-jdbc,nofilter-jdbc"/> - - <target name="filter-jdbc" unless="jdbc3.present"> - <filter token="JDBC3_START" value="${line.separator} /* Start JDBC3 specific code "/> - <filter token="JDBC3_END" value=" End JDBC3 specific code */"/> - </target> - - <target name="nofilter-jdbc" if="jdbc3.present"> - <filter token="JDBC3_START" value="Start JDBC3 specific code"/> - <filter token="JDBC3_END" value="End JDBC3 specific code"/> </target> </project> 1.1 xml-cocoon2/src/blocks/databases/java1.2/org/apache/cocoon/components/language/markup/xsp/AbstractEsqlConnection.java Index: AbstractEsqlConnection.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.language.markup.xsp; import org.apache.avalon.framework.logger.AbstractLogEnabled; import java.sql.Connection; import java.util.Properties; import java.sql.SQLException; /** * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> */ public abstract class AbstractEsqlConnection extends AbstractLogEnabled implements Connection { private String url = null; private Properties properties = null; private boolean multipleResults = false; protected AbstractEsqlConnection() { } protected abstract Connection getConnection() throws SQLException; /** * It appears that some commercial DBMSs like Oracle and Informix * are broken in that they don't follow the JDBC standard and * calls to getUpdateCount after getMoreResults result either in * an exception (Informix) or return the same value (i.e. not -1) (Oracle). * In addition, this feature is only useful with stored procedures. * Hence we disable it per default. **/ public void setMultipleResults(String value) { this.multipleResults = ("true".equalsIgnoreCase(value) || "yes".equalsIgnoreCase(value)); } public boolean getMultipleResults() { return (this.multipleResults); } public Properties getProperties() { return (properties); } public void setProperty(final String name, final Object value) { if (properties == null) properties = new Properties(); properties.put(name, value); } public void setUser(String user) { setProperty("user", user); } public void setPassword(String password) { setProperty("password", password); } public String getURL() throws SQLException { if (this.url == null) { this.url = getConnection().getMetaData().getURL(); } return (this.url); } public void setURL(final String url) { this.url = url; } /** * Factory method for creating an EsqlQuery object. If type is set to * "" or "auto" it will try to find type from the JDBC connection URL. * If this does not succeed the generic JDBC type will be assumed. * (This type does not work for some databases like mssql though) * * @param type {sybase|postgresql|mysql|oracle|jdbc} * @param queryString * @return implementation of the AbstractEsqlQuery * @throws SQLException */ public AbstractEsqlQuery createQuery(final String type, final String queryString) throws SQLException { AbstractEsqlQuery query; if ("".equals(type) || "auto".equalsIgnoreCase(type)) { String url = getURL(); if (url.startsWith("jdbc:postgresql:")) { query = new PostgresEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:mysql:")) { query = new MysqlEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:sybase:")) { query = new SybaseEsqlQuery(this,queryString); } else if (url.startsWith("jdbc:oracle:")) { query = new OracleEsqlQuery(this,queryString); } else { getLogger().warn("Cannot guess database type from jdbc url: " + String.valueOf(url) +" - Defaulting to JDBC"); query = new JdbcEsqlQuery(this,queryString); } } else if ("sybase".equalsIgnoreCase(type)) { query = new SybaseEsqlQuery(this,queryString); } else if ("postgresql".equalsIgnoreCase(type)) { query = new PostgresEsqlQuery(this,queryString); } else if ("postgresql-old".equalsIgnoreCase(type)) { query = new PostgresOldEsqlQuery(this,queryString); } else if ("mysql".equalsIgnoreCase(type)) { query = new MysqlEsqlQuery(this,queryString); } else if ("oracle".equalsIgnoreCase(type)) { query = new OracleEsqlQuery(this,queryString); } else if ("jdbc".equalsIgnoreCase(type)) { query = new JdbcEsqlQuery(this,queryString); } else { getLogger().error("Unknown database type: " + String.valueOf(type)); throw new SQLException("Unknown database type: " + String.valueOf(type)); } setupLogger(query); return(query); } /* just wrap methods below */ public java.sql.Statement createStatement() throws SQLException { return (getConnection().createStatement()); } public java.sql.Statement createStatement(int i1, int i2) throws SQLException { return (getConnection().createStatement(i1, i2)); } public java.sql.PreparedStatement prepareStatement(String s) throws SQLException { return (getConnection().prepareStatement(s)); } public java.sql.PreparedStatement prepareStatement(String s, int i1, int i2) throws SQLException { return (getConnection().prepareStatement(s, i1, i2)); } public void close() throws SQLException { getConnection().close(); } public void commit() throws SQLException { getConnection().commit(); } public void rollback() throws SQLException { getConnection().rollback(); } public boolean getAutoCommit() throws SQLException { return (getConnection().getAutoCommit()); } public void setAutoCommit(boolean autocommit) throws SQLException { getConnection().setAutoCommit(autocommit); } public void setTransactionIsolation(int i) throws SQLException { getConnection().setTransactionIsolation(i); } public int getTransactionIsolation() throws SQLException { return (getConnection().getTransactionIsolation()); } public String getCatalog() throws SQLException { return (getConnection().getCatalog()); } public java.sql.SQLWarning getWarnings() throws SQLException { return (getConnection().getWarnings()); } public java.util.Map getTypeMap() throws SQLException { return (getConnection().getTypeMap()); } public boolean isClosed() throws SQLException { return (getConnection().isClosed()); } public java.sql.DatabaseMetaData getMetaData() throws SQLException { return (getConnection().getMetaData()); } public void setCatalog(String s) throws SQLException { getConnection().setCatalog(s); } public void setTypeMap(java.util.Map m) throws SQLException { getConnection().setTypeMap(m); } public void setReadOnly(boolean b) throws SQLException { getConnection().setReadOnly(b); } public void clearWarnings() throws SQLException { getConnection().clearWarnings(); } public boolean isReadOnly() throws SQLException { return (getConnection().isReadOnly()); } public String nativeSQL(String s) throws SQLException { return (getConnection().nativeSQL(s)); } public java.sql.CallableStatement prepareCall(String s) throws SQLException { return (getConnection().prepareCall(s)); } public java.sql.CallableStatement prepareCall(String s, int i1, int i2) throws SQLException { return (getConnection().prepareCall(s, i1, i2)); } }