Package org.apache.beehive.controls.api

Examples of org.apache.beehive.controls.api.ControlException


                    URL url = new URL(_jndiName);
                    jndiConn = url.openConnection();
                    _homeInstance = jndiConn.getContent();
                }
                catch (MalformedURLException mue) {
                    throw new ControlException(_jndiName + " is not a valid JNDI URL", mue);
                }
                catch (IOException ioe) {
                    throw new ControlException("Error during JNDI lookup from " + _jndiName, ioe);
                }
            }
            else {
                try {
                    javax.naming.Context ctx = getInitialContext();
                    _homeInstance = ctx.lookup(_jndiName);
                }
                catch (Exception ne) {
                    throw new ControlException("Error during JNDI lookup from " + _jndiName, ne);
                }
            }

            if (!_homeInterface.isAssignableFrom(_homeInstance.getClass())) {
                throw new ControlException("JNDI lookup of " + _jndiName + " failed to return an instance of " + _homeInterface);
            }
        }
    }
View Full Code Here


            // By convention, the below cond should never be true.  The bean
            // type-specific resolve should throw an appropriate exception
            // that is more specific.  This is a safety net.
            if (_beanInstance == null)
                throw new ControlException("Unable to resolve bean instance");

            try {
                return m.invoke(_beanInstance, args);
            }
            catch (Exception e) {
View Full Code Here

                //
                // Spring doesn't provide any mechanism to pass dynamic constructor args
                // to Spring bean factory methods.
                //
                if (props != null)
                    throw new ControlException("Providing a PropertyMap to the bean constructor is not supported by SpringControlFactory");
            }
            else
            {
                //
                // Fall back to using standard Java instantation if no Spring configuration
                // could be found.
                // TODO: Have a configuration option where this results in a failure, to avoid
                // masking misconfiguration issues if the expectation is that all usage of
                // Controls is configured via Spring.
                //
                bean = super.instantiate(beanClass, props, context, id);
            }
        }
        catch (Exception e)
        {
            throw new ControlException("Exception creating ControlBean", e);
        }

        return bean;
    }
View Full Code Here

        // cache the Map.get method for efficiency
        try {
            _methodMapGet = java.util.Map.class.getMethod("get", new Class[]{Object.class});
        } catch (NoSuchMethodException e) {
            throw new ControlException("Can not find java.util.Map.get(Object) method");
        }
    }
View Full Code Here

        SqlGrammar _parser = new SqlGrammar(new StringReader(sql));
        SqlStatement parsed = null;
        try {
            parsed = _parser.parse();
        } catch (ParseException e) {
            throw new ControlException("Error parsing SQL statment." + e.getMessage(), e);
        } catch (TokenMgrError tme) {
            throw new ControlException("Error parsing SQL statment. " + tme.getMessage(), tme);
        }

        if (parsed.isCacheable()) {
            _cachedSqlStatements.put(sql, parsed);
        }
View Full Code Here

                }

                return RowMapperFactory.getRowMapper(resultSet, returnType, cal).mapRowToReturnType();
            }
        } catch (SQLException e) {
            throw new ControlException(e.getMessage(), e);
        }
    }
View Full Code Here

                    return _tmf.fixNull(m.getReturnType());
                }
                return RowMapperFactory.getRowMapper(resultSet, returnType, cal).mapRowToReturnType();
            }
        } catch (SQLException e) {
            throw new ControlException(e.getMessage(), e);
        }
    }
View Full Code Here

                java.lang.reflect.Array.set(array, i, list.get(i));
            }
        } catch (IllegalArgumentException iae) {
            // assuming no errors in resultSetObject() this can only happen
            // for single column result sets.
            throw new ControlException("The declared Java type for array " + componentType.getName()
                                       + "is incompatible with the SQL format of column " + md.getColumnName(1)
                                       + md.getColumnTypeName(1) + "which returns objects of type + "
                                       + list.get(0).getClass().getName());
        }
        return array;
View Full Code Here

            // is this a request for generatedKeys ?
            //
            if (_getGeneratedKeys) {

                if (_callableStatement) {
                    throw new ControlException("getGeneratedKeys not supported for CallableStatements");
                }

                if (_genKeyColumnNames.length > 0) {
                    preparedStatement = connection.prepareStatement(sql, _genKeyColumnNames);
                } else if (_genKeyColumnIndexes.length > 0) {
                    preparedStatement = connection.prepareStatement(sql, _genKeyColumnIndexes);
                } else {
                    preparedStatement = connection.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
                }

            } else {

                if (_holdability == JdbcControl.HoldabilityType.DRIVER_DEFAULT) {
                    if (_scrollType == JdbcControl.ScrollType.DRIVER_DEFAULT) {
                        preparedStatement = (_callableStatement) ? connection.prepareCall(sql) : connection.prepareStatement(sql);
                    } else {
                        preparedStatement = (_callableStatement)
                                ? connection.prepareCall(sql, _scrollType.getType(), _scrollType.getConcurrencyType())
                                : connection.prepareStatement(sql, _scrollType.getType(), _scrollType.getConcurrencyType());
                    }
                } else {
                    preparedStatement = (_callableStatement)
                            ? connection.prepareCall(sql, _scrollType.getType(), _scrollType.getConcurrencyType(), _holdability.getHoldability())
                            : connection.prepareStatement(sql, _scrollType.getType(), _scrollType.getConcurrencyType(), _holdability.getHoldability());
                }
            }

            //
            // If the method argument is of type SQLParameter, treat this statement as a CallableStatement,
            //
            if (_callableStatement) {
                for (SqlFragment sf : _children) {
                    if (sf.hasParamValue()) {
                        throw new ControlException("Cannot use parameter substution and SQLParameter array in the same method.");
                    }
                }
                JdbcControl.SQLParameter[] params = (JdbcControl.SQLParameter[]) arguments[0];
                if (params == null) {
                    return preparedStatement;
View Full Code Here

     * @throws SQLException
     */
    private void checkJdbcSupport(DatabaseMetaData metaData) throws SQLException {

        if (_getGeneratedKeys && !metaData.supportsGetGeneratedKeys()) {
            throw new ControlException("The database does not support getGeneratedKeys.");
        }

        if (_batchUpdate && !metaData.supportsBatchUpdates()) {
            throw new ControlException("The database does not support batchUpdates.");
        }

        if (_scrollType != JdbcControl.ScrollType.DRIVER_DEFAULT
                && !metaData.supportsResultSetConcurrency(_scrollType.getType(), _scrollType.getConcurrencyType())) {
            throw new ControlException("The database does not support the ResultSet concurrecy type: " + _scrollType.toString());
        }

        if (_holdability != JdbcControl.HoldabilityType.DRIVER_DEFAULT
                && !metaData.supportsResultSetHoldability(_holdability.getHoldability())) {
            throw new ControlException("The database does not support the ResultSet holdability type: " + _holdability.toString());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.beehive.controls.api.ControlException

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.