Package org.qi4j.api.activation

Examples of org.qi4j.api.activation.ActivationEvent


        try
        {
            // Before Activation Events
            if( fireEvents )
            {
                fireEvent( new ActivationEvent( target, ACTIVATING ) );
            }

            // Before Activation for Activators
            targetActivators.beforeActivation( target instanceof ServiceReference
                                               ? new PassiveServiceReference( (ServiceReference) target )
                                               : target );

            // Activation
            for( Activation child : children )
            {
                if( !activeChildren.contains( child ) )
                {
                    child.activate();
                }
                activeChildren.addFirst( child );
            }

            // Internal Activation Callback
            if( callback != null )
            {
                callback.run();
            }

            // After Activation
            targetActivators.afterActivation( target );

            // After Activation Events
            if( fireEvents )
            {
                fireEvent( new ActivationEvent( target, ACTIVATED ) );
            }

            // Activated
            this.targetActivators = targetActivators;
        }
View Full Code Here


        Set<Exception> exceptions = new LinkedHashSet<>();

        // Before Passivation Events
        if( fireEvents )
        {
            ActivationEvent event = new ActivationEvent( target, PASSIVATING );
            for( ActivationEventListener listener : listeners )
            {
                try
                {
                    listener.onEvent( event );
                }
                catch( Exception ex )
                {
                    if( ex instanceof PassivationException )
                    {
                        exceptions.addAll( ( (PassivationException) ex ).causes() );
                    }
                    else
                    {
                        exceptions.add( ex );
                    }
                }
            }
        }

        // Before Passivation for Activators
        if( targetActivators != null )
        {
            try
            {
                targetActivators.beforePassivation( target );
            }
            catch( PassivationException ex )
            {
                exceptions.addAll( ex.causes() );
            }
            catch( Exception ex )
            {
                exceptions.add( ex );
            }
        }

        // Passivation
        while( !activeChildren.isEmpty() )
        {
            passivateOneChild( exceptions );
        }

        // Internal Passivation Callback
        if( callback != null )
        {
            try
            {
                callback.run();
            }
            catch( Exception ex )
            {
                if( ex instanceof PassivationException )
                {
                    exceptions.addAll( ( (PassivationException) ex ).causes() );
                }
                else
                {
                    exceptions.add( ex );
                }
            }
        }

        // After Passivation for Activators
        if( targetActivators != null )
        {
            try
            {
                targetActivators.afterPassivation( target instanceof ServiceReference
                                                   ? new PassiveServiceReference( (ServiceReference) target )
                                                   : target );
            }
            catch( PassivationException ex )
            {
                exceptions.addAll( ex.causes() );
            }
            catch( Exception ex )
            {
                exceptions.add( ex );
            }
        }
        targetActivators = null;

        // After Passivation Events
        if( fireEvents )
        {
            ActivationEvent event = new ActivationEvent( target, PASSIVATED );
            for( ActivationEventListener listener : listeners )
            {
                try
                {
                    listener.onEvent( event );
View Full Code Here

TOP

Related Classes of org.qi4j.api.activation.ActivationEvent

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.