Package org.codehaus.plexus.component.repository.exception

Examples of org.codehaus.plexus.component.repository.exception.ComponentLifecycleException


        {
            getLifecycleHandler().start( component, this );
        }
        catch ( PhaseExecutionException e )
        {
            throw new ComponentLifecycleException( "Error starting component", e );
        }
    }
View Full Code Here


        {
            getLifecycleHandler().suspend( component, this );
        }
        catch ( PhaseExecutionException e )
        {
            throw new ComponentLifecycleException( "Error suspending component", e );
        }
    }
View Full Code Here

        {
            getLifecycleHandler().resume( component, this );
        }
        catch ( PhaseExecutionException e )
        {
            throw new ComponentLifecycleException( "Error suspending component", e );
        }
    }
View Full Code Here

        {
            getLifecycleHandler().end( component, this );
        }
        catch ( PhaseExecutionException e )
        {
            throw new ComponentLifecycleException( "Error ending component lifecycle", e );
        }
    }
View Full Code Here

    {
        FutureTask<T> singletonFuture;
        synchronized (this) {
            if (disposed)
            {
                throw new ComponentLifecycleException("This ComponentManager has already been destroyed");
            }

            // if singleton already created, simply return the existing singleton
            T singleton = getExistingInstance( false );
            if (singleton != null) {
                return singleton;
            }

            // no existing singleton, create a new one
            singletonFuture = new FutureTask<T>(new CreateInstance());
            this.singletonFuture = singletonFuture;
        }

        // do not call CreateInstance.get() inside of a synchronized block because createInstance results in
        // several callbacks to user code which could result in a dead lock
        if ( singletonFuture != null )
        {
            singletonFuture.run();
        }

        // try to get the future instance
        try
        {
            return singletonFuture.get();
        }
        catch ( Exception e )
        {
            // creation failed... clear future reference
            synchronized ( this )
            {
                // only clear if still refering to this method's future
                if ( this.singletonFuture == singletonFuture )
                {
                    this.singletonFuture = null;
                }
            }

            // future.get() normally throws an execution execption which contains the real cause
            Throwable cause = e;
            if ( e instanceof ExecutionException && e.getCause() != null )
            {
                cause = e.getCause();
            }

            // rethrow ComponentInstantiationException
            if ( cause instanceof ComponentInstantiationException )
            {
                throw (ComponentInstantiationException) cause;
            }

            // rethrow ComponentLifecycleException
            if ( cause instanceof ComponentLifecycleException )
            {
                throw (ComponentLifecycleException) cause;
            }

            // nothing else was expected
            throw new ComponentLifecycleException( "Unexpected error obtaining singleton instance", cause );
        }
    }
View Full Code Here

    public synchronized T getComponent() throws ComponentLifecycleException
    {
        if (disposed)
        {
            throw new ComponentLifecycleException("This ComponentManager has already been destroyed");
        }
        return instance;
    }
View Full Code Here

            if ( e instanceof PhaseExecutionException && e.getCause() != null )
            {
                cause = e.getCause();
            }

            throw new ComponentLifecycleException("Error invoking start method", cause);
        }
    }
View Full Code Here

        {
            lifecycleHandler.end( component, this, componentDescriptor.getRealm() );
        }
        catch ( PhaseExecutionException e )
        {
            throw new ComponentLifecycleException( "Error ending component lifecycle", e );
        }
    }
View Full Code Here

            disposed = true;
            instances = this.instances.keySet();
            this.instances.clear();
        }

        ComponentLifecycleException componentLifecycleException = null;
        for ( T instance : instances )
        {
            try
            {
                // do not call destroyInstance inside of a synchronized block because
View Full Code Here

    public T getComponent( ) throws ComponentInstantiationException, ComponentLifecycleException
    {
        synchronized (this) {
            if (disposed)
            {
                throw new ComponentLifecycleException("This ComponentManager has already been destroyed");
            }
        }

        // do not call createInstance inside of a synchronized block because
        // createInstance results in several callbacks to user code which
        // could result in a dead lock
        T instance = createInstance();

        synchronized (this) {
            // if this manager has been destroyed during create, destroy newly
            // created component
            if (disposed)
            {
                try
                {
                    destroyInstance( instance );
                }
                catch ( ComponentLifecycleException e )
                {
                    // todo: log ignored exception
                }

                throw new ComponentLifecycleException("This ComponentManager has already been destroyed");
            }

            instances.put(instance, instance);
        }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.component.repository.exception.ComponentLifecycleException

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.