Binds the specified annotated service object under the specified path prefix.

@param exceptionHandlersAndConverters an iterable object of {@link ExceptionHandlerFunction},
{@link RequestConverterFunction} and/or
{@link ResponseConverterFunction}
356718
public ServerBuilder annotatedService(String pathPrefix, Object service,
                                          Iterable<?> exceptionHandlersAndConverters) {
        return annotatedService(pathPrefix, service, Function.identity(), exceptionHandlersAndConverters);
    }
593012
public static void setHandler(XMLReader reader, Object handler) throws SAXNotSupportedException, SAXNotRecognizedException{
        if(handler instanceof ContentHandler)
            reader.setContentHandler((ContentHandler)handler);
        if(handler instanceof EntityResolver)
            reader.setEntityResolver((EntityResolver)handler);
        if(handler instanceof ErrorHandler)
            reader.setErrorHandler((ErrorHandler)handler);
        if(handler instanceof DTDHandler)
            reader.setDTDHandler((DTDHandler)handler);
        if(handler instanceof LexicalHandler){
            try{
                reader.setProperty(SAXProperties.LEXICAL_HANDLER, handler);
            }catch(SAXException ex){
                reader.setProperty(SAXProperties.LEXICAL_HANDLER_ALT, handler);
            }
        }
        if(handler instanceof DeclHandler){
            try{
                reader.setProperty(SAXProperties.DECL_HANDLER, handler);
            }catch(SAXException ex){
                reader.setProperty(SAXProperties.DECL_HANDLER_ALT, handler);
            }
        }
    }
365571
public Converter<?, NetworkRequest> requestConverter(Type type, Annotation[] annotations) {
        checkNotNull(type, "type == null");
        checkNotNull(annotations, "annotations == null");

        for (int i = 0, count = converters.size(); i < count; i++) {
            Converter<?, NetworkRequest> converter =
                    converters.get(i).toRequest(type, annotations);
            if (converter != null) {
                return converter;
            }
        }

        StringBuilder builder = new StringBuilder("Could not locate Request converter for ")
                .append(type)
                .append(". Tried:");
        for (Factory converterFactory : converters) {
            builder.append("\n * ").append(converterFactory.getClass().getName());
        }
        throw new IllegalArgumentException(builder.toString());
    }
1198517
protected Map<String, FunctionConfiguration> getFunctionConfigurations(final AnnotationHandler handler,
                                                                           final Set<Method> methods) throws Exception {
        info("");
        info(GENERATE_CONFIG);
        final Map<String, FunctionConfiguration> configMap = handler.generateConfigurations(methods);
        if (configMap.size() == 0) {
            info(GENERATE_SKIP);
        } else {
            final String scriptFilePath = getScriptFilePath();
            configMap.values().forEach(config -> config.setScriptFile(scriptFilePath));
            info(GENERATE_DONE);
        }

        return configMap;
    }
880809
public ExceptionHandlerImpl getHandler(Class<? extends Exception> exceptionClass) {
        // If the exception map does not contain the provided exception class, it might
        // still be that a superclass of the exception class is.
        if (!this.exceptionMap.containsKey(exceptionClass)) {

            Class<?> superclass = exceptionClass.getSuperclass();
            do {
                // Is the superclass mapped?
                if (this.exceptionMap.containsKey(superclass)) {
                    // Use the handler for the mapped superclass, and cache handler
                    // for this exception class
                    ExceptionHandlerImpl handler = this.exceptionMap.get(superclass);
                    this.exceptionMap.put(exceptionClass, handler);
                    return handler;
                }

                // Iteratively walk through the exception class's superclasses
                superclass = superclass.getSuperclass();
            } while (superclass != null);

            // No handler found either for the superclasses of the exception class
            // We cache the null value to prevent future
            this.exceptionMap.put(exceptionClass, null);
            return null;
        }

        // Direct map
        return this.exceptionMap.get(exceptionClass);
    }
1244520
@SuppressWarnings("unchecked")
    public void with(ExceptionHandler<? super T> exceptionHandler)
    {
        final EventProcessor eventProcessor = consumerRepository.getEventProcessorFor(eventHandler);
        if (eventProcessor instanceof BatchEventProcessor)
        {
            ((BatchEventProcessor<T>) eventProcessor).setExceptionHandler(exceptionHandler);
            consumerRepository.getBarrierFor(eventHandler).alert();
        }
        else
        {
            throw new RuntimeException(
                "EventProcessor: " + eventProcessor + " is not a BatchEventProcessor " +
                "and does not support exception handlers");
        }
    }
