public synchronized void shutdownAll()

in common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/run/EmbeddedRegistry.java [100:156]


    public synchronized void shutdownAll( final Log log )
        throws Exception
    {
        Exception firstException = null;
        for ( Iterator<Object> iterator = containers.iterator(); iterator.hasNext(); )
        {
            Object embedded = iterator.next();
            try
            {
                Method method = embedded.getClass().getMethod( "stop", null );
                method.invoke( embedded, null );
                embedded.getClass().getMethod( "destroy", null ).invoke( embedded, null );
                iterator.remove();
            }
            catch ( NoSuchMethodException e )
            {
                if ( firstException == null )
                {
                    firstException = e;
                    error( log, e, "no stop/destroy method in class " + embedded.getClass().getName() );
                }
                else
                {
                    error( log, e, "Error while shutting down embedded Tomcat." );
                }
            }
            catch ( IllegalAccessException e )
            {
                if ( firstException == null )
                {
                    firstException = e;
                    error( log, e, "IllegalAccessException for stop/destroy method in class " + embedded.getClass().getName() );
                }
                else
                {
                    error( log, e, "Error while shutting down embedded Tomcat." );
                }
            }
            catch ( InvocationTargetException e )
            {

                if ( firstException == null )
                {
                    firstException = e;
                    error( log, e, "IllegalAccessException for stop/destroy method in class " + embedded.getClass().getName() );
                }
                else
                {
                    error( log, e, "Error while shutting down embedded Tomcat." );
                }
            }
        }
        if ( firstException != null )
        {
            throw firstException;
        }
    }