Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.sonatype.sisu.jetty.mangler;
 
Mangler that sets UnavailableOnStartupException on all WebAppContexts to true (or to defined value). It does so by "crawling" all the defined contexts in Jetty instance. Note: use of this handler is limited only before Jetty is started (for obvious reasons)! It returns the count of affected WebAppContext encountered during it's work being done (in other words, returns the count of the setter invocations it did).

Author(s):
cstamas
Since:
1.2
    implements ServerMangler<Integer>
    private final boolean throwUnavailableOnStartupException;
    {
        thistrue );
    }
    public UnavailableOnStartupExceptionContextManglerfinal boolean throwUnavailableOnStartupException )
    {
        this. = throwUnavailableOnStartupException;
    }
    public Integer mangleServer server )
    {
        return setUnavailableOnStartupExceptionserver.getHandlers() );
    }
    // ==
    protected int setUnavailableOnStartupExceptionfinal Handler[] handlers )
    {
        int setCount = 0;
        for ( int i = 0; i < handlers.lengthi++ )
        {
            if ( handlers[iinstanceof ContextHandler )
            {
                final ContextHandler ctx = (ContextHandlerhandlers[i];
                if ( ctx instanceof WebAppContext )
                {
                    final WebAppContext wctx = (WebAppContextctx;
                    wctx.setThrowUnavailableOnStartupException );
                    setCount++;
                }
            }
            else if ( handlers[iinstanceof HandlerCollection )
            {
                final Handler[] handlerList = ( (HandlerCollectionhandlers[i] ).getHandlers();
                setCount = setCount + setUnavailableOnStartupExceptionhandlerList );
            }
        }
        return setCount;
    }
New to GrepCode? Check out our FAQ X