jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu...@apache.org
Subject cvs commit: jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql DataSourceUtil.java SetDataSourceTagSupport.java
Date Fri, 19 Apr 2002 17:17:34 GMT
luehe       02/04/19 10:17:34

  Modified:    standard/src/org/apache/taglibs/standard/tag/common/sql
                        DataSourceUtil.java SetDataSourceTagSupport.java
  Log:
  Fixed 8283: Providing a javax.sql.DataSource object to the datasource
  attribute of the setDataSource action fails:
  
  - Applied Ryan's patch (thanks, Ryan!)
  - Also removed DataSourceUtil constructor, in which a
    DataSourceWrapper was allocated. This was out-of-date, since the
    wrapper now is allocated inside setUsingParams().
  
  Revision  Changes    Path
  1.6       +14 -19    jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DataSourceUtil.java
  
  Index: DataSourceUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/DataSourceUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DataSourceUtil.java	19 Apr 2002 02:25:32 -0000	1.5
  +++ DataSourceUtil.java	19 Apr 2002 17:17:34 -0000	1.6
  @@ -79,29 +79,25 @@
       private DataSource dataSource;
       private boolean hasDataSourceAttribute = false;
   
  -    DataSourceUtil() {
  -        dataSource = new DataSourceWrapper();
  -    }
  -
       public DataSource getDataSource() {
           return dataSource;
       }
   
       /**
        * Useful for Transaction nesting check
  -     **/
  +     */
       public boolean hasDataSourceAttribute() {
           return hasDataSourceAttribute;
       }
   
       /**
  -     *
        * If dataSource is a String first do JNDI lookup
        * If lookup fails parse String like it was a set of JDBC parameters
  -     * Otherwise check to see if dataSource is a DataSource object and use as is
  -     *
  -     **/
  -    public void setDataSource(Object rawDataSource, PageContext pageContext) throws JspException
{
  +     * Otherwise check to see if dataSource is a DataSource object and use as
  +     * is
  +     */
  +    public void setDataSource(Object rawDataSource,
  +			      PageContext pageContext) throws JspException {
   
           if (rawDataSource == null) {
               rawDataSource = Config.find(pageContext, Config.SQL_DATASOURCE);
  @@ -132,12 +128,10 @@
       }
   
       /**
  -     *
        * Parse JDBC parameters and setup dataSource appropriately
  -     *
  -     **/
  +     */
       private void setUsingParams(String params) throws JspException {
  -        dataSource = (DataSource) new DataSourceWrapper();
  +        dataSource = new DataSourceWrapper();
   
           String[] paramString = new String[4];
           int escCount = 0; 
  @@ -166,21 +160,22 @@
           paramString[aryCount] = params.substring(begin);
   
   	// use the JDBC URL from the parameter string
  -        ((DataSourceWrapper)dataSource).setJdbcURL(paramString[0]);
  +        ((DataSourceWrapper) dataSource).setJdbcURL(paramString[0]);
   
   	// try to load a driver if it's present
           if (paramString[1] != null) {
               try {
  -                ((DataSourceWrapper)dataSource).setDriverClassName(paramString[1]);
  +                ((DataSourceWrapper) dataSource).setDriverClassName(paramString[1]);
               } catch (Exception ex) {
                   throw new JspTagException(
  -                    Resources.getMessage("DRIVER_INVALID_CLASS", ex.getMessage()));
  +                    Resources.getMessage("DRIVER_INVALID_CLASS",
  +					 ex.getMessage()));
               }
   	}
   
   	// set the username and password
  -        ((DataSourceWrapper)dataSource).setUserName(paramString[2]);
  -        ((DataSourceWrapper)dataSource).setPassword(paramString[3]);
  +        ((DataSourceWrapper) dataSource).setUserName(paramString[2]);
  +        ((DataSourceWrapper) dataSource).setPassword(paramString[3]);
       }
   
   }
  
  
  
  1.5       +11 -8     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/SetDataSourceTagSupport.java
  
  Index: SetDataSourceTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/SetDataSourceTagSupport.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SetDataSourceTagSupport.java	16 Apr 2002 18:15:40 -0000	1.4
  +++ SetDataSourceTagSupport.java	19 Apr 2002 17:17:34 -0000	1.5
  @@ -56,6 +56,7 @@
   package org.apache.taglibs.standard.tag.common.sql;
   
   import java.util.*;
  +import javax.sql.DataSource;
   import javax.servlet.*;
   import javax.servlet.jsp.*;
   import javax.servlet.jsp.jstl.sql.*;
  @@ -103,28 +104,30 @@
       // Tag logic
   
       public int doStartTag() throws JspException {
  -        DataSourceWrapper ds;
  +        DataSource ds;
   
           if (dataSource != null) {
               DataSourceUtil dsUtil = new DataSourceUtil();
               dsUtil.setDataSource(dataSource, pageContext);
  -            ds = (DataSourceWrapper) dsUtil.getDataSource();
  +            ds = dsUtil.getDataSource();
           }
           else {
  -            ds = new DataSourceWrapper();
  +            DataSourceWrapper dsw = new DataSourceWrapper();
               try {
                   // set driver class iff provided by the tag
                   if (driverClassName != null) {
  -                    ds.setDriverClassName(driverClassName);
  +                    dsw.setDriverClassName(driverClassName);
                   }
               }
               catch (Exception e) {
                   throw new JspTagException(
  -                    Resources.getMessage("DRIVER_INVALID_CLASS", e.getMessage()));
  +                    Resources.getMessage("DRIVER_INVALID_CLASS",
  +					 e.getMessage()));
               }
  -            ds.setJdbcURL(jdbcURL);
  -            ds.setUserName(userName);
  -            ds.setPassword(password);
  +            dsw.setJdbcURL(jdbcURL);
  +            dsw.setUserName(userName);
  +            dsw.setPassword(password);
  +	    ds = (DataSource) dsw;
           }
   
           if (var != null) {
  
  
  

--
To unsubscribe, e-mail:   <mailto:taglibs-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:taglibs-dev-help@jakarta.apache.org>


Mime
View raw message