Package org.apache.avalon.fortress.impl.handler

Examples of org.apache.avalon.fortress.impl.handler.ComponentHandler


            throw new IllegalArgumentException( "Using a reserved id name" + metaData.getName() );
        }

        Iterator it = metaEntry.getRoles();
        // create a handler for the combo of Role+MetaData
        final ComponentHandler handler =
                getComponentHandler( metaEntry, metaData );

        while ( it.hasNext() )
        {
            final String role = (String) it.next();
View Full Code Here


    private ComponentHandler getComponentHandler( final MetaInfoEntry metaEntry,
                                                  final ComponentHandlerMetaData metaData )
            throws Exception
    {
        // get info from params
        final ComponentHandler handler;
        final String classname = metaEntry.getComponentClass().getName();
        final Configuration configuration = metaData.getConfiguration();

        try
        {
            final ObjectFactory factory =
                    createObjectFactory( classname, configuration );

            // create the appropriate handler instance
            final ComponentHandler targetHandler =
                    (ComponentHandler) metaEntry.getHandlerClass().newInstance();

            // do the handler lifecycle
            ContainerUtil.enableLogging( targetHandler, getLogger() );
            ContainerUtil.contextualize( targetHandler, m_context );
View Full Code Here

        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() )
                        {
View Full Code Here

        final Iterator i = m_shutDownOrder.iterator();
        while ( i.hasNext() )
        {
            final Vertex entry = (Vertex) i.next();
            final ComponentHandler handler = (ComponentHandler) entry.getNode();

            if ( getLogger().isDebugEnabled() ) getLogger().debug( "Shutting down: " + handler );
            ContainerUtil.dispose( handler );
            if ( getLogger().isDebugEnabled() ) getLogger().debug( "Done." );
        }
View Full Code Here

    public boolean handleCommandFailure( final Command command, final Throwable throwable )
    {
        if ( command instanceof PrepareHandlerCommand )
        {
            PrepareHandlerCommand phc = (PrepareHandlerCommand)command;
            ComponentHandler handler = phc.getHandler();

            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "Could not prepare ComponentHandler for: "
                    + handler.getComponentClass().getName(), throwable );
            }
        }
        else
        {
            if ( getLogger().isErrorEnabled() )
View Full Code Here

    public boolean handleCommandFailure( final Command command, final Throwable throwable )
    {
        if ( command instanceof PrepareHandlerCommand )
        {
            PrepareHandlerCommand phc = (PrepareHandlerCommand)command;
            ComponentHandler handler = phc.getHandler();
           
            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "Could not prepare ComponentHandler for: "
                    + handler.getComponentClass().getName(), throwable );
            }
        }
        else
        {
            if ( getLogger().isErrorEnabled() )
View Full Code Here

            throw new IllegalArgumentException( "Using a reserved id name" + metaData.getName() );
        }

        Iterator it = metaEntry.getRoles();
        // create a handler for the combo of Role+MetaData
        final ComponentHandler handler =
                getComponentHandler( metaEntry, metaData );

        while ( it.hasNext() )
        {
            final String role = (String) it.next();
View Full Code Here

    private ComponentHandler getComponentHandler( final MetaInfoEntry metaEntry,
                                                  final ComponentHandlerMetaData metaData )
            throws Exception
    {
        // get info from params
        final ComponentHandler handler;
        final String classname = metaEntry.getComponentClass().getName();
        final Configuration configuration = metaData.getConfiguration();

        try
        {
            final ObjectFactory factory =
                    createObjectFactory( classname, configuration );

            // create the appropriate handler instance
            final ComponentHandler targetHandler =
                    (ComponentHandler) metaEntry.getHandlerClass().newInstance();

            // do the handler lifecycle
            ContainerUtil.enableLogging( targetHandler, getLogger() );
            ContainerUtil.contextualize( targetHandler, m_context );
View Full Code Here

        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() )
                        {
View Full Code Here

        final Iterator i = m_shutDownOrder.iterator();
        while ( i.hasNext() )
        {
            final Vertex entry = (Vertex) i.next();
            final ComponentHandler handler = (ComponentHandler) entry.getNode();

            if ( getLogger().isDebugEnabled() ) getLogger().debug( "Shutting down: " + handler );
            ContainerUtil.dispose( handler );
            if ( getLogger().isDebugEnabled() ) getLogger().debug( "Done." );
        }
View Full Code Here

TOP

Related Classes of org.apache.avalon.fortress.impl.handler.ComponentHandler

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.