Package org.apache.commons.collections

Examples of org.apache.commons.collections.BoundedFifoBuffer


    public BlockingFixedSizePool( ObjectFactory factory, int size, long timeout )
        throws Exception
    {
        m_timeout = ( timeout < 1 ) ? 0 : timeout;
        m_buffer = new BoundedFifoBuffer( size );
        m_maxSize = size;
        m_factory = factory;
    }
View Full Code Here


    private final ObjectFactory m_factory;

    public FixedSizePool( ObjectFactory factory, int size )
        throws Exception
    {
        m_buffer = new BoundedFifoBuffer( size );
        m_factory = factory;

        for( int i = 0; i < size; i++ )
        {
            m_buffer.add( newInstance() );
View Full Code Here

    public void initialize()
            throws CompositeException, Exception
    {
        // go over all components
        final Iterator i = m_components.iterator();
        final BoundedFifoBuffer buffer = new BoundedFifoBuffer( Math.max( m_components.size(), 1 ) );

        // just to be on the safe side
        m_extManager.makeReadOnly();

        verifyComponents();

        ComponentHandlerEntry entry;
        while ( i.hasNext() )
        {
            entry = (ComponentHandlerEntry) i.next();
            try
            {
                final ComponentHandler handler = entry.getHandler();

                // Depending on the activation policy of the component decide
                //  how to initialize the component.  Make sure that we can
                //  perform the specified activation policy, if not modify it.
                int activation = entry.getMetaData().getActivation();
                if ( activation == ComponentHandlerMetaData.ACTIVATION_BACKGROUND )
                {
                    // If a sink is not set then we must change to inline.
                    if ( null == m_commandSink )
                    {
                        activation = ComponentHandlerMetaData.ACTIVATION_INLINE;
                    }
                }

                // We now have an activation policy we can handle.
                switch ( activation )
                {
                    case ComponentHandlerMetaData.ACTIVATION_BACKGROUND:
                        // Add a command to initialize the component to the command
                        //  sink so it will be initialized asynchronously in the
                        //  background.
                        final PrepareHandlerCommand element =
                                new PrepareHandlerCommand( handler, getLogger() );
                        m_commandSink.enqueue( element );
                        break;

                    case ComponentHandlerMetaData.ACTIVATION_INLINE:
                        // Initialize the component now.
                        handler.prepareHandler();
                        break;

                    default: // ComponentHandlerMetaData.ACTIVATION_LAZY
                        if ( getLogger().isDebugEnabled() )
                        {
                            final String message = "ComponentHandler (" + handler +
                                    ") has specified a lazy activation policy, " +
                                    "initialization deferred until first use";
                            getLogger().debug( message );
                        }
                        break;
                }
            }
            catch ( final CascadingException e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );

                    final String cause = "Cause for exception";
                    getLogger().warn( cause, e.getCause() );
                }
                buffer.add( e );
            }
            catch ( final Exception e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );
                }
                buffer.add( e );
            }
            catch ( final LinkageError le )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, le );
                }
                buffer.add( le );
            }
        }

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

    public BlockingFixedSizePool( ObjectFactory factory, int size, long timeout )
        throws Exception
    {
        m_timeout = ( timeout < 1 ) ? 0 : timeout;
        m_buffer = new BoundedFifoBuffer( size );
        m_maxSize = size;
        m_factory = factory;
    }
