Examples of MultiException


Examples of org.mortbay.util.MultiException

    public void handle(String target, HttpServletRequest request, HttpServletResponse response, int dispatch)
        throws IOException, ServletException
    {
        if (_handlers!=null && isStarted())
        {
            MultiException mex=null;
           
            for (int i=0;i<_handlers.length;i++)
            {
                try
                {
                    _handlers[i].handle(target,request, response, dispatch);
                }
                catch(IOException e)
                {
                    throw e;
                }
                catch(RuntimeException e)
                {
                    throw e;
                }
                catch(Exception e)
                {
                    if (mex==null)
                        mex=new MultiException();
                    mex.add(e);
                }
            }
            if (mex!=null)
            {
                if (mex.size()==1)
                    throw new ServletException(mex.getThrowable(0));
                else
                    throw new ServletException(mex);
            }
           
        }   
View Full Code Here

Examples of org.mortbay.util.MultiException

    /*
     * @see org.mortbay.jetty.handler.AbstractHandler#doStart()
     */
    protected void doStart() throws Exception
    {
        MultiException mex=new MultiException();
        if (_handlers!=null)
        {
            for (int i=0;i<_handlers.length;i++)
                try{_handlers[i].start();}catch(Throwable e){mex.add(e);}
        }
        super.doStart();
        mex.ifExceptionThrow();
    }
View Full Code Here

Examples of org.mortbay.util.MultiException

    /*
     * @see org.mortbay.jetty.handler.AbstractHandler#doStop()
     */
    protected void doStop() throws Exception
    {
        MultiException mex=new MultiException();
        try { super.doStop(); } catch(Throwable e){mex.add(e);}
        if (_handlers!=null)
        {
            for (int i=_handlers.length;i-->0;)
                try{_handlers[i].stop();}catch(Throwable e){mex.add(e);}
        }
        mex.ifExceptionThrow();
    }
View Full Code Here

Examples of org.mortbay.util.MultiException

    /* ------------------------------------------------------------ */
    protected void doStart() throws Exception
    {
        Log.info("jetty-"+_version);
        HttpGenerator.setServerVersion(_version);
        MultiException mex=new MultiException();
     
        for (int i=0;_realms !=null && i<_realms.length; i++)
        {
            if (_realms[i] instanceof LifeCycle)
                ((LifeCycle)_realms[i]).start();
        }

        Iterator itor = _dependentLifeCycles.iterator();
        while (itor.hasNext())
        {  
            try
            {
                ((LifeCycle)itor.next()).start();
            }
            catch (Throwable e) {mex.add(e);}
        }
       
        if (_threadPool==null)
        {
            QueuedThreadPool tp=new QueuedThreadPool();
            setThreadPool(tp);
        }
       
        if (_sessionIdManager!=null)
            _sessionIdManager.start();
       
        try
        {
            if (_threadPool instanceof LifeCycle)
                ((LifeCycle)_threadPool).start();
        }
        catch(Throwable e) { mex.add(e);}
       
        try
        {
            super.doStart();
        }
        catch(Throwable e)
        {
            Log.warn("Error starting handlers",e);
        }
       
        if (_connectors!=null)
        {
            for (int i=0;i<_connectors.length;i++)
            {
                try{_connectors[i].start();}
                catch(Throwable e)
                {
                    mex.add(e);
                }
            }
        }
        mex.ifExceptionThrow();
    }
View Full Code Here

Examples of org.mortbay.util.MultiException

    }

    /* ------------------------------------------------------------ */
    protected void doStop() throws Exception
    {
        MultiException mex=new MultiException();
       
        for (int i=0;_realms !=null && i<_realms.length; i++)
        {
            if (_realms[i] instanceof LifeCycle)
                ((LifeCycle)_realms[i]).stop();
        }
       
        if (_graceful>0)
        {
            if (_connectors!=null)
            {
                for (int i=_connectors.length;i-->0;)
                {
                    Log.info("Graceful shutdown {}",_connectors[i]);
                    try{_connectors[i].close();}catch(Throwable e){mex.add(e);}
                }
            }
           
            Handler[] contexts = getChildHandlersByClass(Graceful.class);
            for (int c=0;c<contexts.length;c++)
            {
                Graceful context=(Graceful)contexts[c];
                Log.info("Graceful shutdown {}",context);
                context.setShutdown(true);
            }
            Thread.sleep(_graceful);
        }
       
        if (_connectors!=null)
        {
            for (int i=_connectors.length;i-->0;)
                try{_connectors[i].stop();}catch(Throwable e){mex.add(e);}
        }

        try {super.doStop(); } catch(Throwable e) { mex.add(e);}
       
        if (_sessionIdManager!=null)
            _sessionIdManager.stop();
       
        try
        {
            if (_threadPool instanceof LifeCycle)
                ((LifeCycle)_threadPool).stop();
        }
        catch(Throwable e){mex.add(e);}
       
        if (!_dependentLifeCycles.isEmpty())
        {
            ListIterator itor = _dependentLifeCycles.listIterator(_dependentLifeCycles.size());
            while (itor.hasPrevious())
            {
                try
                {
                    ((LifeCycle)itor.previous()).stop();
                }
                catch (Throwable e) {mex.add(e);}
            }
        }
      
        mex.ifExceptionThrow();
    }
View Full Code Here

Examples of org.mortbay.util.MultiException

     * Called automatically from start if autoInitializeServlet is true.
     */
    public void initialize()
        throws Exception
    {
        MultiException mx = new MultiException();

        // Start filters
        if (_filters!=null)
        {
            for (int i=0;i<_filters.length; i++)
                _filters[i].start();
        }
       
        if (_servlets!=null)
        {
            // Sort and Initialize servlets
            ServletHolder[] servlets = (ServletHolder[])_servlets.clone();
            Arrays.sort(servlets);
            for (int i=0; i<servlets.length; i++)
            {
                try
                {
                    if (servlets[i].getClassName()==null && servlets[i].getForcedPath()!=null)
                    {
                        ServletHolder forced_holder = (ServletHolder)_servletPathMap.match(servlets[i].getForcedPath());
                        if (forced_holder==null || forced_holder.getClassName()==null)
                        {   
                            mx.add(new IllegalStateException("No forced path servlet for "+servlets[i].getForcedPath()));
                            continue;
                        }
                        servlets[i].setClassName(forced_holder.getClassName());
                    }
                   
                    servlets[i].start();
                }
                catch(Throwable e)
                {
                    Log.debug(Log.EXCEPTION,e);
                    mx.add(e);
                }
            }
            mx.ifExceptionThrow()
        }
    }
View Full Code Here

Examples of org.openqa.jetty.util.MultiException

     */
    protected void startHandlers()
        throws Exception
    {
        // Prepare a multi exception
        MultiException mx = new MultiException();

        Iterator handlers = _handlers.iterator();
        while(handlers.hasNext())
        {
            HttpHandler handler=(HttpHandler)handlers.next();
            if (!handler.isStarted())
                try{handler.start();}catch(Exception e){mx.add(e);}
        }
        mx.ifExceptionThrow();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.