Configure the web application(s).
@param handlers
@throws Exception
963899
protected void addModulesToJetty(HandlerCollection handlers) throws Exception {
    	/* *************
         * Manager API
         * ************* */
        ServletContextHandler apiManServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
        addSecurityHandler(apiManServer);
        apiManServer.setContextPath("/apiman");
        apiManServer.addEventListener(new Listener());
        apiManServer.addEventListener(new BeanManagerResourceBindingListener());
        apiManServer.addEventListener(new ResteasyBootstrap());
        apiManServer.addFilter(LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(ApimanCorsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(DisableCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        addAuthFilter(apiManServer);
        apiManServer.addFilter(DefaultSecurityContextFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(RootResourceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        apiManServer.addFilter(ManagerApiMicroServiceTxWatchdogFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
        ServletHolder resteasyServlet = new ServletHolder(new HttpServletDispatcher());
        resteasyServlet.setInitParameter("javax.ws.rs.Application", ManagerApiMicroServiceApplication.class.getName());
        apiManServer.addServlet(resteasyServlet, "/*");

        apiManServer.setInitParameter("resteasy.injector.factory", "org.jboss.resteasy.cdi.CdiInjectorFactory");
        apiManServer.setInitParameter("resteasy.scan", "true");
        apiManServer.setInitParameter("resteasy.servlet.mapping.prefix", "");

        handlers.addHandler(apiManServer);

        /* ********** *
         * Manager UI *
         * ********** */
        ResourceHandler apimanUiServer = new ResourceHandler() {
            /**
             * @see org.eclipse.jetty.server.handler.ResourceHandler#getResource(java.lang.String)
             */
            @Override
            public Resource getResource(String path) {
                Resource resource = null;

                if (path == null || path.equals("/") || path.equals("/index.html")) {
                    path = "/index.html";
                }
                if (path.startsWith("/apimanui/api-manager") || path.equals("/apimanui") || path.equals("/apimanui/")) {
                    path = "/apimanui/index.html";
                }
                if (path.equals("/apimanui/apiman/config.js")) {
                    resource = getConfigResource(path);
                }
                if (path.equals("/apimanui/apiman/translations.js")) {
                    resource = getTranslationsResource(path);
                }

                if (resource == null) {
                    URL url = getClass().getResource(path);
                    if (url != null) {
                        resource = new ApimanResource(url);
                    }
                }

                return resource;
            }
        };
        apimanUiServer.setResourceBase("/apimanui/");
        apimanUiServer.setWelcomeFiles(new String[] { "index.html" });
        handlers.addHandler(apimanUiServer);
    }
48256
protected void doStart() throws Exception
    {
        if (isStarted())
            return;

        // save context classloader
        Thread thread= Thread.currentThread();
        ClassLoader lastContextLoader= thread.getContextClassLoader();

        MultiException mex= null;
        try
        {
            // Find the webapp
            resolveWebApp();

            // Get the handler
            getServletHandler();
          
            _configurations=loadConfigurations();
            
            // initialize the classloader            
            configureClassPath();
            initClassLoader(true);
            thread.setContextClassLoader(getClassLoader());
            initialize();
            
            // Do the default configuration
            configureDefaults();

            // Set classpath for Jasper.
            Map.Entry entry= _webAppHandler.getHolderEntry("test.jsp");
            if (entry != null)
            {
                ServletHolder jspHolder= (ServletHolder)entry.getValue();
                if (jspHolder != null && jspHolder.getInitParameter("classpath") == null)
                {
                    String fileClassPath= getFileClassPath();
                    jspHolder.setInitParameter("classpath", fileClassPath);
                    if (log.isDebugEnabled())
                        log.debug("Set classpath=" + fileClassPath + " for " + jspHolder);
                }
            }
            
            // configure webapp
            configureWebApp();

            // If we have servlets, don't init them yet
            _webAppHandler.setAutoInitializeServlets(false);

            // Start handlers
            super.doStart();

            mex= new MultiException();
            // Context listeners
            if (_contextListeners != null && _webAppHandler != null)
            {
                ServletContextEvent event= new ServletContextEvent(getServletContext());
                for (int i= 0; i < LazyList.size(_contextListeners); i++)
                {
                    try
                    {
                        ((ServletContextListener)LazyList.get(_contextListeners, i)).contextInitialized(event);
                    }
                    catch (Exception ex)
                    {
                        mex.add(ex);
                    }
                }
            }

            // OK to Initialize servlets now
            if (_webAppHandler != null && _webAppHandler.isStarted())
            {
                try
                {
                    _webAppHandler.initializeServlets();
                }
                catch (Exception ex)
                {
                    mex.add(ex);
                }
            }
        }
        catch (Exception e)
        {
            log.warn("Configuration error on " + _war, e);
            throw e;
        }
        finally
        {
            thread.setContextClassLoader(lastContextLoader);
        }

        if (mex != null)
            mex.ifExceptionThrow();
    }
266247
public function replaceHandlers(string $exceptionType, Closure $handler): void
	{
		$this->clearHandlers($exceptionType);

		$this->handle($exceptionType, $handler);
	}
1199082
public ClientBuilder<T> handlers(Handler... handlers) {
        this.handlers = ImmutableList.<Handler>builder().add(handlers).build();
        return this;
    }
437196
def configure_error_handlers(graph):
    
    # override all of the werkzeug HTTPExceptions
    for code in default_exceptions.keys():
        graph.flask.register_error_handler(code, make_json_error)

    # register catch all for user exceptions
    graph.flask.register_error_handler(Exception, make_json_error)
274474
protected function configureHandler()
    {
        if ($this->config('_handlerConfigured') !== true) {
            $app = $this;

            if ($this->config('bono.cli') !== true) {
                $this->whoops = new Run();

                $handler = new PrettyPageHandler();
                $path = explode(DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR, __DIR__);
                $path = $path[0].'/templates/_whoops';
                $handler->setResourcesPath($path);

                $jsonResponseHandler = new JsonResponseHandler();
                $jsonResponseHandler->onlyForAjaxRequests(true);

                $appHandler = function ($err) use ($app, $handler) {
                    if (!isset($app->request)) {
                        return;
                    }

                    $template = 'error.php';
                    if ($err->getMessage() === '404 Resource not found') {
                        $template = 'notFound.php';
                    }

                    $request = $app->request;

                    // Add some custom tables with relevant info about your application,
                    // that could prove useful in the error page:
                    $handler->addDataTable('Bono Application', array(
                        'Template'         => 'Modify this page on templates/'.$template,
                        'Application Class'=> get_class($app),
                        'Charset'          => $request->headers('ACCEPT_CHARSET') ?: '<none>',
                        'Locale'           => $request->getContentCharset() ?: '<none>',
                    ));

                    $handler->addDataTable('Bono Request', array(
                        'URI'         => $request->getRootUri(),
                        'Request URI' => $request->getResourceUri(),
                        'Path'        => $request->getPath(),
                        'Query String'=> $request->params() ?: '<none>',
                        'HTTP Method' => $request->getMethod(),
                        'Script Name' => $request->getScriptName(),
                        'Base URL'    => $request->getUrl(),
                        'Scheme'      => $request->getScheme(),
                        'Port'        => $request->getPort(),
                        'Host'        => $request->getHost(),
                    ));

                    // Set the title of the error page:
                    $handler->setPageTitle("Bono got whoops! There was a problem.");
                };

                $this->whoops->pushHandler($handler);

                // Add a special handler to deal with AJAX requests with an
                // equally-informative JSON response. Since this handler is
                // first in the stack, it will be executed before the error
                // page handler, and will have a chance to decide if anything
                // needs to be done.
                $this->whoops->pushHandler($jsonResponseHandler);
                $this->whoops->pushHandler($appHandler);

                $this->notFound(array(new NotFoundHandler($this), 'handle'));
                $this->error(array(new ErrorHandler($this), 'handle'));
            }

            $this->config('_handlerConfigured', true);
        }

        return $this;
    }
386879
private void configureExceptionResolvers() {
        Map<String, HandlerExceptionResolver> resolvers = this.factory.getBeansOfType(HandlerExceptionResolver.class);
        DefaultHandlerExceptionResolver defaultResolver;

        if (resolvers.isEmpty()) {
            defineBean(ExceptionHandlerExceptionResolver.class);
            defineBean(ResponseStatusExceptionResolver.class);
            defaultResolver = defineBean(DefaultHandlerExceptionResolver.class);
        } else {
            defaultResolver = getBean(DefaultHandlerExceptionResolver.class).orElse(null);
        }

        if (defaultResolver != null) {
            defaultResolver.setWarnLogCategory("mvc");
        }
    }
1056453
@Override
    public void configure() throws Exception {

        final Namespaces ns = new Namespaces("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
        ns.add("indexing", "http://fedora.info/definitions/v4/indexing#");

        final XPathBuilder indexable = new XPathBuilder(
                String.format("/rdf:RDF/rdf:Description/rdf:type[@rdf:resource='%s']",
                    "http://fedora.info/definitions/v4/indexing#Indexable"));
        indexable.namespaces(ns);

        /**
         * A generic error handler (specific to this RouteBuilder)
         */
        onException(Exception.class)
            .maximumRedeliveries("{{error.maxRedeliveries}}")
            .log("Index Routing Error: ${routeId}");

        /**
         * route a message to the proper queue, based on whether
         * it is a DELETE or UPDATE operation.
         */
        from("{{input.stream}}")
            .routeId("FcrepoTriplestoreRouter")
            .process(new EventProcessor())
            .choice()
                .when(or(header(FCREPO_EVENT_TYPE).contains(RESOURCE_DELETION),
                            header(FCREPO_EVENT_TYPE).contains(DELETE)))
                    .to("direct:delete.triplestore")
                .otherwise()
                    .to("direct:index.triplestore");

        /**
         * Handle re-index events
         */
        from("{{triplestore.reindex.stream}}")
            .routeId("FcrepoTriplestoreReindex")
            .to("direct:index.triplestore");

        /**
         * Based on an item's metadata, determine if it is indexable.
         */
        from("direct:index.triplestore")
            .routeId("FcrepoTriplestoreIndexer")
            .filter(not(in(tokenizePropertyPlaceholder(getContext(), "{{filter.containers}}", ",").stream()
                        .map(uri -> or(
                            header(FCREPO_URI).startsWith(constant(uri + "/")),
                            header(FCREPO_URI).isEqualTo(constant(uri))))
                        .collect(toList()))))
            .removeHeaders("CamelHttp*")
            .choice()
                .when(simple("{{indexing.predicate}} != 'true'"))
                    .to("direct:update.triplestore")
                .otherwise()
                    .to("fcrepo:{{fcrepo.baseUrl}}?preferInclude=PreferMinimalContainer&accept=application/rdf+xml")
                    .choice()
                        .when(indexable)
                            .to("direct:update.triplestore")
                        .otherwise()
                            .to("direct:delete.triplestore");

        /**
         * Remove an item from the triplestore index.
         */
        from("direct:delete.triplestore")
            .routeId("FcrepoTriplestoreDeleter")
            .process(new SparqlDeleteProcessor())
            .log(LoggingLevel.INFO, LOGGER,
                    "Deleting Triplestore Object ${headers[CamelFcrepoUri]}")
            .to("{{triplestore.baseUrl}}?useSystemProperties=true");

        /**
         * Perform the sparql update.
         */
        from("direct:update.triplestore")
            .routeId("FcrepoTriplestoreUpdater")
            .setHeader(FCREPO_NAMED_GRAPH)
                .simple("{{triplestore.namedGraph}}")
            .to("fcrepo:{{fcrepo.baseUrl}}?accept=application/n-triples" +
                    "&preferOmit={{prefer.omit}}&preferInclude={{prefer.include}}")
            .process(new SparqlUpdateProcessor())
            .log(LoggingLevel.INFO, LOGGER,
                    "Indexing Triplestore Object ${headers[CamelFcrepoUri]}")
            .to("{{triplestore.baseUrl}}?useSystemProperties=true");
    }
5779
@Override
    public T addHandlers(ArchiveEventHandler... handlers) {
        for (ArchiveEventHandler handler : handlers) {
            this.getArchive().addHandlers(handler);
        }
        return covarientReturn();
    }
316329
public void setApplications(java.util.Collection<ApplicationDescription> applications) {
        if (applications == null) {
            this.applications = null;
            return;
        }

        this.applications = new com.amazonaws.internal.SdkInternalList<ApplicationDescription>(applications);
    }
768259
protected function prepareWebsocketHandler()
    {
        $handlerClass = $this->container->make('config')->get('swoole.websocket.handler', Handler::class);

        if (!$handlerClass) {
            throw new RuntimeException('Websocket handler is not set in swoole.websocket config');
        }

        $this->setWebsocketHandler($this->app->make($handlerClass));
    }
867975
public void setApplications(java.util.Collection<Application> applications) {
        if (applications == null) {
            this.applications = null;
            return;
        }

        this.applications = new java.util.ArrayList<Application>(applications);
    }
1133992
public static function initialize()
    {
        if (static::$isConfigurationLoaded === true) {
            return;
        }
        
        foreach (static::$handlers as $handler) {
            EventManager::getInstance()->addEventHandler($handler[0], $handler[1], $handler[2], $handler[3]);
        }

        static::$isConfigurationLoaded = true;
    }
621040
protected function prepareWebsocketHandler()
    {
        $handlerClass = $this->container->make('config')->get('swoole_websocket.handler');

        if (! $handlerClass) {
            throw new WebsocketNotSetInConfigException;
        }

        $this->setWebsocketHandler($this->app->make($handlerClass));
    }
758078
@Override
	public void registerErrorHandlers(ErrorHandler... handlers) {
		if (handlers != null) {
			for (ErrorHandler handler : handlers) {
				this.registerErrorHandler(handler);
			}
		}
	}
178201
private static void initMapDefinedHandler(Map<String, Object> handler) {
		// If the handler is a map, the keys are the class name, values are the
		// parameters.
		for (Map.Entry<String, Object> entry : handler.entrySet()) {
			Tuple<String, Class> namedClass = splitClassAndName(entry.getKey());

			// If the values in the config are a map, construct the object using named
			// parameters.
			if (entry.getValue() instanceof Map) {
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByNamedParams(namedClass.second,
							(Map) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a map: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			} else if (entry.getValue() instanceof List) {

				// If the values in the config are a list, call the constructor of the handler
				// with those fields.
				HttpHandler httpHandler;
				try {
					httpHandler = (HttpHandler) ServiceUtil.constructByParameterizedConstructor(namedClass.second,
							(List) entry.getValue());
				} catch (Exception e) {
					throw new RuntimeException(
							"Could not construct a handler with values provided as a list: " + namedClass.second);
				}
				registerMiddlewareHandler(httpHandler);
				handlers.put(namedClass.first, httpHandler);
				handlerListById.put(namedClass.first, Collections.singletonList(httpHandler));
			}
		}
	}
370398
@SuppressWarnings("unchecked")
    public <E extends Throwable> 
    ExceptionHandler<? super E> addExceptionHandler(
            Class<E> type, ExceptionHandler<? super E> handler) {
        exceptionHandlerCache.clear();
        return (ExceptionHandler<? super E>) exceptionHandlers.put(type, handler);
    }