View Full Code Here

    private final ObjectFactory m_factory;

    public FixedSizePool( ObjectFactory factory, int size )
        throws Exception
    {
        m_buffer = new BoundedFifoBuffer( size );
        m_factory = factory;

        for( int i = 0; i < size; i++ )
        {
            m_buffer.add( newInstance() );
View Full Code Here

    public void initialize()
            throws CompositeException, Exception
    {
        // go over all components
        final Iterator i = m_components.iterator();
        final BoundedFifoBuffer buffer = new BoundedFifoBuffer( Math.max( m_components.size(), 1 ) );

        // just to be on the safe side
        m_extManager.makeReadOnly();

        verifyComponents();

        ComponentHandlerEntry entry;
        while ( i.hasNext() )
        {
            entry = (ComponentHandlerEntry) i.next();
            try
            {
                final ComponentHandler handler = entry.getHandler();

                // Depending on the activation policy of the component decide
                //  how to initialize the component.  Make sure that we can
                //  perform the specified activation policy, if not modify it.
                int activation = entry.getMetaData().getActivation();
                if ( activation == ComponentHandlerMetaData.ACTIVATION_BACKGROUND )
                {
                    // If a sink is not set then we must change to inline.
                    if ( null == m_commandSink )
                    {
                        activation = ComponentHandlerMetaData.ACTIVATION_INLINE;
                    }
                }

                // We now have an activation policy we can handle.
                switch ( activation )
                {
                    case ComponentHandlerMetaData.ACTIVATION_BACKGROUND:
                        // Add a command to initialize the component to the command
                        //  sink so it will be initialized asynchronously in the
                        //  background.
                        final PrepareHandlerCommand element =
                                new PrepareHandlerCommand( handler, getLogger() );
                        m_commandSink.enqueue( element );
                        break;

                    case ComponentHandlerMetaData.ACTIVATION_INLINE:
                        // Initialize the component now.
                        handler.prepareHandler();
                        break;

                    default: // ComponentHandlerMetaData.ACTIVATION_LAZY
                        if ( getLogger().isDebugEnabled() )
                        {
                            final String message = "ComponentHandler (" + handler +
                                    ") has specified a lazy activation policy, " +
                                    "initialization deferred until first use";
                            getLogger().debug( message );
                        }
                        break;
                }
            }
            catch ( final CascadingException e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );

                    final String cause = "Cause for exception";
                    getLogger().warn( cause, e.getCause() );
                }
                buffer.add( e );
            }
            catch ( final Exception e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );
                }
                buffer.add( e );
            }
            catch ( final LinkageError le )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, le );
                }
                buffer.add( le );
            }
        }

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

    public BlockingFixedSizePool( ObjectFactory factory, int size, long timeout )
        throws Exception
    {
        m_timeout = ( timeout < 1 ) ? 0 : timeout;
        m_buffer = new BoundedFifoBuffer( size );
        m_maxSize = size;
        m_factory = factory;
    }
View Full Code Here

    private final ObjectFactory m_factory;

    public FixedSizePool( ObjectFactory factory, int size )
        throws Exception
    {
        m_buffer = new BoundedFifoBuffer( size );
        m_factory = factory;

        for( int i = 0; i < size; i++ )
        {
            m_buffer.add( newInstance() );
View Full Code Here

    public void initialize()
            throws CompositeException, Exception
    {
        // go over all components
        final Iterator i = m_components.iterator();
        final BoundedFifoBuffer buffer = new BoundedFifoBuffer( Math.max( m_components.size(), 1 ) );

        // just to be on the safe side
        m_extManager.makeReadOnly();

        verifyComponents();

        ComponentHandlerEntry entry;
        while ( i.hasNext() )
        {
            entry = (ComponentHandlerEntry) i.next();
            try
            {
                final ComponentHandler handler = entry.getHandler();

                // Depending on the activation policy of the component decide
                //  how to initialize the component.  Make sure that we can
                //  perform the specified activation policy, if not modify it.
                int activation = entry.getMetaData().getActivation();
                if ( activation == ComponentHandlerMetaData.ACTIVATION_BACKGROUND )
                {
                    // If a sink is not set then we must change to inline.
                    if ( null == m_commandSink )
                    {
                        activation = ComponentHandlerMetaData.ACTIVATION_INLINE;
                    }
                }

                // We now have an activation policy we can handle.
                switch ( activation )
                {
                    case ComponentHandlerMetaData.ACTIVATION_BACKGROUND:
                        // Add a command to initialize the component to the command
                        //  sink so it will be initialized asynchronously in the
                        //  background.
                        final PrepareHandlerCommand element =
                                new PrepareHandlerCommand( handler, getLogger() );
                        m_commandSink.enqueue( element );
                        break;

                    case ComponentHandlerMetaData.ACTIVATION_INLINE:
                        // Initialize the component now.
                        handler.prepareHandler();
                        break;

                    default: // ComponentHandlerMetaData.ACTIVATION_LAZY
                        if ( getLogger().isDebugEnabled() )
                        {
                            final String message = "ComponentHandler (" + handler +
                                    ") has specified a lazy activation policy, " +
                                    "initialization deferred until first use";
                            getLogger().debug( message );
                        }
                        break;
                }
            }
            catch ( final CascadingException e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );

                    final String cause = "Cause for exception";
                    getLogger().warn( cause, e.getCause() );
                }
                buffer.add( e );
            }
            catch ( final Exception e )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, e );
                }
                buffer.add( e );
            }
            catch ( final LinkageError le )
            {
                final String cName = entry.getMetaData().getName();

                if ( getLogger().isWarnEnabled() )
                {
                    final String message = "Could not initialize component " + cName;
                    getLogger().warn( message, le );
                }
                buffer.add( le );
            }
        }

        // if we were unable to activate one or more components,
        // throw an exception
        if ( buffer.size() > 0 )
        {
            throw new CompositeException( (Exception[]) buffer.toArray( new Exception[0] ),
                    "unable to instantiate one or more components" );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.collections.BoundedFifoBuffer

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.