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/rt/sql SetDataSourceTag.java TransactionTag.java
Date Wed, 24 Apr 2002 22:14:25 GMT
luehe       02/04/24 15:14:25

  Modified:    standard/src/org/apache/taglibs/standard/resources
                        Resources.properties
               standard/src/org/apache/taglibs/standard/tag/common/sql
                        DataSourceUtil.java QueryTagSupport.java
                        SetDataSourceTagSupport.java
                        TransactionTagSupport.java UpdateTagSupport.java
               standard/src/org/apache/taglibs/standard/tag/el/sql
                        SetDataSourceTag.java TransactionTag.java
               standard/src/org/apache/taglibs/standard/tag/rt/sql
                        SetDataSourceTag.java TransactionTag.java
  Log:
  <sql:setDataSource>, <sql:transaction>, <sql:query>, and <sql:update>
  now all throw a JspException if 'dataSource' is specified but null
  (this is being added to the "Null & Error Handling" section of these
  actions).
  
  Revision  Changes    Path
  1.30      +4 -1      jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/resources/Resources.properties,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Resources.properties	23 Apr 2002 17:41:54 -0000	1.29
  +++ Resources.properties	24 Apr 2002 22:14:24 -0000	1.30
  @@ -202,8 +202,11 @@
   SQL_PROCESS_ERROR=\
       Error processing SQL: "{0}"
   
  -SQL_DATASOURCE_INVALID=\
  +SQL_DATASOURCE_INVALID_TYPE=\
       'dataSource' is neither a String nor a javax.sql.DataSource
  +
  +SQL_DATASOURCE_NULL=\
  +    'dataSource' is null
   
   SQL_MAXROWS_PARSE_ERROR=\
       Error parsing 'javax.servlet.jsp.jstl.sql.maxRows' configuration setting: "{0}"
  
  
  
  1.9       +1 -1      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DataSourceUtil.java	24 Apr 2002 01:16:31 -0000	1.8
  +++ DataSourceUtil.java	24 Apr 2002 22:14:24 -0000	1.9
  @@ -114,7 +114,7 @@
               dataSource = (DataSource) rawDataSource;
           } else {
   	    throw new JspException(
  -                Resources.getMessage("SQL_DATASOURCE_INVALID"));
  +                Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE"));
   	}
   
   	return dataSource;
  
  
  
  1.28      +14 -5     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java
  
  Index: QueryTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/QueryTagSupport.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- QueryTagSupport.java	24 Apr 2002 18:41:25 -0000	1.27
  +++ QueryTagSupport.java	24 Apr 2002 22:14:24 -0000	1.28
  @@ -112,10 +112,16 @@
       }
   
       private void init() {
  -        scope = PageContext.PAGE_SCOPE;
           startRow = 0;
           maxRows = -1;
   	maxRowsSpecified = dataSourceSpecified = false;
  +	isPartOfTransaction = false;
  +	conn = null;
  +	rawDataSource = null;
  +	parameters = null;
  +	sql = null;
  +	var = null;
  +        scope = PageContext.PAGE_SCOPE;
       }
   
   
  @@ -267,11 +273,8 @@
   	    } catch (SQLException e) {} // Not much we can do
   	}
   
  -	// Reset the per-invokation state.
  -	parameters = null;
  -	isPartOfTransaction = false;
   	conn = null;
  -        rawDataSource = null;
  +	parameters = null;
       }
   
   
  @@ -281,6 +284,8 @@
       private Connection getConnection() throws JspException, SQLException {
   	// Fix: Add all other mechanisms
   	Connection conn = null;
  +	isPartOfTransaction = false;
  +
   	TransactionTagSupport parent = (TransactionTagSupport) 
   	    findAncestorWithClass(this, TransactionTagSupport.class);
   	if (parent != null) {
  @@ -291,6 +296,10 @@
   	    conn = parent.getSharedConnection();
               isPartOfTransaction = true;
   	} else {
  +	    if ((rawDataSource == null) && dataSourceSpecified) {
  +		throw new JspException(
  +		    Resources.getMessage("SQL_DATASOURCE_NULL"));
  +	    }
   	    DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource,
   								 pageContext);
               try {
  
  
  
  1.9       +31 -1     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SetDataSourceTagSupport.java	24 Apr 2002 01:16:31 -0000	1.8
  +++ SetDataSourceTagSupport.java	24 Apr 2002 22:14:24 -0000	1.9
  @@ -76,14 +76,33 @@
   public class SetDataSourceTagSupport extends TagSupport {
   
       protected Object dataSource;
  +    protected boolean dataSourceSpecified;
       protected String jdbcURL;
       protected String driverClassName;
       protected String userName;
       protected String password;
   
  -    private int scope = PageContext.PAGE_SCOPE;
  +    private int scope;
       private String var;
   
  +
  +    //*********************************************************************
  +    // Constructor and initialization
  +
  +    public SetDataSourceTagSupport() {
  +	super();
  +	init();
  +    }
  +
  +    private void init() {
  +	dataSource = null;
  +	dataSourceSpecified = false;
  +	jdbcURL = driverClassName = userName = password = null;
  +	var = null;
  +	scope = PageContext.PAGE_SCOPE;
  +    }
  +
  +
       //*********************************************************************
       // Accessor methods
   
  @@ -100,6 +119,7 @@
   	this.var = var;
       }
   
  +
       //*********************************************************************
       // Tag logic
   
  @@ -109,6 +129,11 @@
           if (dataSource != null) {
               ds = DataSourceUtil.getDataSource(dataSource, pageContext);
           } else {
  +	    if (dataSourceSpecified) {
  +		throw new JspException(
  +                    Resources.getMessage("SQL_DATASOURCE_NULL"));
  +	    }
  +
               DataSourceWrapper dsw = new DataSourceWrapper();
               try {
                   // set driver class iff provided by the tag
  @@ -134,5 +159,10 @@
           }
   
   	return SKIP_BODY;
  +    }
  +
  +    // Releases any resources we may have (or inherit)
  +    public void release() {
  +	init();
       }
   }
  
  
  
  1.11      +9 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java
  
  Index: TransactionTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/TransactionTagSupport.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TransactionTagSupport.java	24 Apr 2002 01:16:31 -0000	1.10
  +++ TransactionTagSupport.java	24 Apr 2002 22:14:24 -0000	1.11
  @@ -96,6 +96,7 @@
   
       protected Object rawDataSource;
       protected DataSource dataSource;
  +    protected boolean dataSourceSpecified;
   
   
       //*********************************************************************
  @@ -116,6 +117,9 @@
   
       private void init() {
   	conn = null;
  +	dataSource = null;
  +	dataSourceSpecified = false;
  +	rawDataSource = null;
   	isolation = Connection.TRANSACTION_NONE;
       }
   
  @@ -129,6 +133,11 @@
        * the transaction.
        */
       public int doStartTag() throws JspException {
  +
  +	if ((rawDataSource == null) && dataSourceSpecified) {
  +	    throw new JspException(
  +                Resources.getMessage("SQL_DATASOURCE_NULL"));
  +	}
   
           dataSource = DataSourceUtil.getDataSource(rawDataSource, pageContext);
   
  
  
  
  1.19      +15 -6     jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java
  
  Index: UpdateTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/common/sql/UpdateTagSupport.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- UpdateTagSupport.java	24 Apr 2002 18:41:25 -0000	1.18
  +++ UpdateTagSupport.java	24 Apr 2002 22:14:24 -0000	1.19
  @@ -108,8 +108,13 @@
       }
   
       private void init() {
  +	rawDataSource = null;
  +	sql = null;
  +	conn = null;
  +	parameters = null;
  +	isPartOfTransaction = dataSourceSpecified = false;
           scope = PageContext.PAGE_SCOPE;
  -	dataSourceSpecified = false;
  +	var = null;
       }
   
   
  @@ -210,15 +215,13 @@
   	if (conn != null && !isPartOfTransaction) {
   	    try {
   		conn.close();
  -	    } catch (SQLException e) {} // Not much we can do
  +	    } catch (SQLException e) {
  +		// Not much we can do
  +	    }
   	}
   
  -	// Reset the per-invokation state.
   	parameters = null;
  -	isPartOfTransaction = false;
   	conn = null;
  -        bodyContent = null;
  -        rawDataSource = null;
       }
   
   
  @@ -243,6 +246,8 @@
       private Connection getConnection() throws JspException, SQLException {
   	// Fix: Add all other mechanisms
   	Connection conn = null;
  +	isPartOfTransaction = false;
  +
   	TransactionTagSupport parent = (TransactionTagSupport) 
   	    findAncestorWithClass(this, TransactionTagSupport.class);
   	if (parent != null) {
  @@ -253,6 +258,10 @@
   	    conn = parent.getSharedConnection();
               isPartOfTransaction = true;
   	} else {
  +	    if ((rawDataSource == null) && dataSourceSpecified) {
  +		throw new JspException(
  +		    Resources.getMessage("SQL_DATASOURCE_NULL"));
  +	    }
   	    DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource,
   								 pageContext);
               try {
  
  
  
  1.3       +1 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/SetDataSourceTag.java
  
  Index: SetDataSourceTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/SetDataSourceTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SetDataSourceTag.java	19 Apr 2002 00:40:49 -0000	1.2
  +++ SetDataSourceTag.java	24 Apr 2002 22:14:25 -0000	1.3
  @@ -77,6 +77,7 @@
   
       public void setDataSource(String dataSourceEL) {
   	this.dataSourceEL = dataSourceEL;
  +	this.dataSourceSpecified = true;
       }
   
       public void setDriver(String driverClassNameEL) {
  
  
  
  1.5       +1 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/TransactionTag.java
  
  Index: TransactionTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/el/sql/TransactionTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TransactionTag.java	11 Apr 2002 00:46:25 -0000	1.4
  +++ TransactionTag.java	24 Apr 2002 22:14:25 -0000	1.5
  @@ -72,6 +72,7 @@
   
       public void setDataSource(String dataSourceEL) {
   	this.dataSourceEL = dataSourceEL;
  +	this.dataSourceSpecified = true;
       }
   
       public void setIsolation(String isolationEL) {
  
  
  
  1.2       +1 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/SetDataSourceTag.java
  
  Index: SetDataSourceTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/SetDataSourceTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetDataSourceTag.java	16 Apr 2002 00:01:34 -0000	1.1
  +++ SetDataSourceTag.java	24 Apr 2002 22:14:25 -0000	1.2
  @@ -69,6 +69,7 @@
   
       public void setDataSource(Object dataSource) {
   	this.dataSource = dataSource;
  +	this.dataSourceSpecified = true;
       }
   
       public void setDriver(String driverClassName) {
  
  
  
  1.5       +1 -0      jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/TransactionTag.java
  
  Index: TransactionTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/standard/src/org/apache/taglibs/standard/tag/rt/sql/TransactionTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TransactionTag.java	18 Apr 2002 15:27:41 -0000	1.4
  +++ TransactionTag.java	24 Apr 2002 22:14:25 -0000	1.5
  @@ -76,6 +76,7 @@
        */
       public void setDataSource(Object dataSource) {
   	this.rawDataSource = dataSource;
  +	this.dataSourceSpecified = true;
       }
   
       /**
  
  
  

--
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