Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.JellyException


    //-------------------------------------------------------------------------
    /** By default just evaluate the body */
    public void doTag(XMLOutput output) throws Exception {
        StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class );
        if (tag == null) {
            throw new JellyException(
                "<applyTemplates> tag must be inside a <stylesheet> tag"
            );
        }
        Stylesheet stylesheet = tag.getStylesheet();               
        Object source = tag.getXPathSource();
View Full Code Here


        if (dataSource != null) {
            ds = DataSourceUtil.getDataSource(dataSource, context);
        }
        else {
            if (dataSourceSpecified) {
                throw new JellyException(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) {
                log.error( "Could not load driver class: " + e, e );
                throw new JellyException(
                    Resources.getMessage("DRIVER_INVALID_CLASS", e.getMessage()));
            }
            dsw.setJdbcURL(jdbcURL);
            dsw.setUserName(userName);
            dsw.setPassword(password);
View Full Code Here

     * the transaction.
     */
    public void doTag(XMLOutput output) throws Exception {

        if ((rawDataSource == null) && dataSourceSpecified) {
            throw new JellyException(Resources.getMessage("SQL_DATASOURCE_NULL"));
        }

        DataSource dataSource = DataSourceUtil.getDataSource(rawDataSource, context);

        try {
            conn = dataSource.getConnection();
            origIsolation = conn.getTransactionIsolation();
            if (origIsolation == Connection.TRANSACTION_NONE) {
                throw new JellyException(Resources.getMessage("TRANSACTION_NO_SUPPORT"));
            }
            if ((isolation != Connection.TRANSACTION_NONE)
                && (isolation != origIsolation)) {
                conn.setTransactionIsolation(isolation);
            }
            conn.setAutoCommit(false);
        }
        catch (SQLException e) {
            throw new JellyException(
                Resources.getMessage("ERROR_GET_CONNECTION", e.getMessage()));
        }

        boolean finished = false;
        try {
            invokeBody(output);
            finished = true;
        }
        catch (Exception e) {
            if (conn != null) {
                try {
                    conn.rollback();
                }
                catch (SQLException s) {
                    // Ignore to not hide orignal exception
                }
                doFinally();
            }
            throw e;
        }

        // lets commit         
        try {
            conn.commit();
        }
        catch (SQLException e) {
            throw new JellyException(
                Resources.getMessage("TRANSACTION_COMMIT_ERROR", e.getMessage()));
        }
        finally {
            doFinally();
        }
View Full Code Here

        }
        else if (TRANSACTION_SERIALIZABLE.equals(iso)) {
            isolation = Connection.TRANSACTION_SERIALIZABLE;
        }
        else {
            throw new JellyException(Resources.getMessage("TRANSACTION_INVALID_ISOLATION"));
        }
    }
View Full Code Here

   
    // Tag interface
    //-------------------------------------------------------------------------                   
    public void doTag(XMLOutput output) throws Exception {
        if ( var == null ) {
            throw new JellyException( "<define:script> must have a var attribute" );
        }
        context.setVariable( var, getBody() );
    }   
View Full Code Here

        }
        else if (rawDataSource instanceof DataSource) {
            dataSource = (DataSource) rawDataSource;
        }
        else {
            throw new JellyException(Resources.getMessage("SQL_DATASOURCE_INVALID_TYPE"));
        }

        return dataSource;
    }
View Full Code Here

            if (TOKEN.indexOf(nextChar) != -1) {
                if (escCount == 0) {
                    paramString[aryCount] = params.substring(begin, index);
                    begin = index + 1;
                    if (++aryCount > 4) {
                        throw new JellyException(Resources.getMessage("JDBC_PARAM_COUNT"));
                    }
                }
            }
            if (ESCAPE.indexOf(nextChar) != -1) {
                escCount++;
            }
            else {
                escCount = 0;
            }
        }
        paramString[aryCount] = params.substring(begin);

        // use the JDBC URL from the parameter string
        dataSource.setJdbcURL(paramString[0]);

        // try to load a driver if it's present
        if (paramString[1] != null) {
            try {
                dataSource.setDriverClassName(paramString[1]);
            }
            catch (Exception ex) {
                throw new JellyException(
                    Resources.getMessage("DRIVER_INVALID_CLASS", ex.getMessage()));
            }
        }

        // set the username and password
View Full Code Here

    // Tag interface
    //-------------------------------------------------------------------------                   
    public void doTag(XMLOutput output) throws Exception {
        BeanTag tag = (BeanTag) findAncestorWithClass( BeanTag.class );
        if ( tag == null ) {
            throw new JellyException( "This tag should be nested inside a <define:bean> or <define:jellybean> tag" );
        }

        tag.addAttribute( attribute );       
    }
View Full Code Here

    public void doTag(XMLOutput output) throws Exception {
        SQLExecutionTag parent =
            (SQLExecutionTag) findAncestorWithClass(this, SQLExecutionTag.class);
        if (parent == null) {
            throw new JellyException(Resources.getMessage("SQL_PARAM_OUTSIDE_PARENT"));
        }

        Object paramValue = value;
        if (value != null) {
            paramValue = value;
View Full Code Here

        else {
            // note this mechanism does not work properly for arbitrarily
            // nested dynamic tags. A better way is required.
            Tag tag = findAncestorWithClass(this, DynamicTag.class);
            if (tag == null) {
                throw new JellyException("Cannot invoke body, no dynamic tag is defined in this block");
            }
            else {
                tag.invokeBody(output);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.JellyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.