919485
public static HttpHandler createRootHandler(
            List<MappedEndpoint> mappedEndpoints,
            List<Interceptor> rootInterceptors,
            List<Interceptor> endpointInterceptors,
            ExceptionMapper exceptionMapper,
            String basePath,
            boolean httpTracer) {

        final RoutingHandler routingRestHandler = new HttpRootHandler(false);
        final PathTemplateHandler websocketHandler = Handlers.pathTemplate(false);
        HttpHandler staticHandler = null;


        for (MappedEndpoint me : mappedEndpoints) {

            if (MappedEndpoint.Type.REST.equals(me.type)) {
                HttpHandler httpDispatcher =
                        new BlockingHandler(
                                new HttpDispatcher(
                                        new ConnegHandler(
                                                new InterceptorHandler(me.handler, endpointInterceptors), me.mediaTypes
                                        ),
                                        exceptionMapper
                                )
                        );

                String endpointPath = HandlerUtil.BASE_PATH.equals(basePath) ? me.url : basePath + me.url;

                HttpHandler httpHandler = wrapCompressionHandler(httpDispatcher, me);
                routingRestHandler.add(me.method, endpointPath, httpHandler);
            }
            if (MappedEndpoint.Type.MULTIPART.equals(me.type)) {
                HttpHandler httpDispatcher =
                        new BlockingHandler(
                                new HttpDispatcher(
                                        new ConnegHandler(
                                                new InterceptorHandler(me.handler, endpointInterceptors), me.mediaTypes),
                                        exceptionMapper)
                        );

                String endpointPath = HandlerUtil.BASE_PATH.equals(basePath) ? me.url : basePath + me.url;

                HttpHandler httpHandler = wrapCompressionHandler(httpDispatcher, me);
                routingRestHandler.add(me.method, endpointPath, httpHandler);
            }
            if (MappedEndpoint.Type.SSE.equals(me.type)) {
                InterceptorHandler interceptorHandler = new InterceptorHandler(me.handler, endpointInterceptors);
                HttpHandler httpHandler = wrapCompressionHandler(interceptorHandler, me);

                String endpointPath = HandlerUtil.BASE_PATH.equals(basePath) ? me.url : basePath + me.url;
                routingRestHandler.add(me.method, endpointPath, httpHandler);
            }
            if (MappedEndpoint.Type.WS.equals(me.type)) {
                InterceptorHandler interceptorHandler = new InterceptorHandler(me.handler, endpointInterceptors);
                HttpHandler httpHandler = wrapCompressionHandler(interceptorHandler, me);
                websocketHandler.add(me.url, httpHandler);
            }
            if (MappedEndpoint.Type.STATIC.equals(me.type)) {
                staticHandler = wrapCompressionHandler(me.handler, me);
            }
        }

        HttpHandler resolved = resolveHandlers(routingRestHandler, websocketHandler, staticHandler, mappedEndpoints);

        HttpHandler root = wrapRootInterceptorHandler(resolved, rootInterceptors);
        HttpHandler handler = wrapRequestDump(root, httpTracer);
//        handler = wrapServerName(handler);

        return Handlers.gracefulShutdown(handler);
    }
196422
@SuppressWarnings("static-method")
	protected void translateAnnotationsTo(List<JvmAnnotationReference> annotations, JvmAnnotationTarget target,
			Class<?>... exceptions) {
		final Set<String> excepts = new HashSet<>();
		for (final Class<?> type : exceptions) {
			excepts.add(type.getName());
		}
		final List<JvmAnnotationReference> addition = new ArrayList<>();
		for (final JvmAnnotationReference annotation : Iterables.filter(annotations, an -> {
			if (!ANNOTATION_TRANSLATION_FILTER.apply(an)) {
				return false;
			}
			return !excepts.contains(an.getAnnotation().getIdentifier());
		})) {
			addition.add(annotation);
		}
		target.getAnnotations().addAll(addition);
	}
