FileDocCategorySizeDatePackage
SetDataSourceTagSupport.javaAPI DocGlassfish v2 API4949Sat May 05 19:17:54 BST 2007org.apache.taglibs.standard.tag.common.sql

SetDataSourceTagSupport

public class SetDataSourceTagSupport extends javax.servlet.jsp.tagext.TagSupport

Tag handler for <SetDataSource> in JSTL, used to create a simple DataSource for prototyping.

author
Hans Bergsten
author
Justyna Horwat

Fields Summary
protected Object
dataSource
protected boolean
dataSourceSpecified
protected String
jdbcURL
protected String
driverClassName
protected String
userName
protected String
password
private int
scope
private String
var
Constructors Summary
public SetDataSourceTagSupport()

	super();
	init();
    
Methods Summary
public intdoStartTag()

        DataSource ds;

        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
                if (driverClassName != null) {
                    dsw.setDriverClassName(driverClassName);
                }
            }
            catch (Exception e) {
                throw new JspTagException(
                    Resources.getMessage("DRIVER_INVALID_CLASS",
					 e.toString()), e);
            }
            dsw.setJdbcURL(jdbcURL);
            dsw.setUserName(userName);
            dsw.setPassword(password);
	    ds = (DataSource) dsw;
        }

        if (var != null) {
	    pageContext.setAttribute(var, ds, scope);
        } else {
            Config.set(pageContext, Config.SQL_DATA_SOURCE, ds, scope);
        }

	return SKIP_BODY;
    
private voidinit()

	dataSource = null;
	dataSourceSpecified = false;
	jdbcURL = driverClassName = userName = password = null;
	var = null;
	scope = PageContext.PAGE_SCOPE;
    
public voidrelease()

	init();
    
public voidsetScope(java.lang.String scope)
Setter method for the scope of the variable to hold the result.

        this.scope = Util.getScope(scope);
    
public voidsetVar(java.lang.String var)

	this.var = var;