Package org.apache.avalon.excalibur.datasource

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent


            final String driver = dataSourceConf.getChild( "driver", true ).getValue( "" );

            final ClassLoader classLoader =
                Thread.currentThread().getContextClassLoader();

            DataSourceComponent component = null;
            if( null == classLoader )
            {
                if( !"".equals( driver ) )
                {
                    Class.forName( driver, true, Thread.currentThread().getContextClassLoader() );
                }

                component = (DataSourceComponent)Class.forName( clazz ).newInstance();
            }
            else
            {
                if( !"".equals( driver ) )
                {
                    classLoader.loadClass( driver );
                }

                component = (DataSourceComponent)classLoader.loadClass( clazz ).newInstance();
            }

            if( component instanceof LogEnabled )
            {
                setupLogger( component, name );
            }
            component.configure( dataSourceConf );
            m_dataSources.put( name, component );

            if( getLogger().isInfoEnabled() )
            {
                getLogger().info( "DataSource " + name + " ready" );
View Full Code Here


            getLogger().debug( "disposal" );
        }
        final Iterator keys = m_dataSources.keySet().iterator();
        while( keys.hasNext() )
        {
            final DataSourceComponent dsc =
                (DataSourceComponent)m_dataSources.get( keys.next() );
            if( dsc instanceof Disposable )
            {
                ( (Disposable)dsc ).dispose();
            }
View Full Code Here

                final String connection = properties.getParameter( SQLTransformer.MAGIC_CONNECTION, null );
                if ( connection != null ) {
                    if (this.transformer.dbSelector == null) {
                        transformer.getTheLogger().error( "No DBSelector found, could not use connection: " + connection);
                    } else {
                        DataSourceComponent datasource = null;

                        try {
                            datasource = (DataSourceComponent) this.transformer.dbSelector.select( connection );
                            for ( int i = 0; i < transformer.connectAttempts && result == null; i++) {
                                try {
                                    result = datasource.getConnection();
                                } catch ( Exception e ) {
                                    final long waittime = transformer.connectWaittime;
                                    transformer.getTheLogger().debug(
                                            "SQLTransformer$Query: could not acquire a Connection -- waiting "
                                            + waittime + " ms to try again." );
View Full Code Here

     * @exception  Exception  Description of Exception
     */
    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src,
            Parameters parameters)
        throws Exception {
        DataSourceComponent datasource = null;
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;

        // read global parameter settings
        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;

        if (this.settings.containsKey("reloadable")) {
            reloadable = Boolean.valueOf((String) this.settings.get("reloadable")).booleanValue();
        }

        // read local settings
        try {
            Configuration conf = this.getConfiguration(
                    parameters.getParameter("descriptor", (String) this.settings.get("descriptor")),
                    resolver,
                    parameters.getParameterAsBoolean("reloadable", reloadable));
            String create_session = parameters.getParameter("create-session",
                    (String)this.settings.get("create-session"));
            String append_session = parameters.getParameter("append-session",
                    (String)this.settings.get("append-session"));
            boolean cs = true;
            if (create_session != null) {
                cs = BooleanUtils.toBoolean(create_session.trim());
            }
            boolean as = BooleanUtils.toBoolean(append_session.trim());

            datasource = this.getDataSource(conf);
            conn = datasource.getConnection();
            Request req = ObjectModelHelper.getRequest(objectModel);

            /*
             *  check request validity
             */
 
View Full Code Here

        super( name );
    }

    public void testOverAllocation()
    {
        DataSourceComponent ds = null;
        m_isSuccessful = false;
        LinkedList connectionList = new LinkedList();

        try
        {
            ds = (DataSourceComponent)manager.lookup( DataSourceComponent.ROLE );

            for( int i = 0; i < 10; i++ )
            {
                connectionList.add( ds.getConnection() );
            }
            getLogger().info( "Testing overallocation of connections.  Should see a warning next." );
            connectionList.add( ds.getConnection() );
        }
        catch( SQLException se )
        {
            this.m_isSuccessful = true;
            getLogger().info( "The test was successful" );
View Full Code Here

        assertTrue( "Exception was not thrown when too many datasource components were retrieved.", this.m_isSuccessful );
    }

    public void testNormalUse()
    {
        DataSourceComponent ds = null;
        m_isSuccessful = true;

        try
        {
            ds = (DataSourceComponent)manager.lookup( DataSourceComponent.ROLE );
View Full Code Here

            final String driver = dataSourceConf.getChild( "driver", true ).getValue( "" );

            final ClassLoader classLoader =
                Thread.currentThread().getContextClassLoader();

            DataSourceComponent component = null;
            if( null == classLoader )
            {
                if( !"".equals( driver ) )
                {
                    Class.forName( driver, true, Thread.currentThread().getContextClassLoader() );
                }

                component = (DataSourceComponent)Class.forName( clazz ).newInstance();
            }
            else
            {
                if( !"".equals( driver ) )
                {
                    classLoader.loadClass( driver );
                }

                component = (DataSourceComponent)classLoader.loadClass( clazz ).newInstance();
            }

            if( component instanceof LogEnabled )
            {
                setupLogger( component, name );
            }
            component.configure( dataSourceConf );
            m_dataSources.put( name, component );

            if( getLogger().isInfoEnabled() )
            {
                getLogger().info( "DataSource " + name + " ready" );
View Full Code Here

            getLogger().debug( "disposal" );
        }
        final Iterator keys = m_dataSources.keySet().iterator();
        while( keys.hasNext() )
        {
            final DataSourceComponent dsc =
                (DataSourceComponent)m_dataSources.get( keys.next() );
            if( dsc instanceof Disposable )
            {
                ( (Disposable)dsc ).dispose();
            }
View Full Code Here

   * Purpose:
   * - allows JDBCSampler to be entirely independent of the pooling classes
   * - allows the pool storage mechanism to be changed if necessary
   */
  public static Connection getConnection(String poolName) throws SQLException{
    DataSourceComponent pool = (DataSourceComponent)
        JMeterContextService.getContext().getVariables().getObject(poolName);
    if (pool == null) {
      throw new SQLException("No pool found named: '" + poolName + "'");
    }
    return pool.getConnection();
  }
View Full Code Here

                final String connection = properties.getParameter( SQLTransformer.MAGIC_CONNECTION, null );
                if ( connection != null ) {
                    if (this.transformer.dbSelector == null) {
                        transformer.getTheLogger().error( "No DBSelector found, could not use connection: " + connection);
                    } else {
                        DataSourceComponent datasource = null;

                        try {
                            datasource = (DataSourceComponent) this.transformer.dbSelector.select( connection );
                            for ( int i = 0; i < transformer.connectAttempts && result == null; i++) {
                                try {
                                    result = datasource.getConnection();
                                } catch ( Exception e ) {
                                    final long waittime = transformer.connectWaittime;
                                    transformer.getTheLogger().debug(
                                            "SQLTransformer$Query: could not acquire a Connection -- waiting "
                                            + waittime + " ms to try again." );
View Full Code Here

TOP

Related Classes of org.apache.avalon.excalibur.datasource.DataSourceComponent

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.