114114
@SuppressWarnings("rawtypes")
   public void setupConfigHandlers(Binding binding, CommonConfig config)
   {
      if (config != null) {
         //start with the use handlers only to remove the previously set configuration
         List<Handler> userHandlers = getNonConfigHandlers(binding.getHandlerChain());
         List<Handler> handlers = convertToHandlers(config.getPreHandlerChains(), binding.getBindingID(), true); //PRE
         handlers.addAll(userHandlers); //ENDPOINT
         handlers.addAll(convertToHandlers(config.getPostHandlerChains(), binding.getBindingID(), false)); //POST
         binding.setHandlerChain(handlers);
      }
   }
351813
protected HttpHandler wrapWithDispatcher(final HttpHandler handler) {
        return new HttpHandler() {
            public void handleRequest(HttpServerExchange exchange) throws Exception {
                if (exchange.isInIoThread()) {
                    exchange.dispatch(handler);
                } else {
                    handler.handleRequest(exchange);
                }
            }
        };
    }
885175
@SuppressWarnings({"rawtypes", "unchecked"})
	private static void loadAnnotationHandlers(HandlerLibrary lib, Trees trees) throws IOException {
		//No, that seemingly superfluous reference to JavacAnnotationHandler's classloader is not in fact superfluous!
		for (JavacAnnotationHandler handler : SpiLoadUtil.findServices(JavacAnnotationHandler.class, JavacAnnotationHandler.class.getClassLoader())) {
			handler.setTrees(trees);
			Class<? extends Annotation> annotationClass = handler.getAnnotationHandledByThisHandler();
			AnnotationHandlerContainer<?> container = new AnnotationHandlerContainer(handler, annotationClass);
			String annotationClassName = container.annotationClass.getName().replace("$", ".");
			List<AnnotationHandlerContainer<?>> list = lib.annotationHandlers.get(annotationClassName);
			if (list == null) lib.annotationHandlers.put(annotationClassName, list = new ArrayList<AnnotationHandlerContainer<?>>(1));
			list.add(container);
			lib.typeLibrary.addType(container.annotationClass.getName());
		}
	}
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);
    }
1232241
static List<RequestObjectResolver> toRequestObjectResolvers(
            List<RequestConverterFunction> converters) {
        final ImmutableList.Builder<RequestObjectResolver> builder = ImmutableList.builder();
        // Wrap every converters received from a user with a default object resolver.
        converters.stream().map(RequestObjectResolver::of).forEach(builder::add);
        builder.addAll(defaultRequestConverters);
        return builder.build();
    }
522052
void doMethod(HttpServletRequest request, HttpServletResponse response, HttpMethod httpMethod) {

        // Locate a request handler:
        String requestPath = mapRequestPath(request);
        Route route = api.get(requestPath);

        try {

            if (route != null && route.requestHandlers.containsKey(httpMethod)) {
                handleRequest(request, response, route, httpMethod);
            } else {
                handleNotFound(request, response);
            }

        } catch (Throwable t) {

            // Chances are the exception we've actually caught is the reflection
            // one from Method.invoke(...)
            Throwable caught = t;
            if (InvocationTargetException.class.isAssignableFrom(t.getClass())) {
                caught = t.getCause();
            }

            RequestHandler requestHandler = (route == null ? null : route.requestHandlers.get(httpMethod));
            handleError(request, response, requestHandler, caught);
        }

    }
177014
public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		String requestedPath = (StringUtils.isEmpty(mapping)) ? helper
				.getPathWithinApplication(request) : helper
				.getPathWithinServletMapping(request);

		if (StringUtils.isNotEmpty(controllerMapping)) {
			requestedPath = requestedPath.substring(controllerMapping.length());
		}

		requestHandler.processRequest(requestedPath, request, response);
		return null;
	}
1034107
@PostMapping(path = SamlProtocolConstants.ENDPOINT_SAML_VALIDATE)
    @Override
    public ModelAndView handleRequestInternal(final HttpServletRequest request,
                                              final HttpServletResponse response) throws Exception {
        return super.handleRequestInternal(request, response);
    }
1349845
@ExceptionHandler({MethodArgumentNotValidException.class, ValidationException.class})
    public ResponseEntity<Response> handleValidationException() {
        return new ResponseEntity<>(
                Response.newBuilder()
                        .withMessage(translate(ExceptionCodes.VALIDATION_ERROR))
                        .withHttpStatus(HttpStatus.INTERNAL_SERVER_ERROR.toString())
                        .build(),
                HttpStatus.INTERNAL_SERVER_ERROR
        );
    }