Examples of HandlerWrapper


Examples of io.undertow.server.HandlerWrapper

    @Override
    public HandlerWrapper build(final Map<String, Object> config) {
        final ExchangeAttribute value = (ExchangeAttribute) config.get("value");
        final ExchangeAttribute attribute = (ExchangeAttribute) config.get("attribute");

        return new HandlerWrapper() {
            @Override
            public HttpHandler wrap(HttpHandler handler) {
                return new SetAttributeHandler(handler, attribute, value);
            }
        };
View Full Code Here

Examples of io.undertow.server.HandlerWrapper

        final List<PredicatedHandler> wrappers = new ArrayList<>();

        for (String line : lines) {
            if (line.trim().length() > 0) {
                Predicate predicate;
                HandlerWrapper handler;
                String[] parts = line.split("->");
                if (parts.length == 2) {
                    predicate = PredicateParser.parse(parts[0], classLoader);
                    handler = HandlerParser.parse(parts[1], classLoader);
                } else if (parts.length == 1) {
View Full Code Here

Examples of io.undertow.server.HandlerWrapper

            request.setAttribute(Constants.JSP_FILE, old);
        }
    }

    public static HandlerWrapper jspFileHandlerWrapper(final String jspFile) {
        return new HandlerWrapper() {
            @Override
            public HttpHandler wrap(HttpHandler handler) {
                return new JspFileHandler(jspFile, handler);
            }
        };
View Full Code Here

Examples of io.undertow.server.HandlerWrapper

                        new ServletInfo("servlet", MessageServlet.class)
                                .addMapping("/")
                                .addInitParam(MessageServlet.MESSAGE, "This is a servlet")
                )
                .addListener(new ListenerInfo(TestListener.class))
                .addInitialHandlerChainWrapper(new HandlerWrapper() {
                    @Override
                    public HttpHandler wrap(final HttpHandler handler) {
                        return new HttpHandler() {
                            @Override
                            public void handleRequest(final HttpServerExchange exchange) throws Exception {
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

        server.addConnector(localConnector);

        // create a handler chain to serve requests
        webApps = new ContextHandlerCollection();
        webApps.setHandlers(new Handler[0]);
        HandlerWrapper interceptor = new DashboardHttpRequestInterceptor(
                startupTimestamp);
        interceptor.setHandler(webApps);
        server.setHandler(interceptor);

        // start the server
        try {
            server.start();
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

    {
        Server server = new Server(8080);

        // create the handlers
        Handler param = new ParamHandler();
        HandlerWrapper wrapper = new WelcomeWrapHandler();
        Handler hello = new HelloHandler();
        Handler dft = new DefaultHandler();
        RequestLogHandler requestLog = new RequestLogHandler();

        // configure request logging
        File requestLogFile = File.createTempFile("demo", "log");
        NCSARequestLog ncsaLog = new NCSARequestLog(
                requestLogFile.getAbsolutePath());
        requestLog.setRequestLog(ncsaLog);

        // create the handler collections
        HandlerCollection handlers = new HandlerCollection();
        HandlerList list = new HandlerList();

        // link them all together
        wrapper.setHandler(hello);
        list.setHandlers(new Handler[] { param, wrapper, dft });
        handlers.setHandlers(new Handler[] { list, requestLog });

        // Handler tree looks like the following
        // <pre>
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

        _server.setConnectors(new Connector[]{});
    }

    protected void configureServer(Handler handler) throws Exception
    {
        HandlerWrapper current = (HandlerWrapper)_server.getHandler();
        current.stop();
        current.setHandler(handler);
        current.start();
    }
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

        _connector = new ServerConnector(_server);
        _statistics = new ConnectorStatistics();
        _connector.addBean(_statistics);
        _server.addConnector(_connector);

        HandlerWrapper wrapper = new HandlerWrapper()
        {
            @Override
            public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
            {
                try
                {
                    _connect.await();
                }
                catch (Exception ex)
                {
                    LOG.debug(ex);
                }
                finally
                {
                    super.handle(path, request, httpRequest, httpResponse);
                }
            }
        };
        _server.setHandler(wrapper);

        Handler handler = new AbstractHandler()
        {
            @Override
            public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
                throws IOException, ServletException
            {
                try{Thread.sleep(1);} catch(Exception e){}
                baseRequest.setHandled(true);
                PrintWriter out = response.getWriter();
                out.write("Server response\n");
                out.close();

                response.setStatus(HttpServletResponse.SC_OK);
            }
        };
        wrapper.setHandler(handler);

        _server.start();
    }
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

    protected void startServer(ServerConnector connector) throws Exception
    {
        _connector = connector;
        _connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration().setSendDateHeader(false);
        _server.addConnector(_connector);
        _server.setHandler(new HandlerWrapper());
        _server.start();
        _serverURI = _server.getURI();
    }
View Full Code Here

Examples of org.eclipse.jetty.server.handler.HandlerWrapper

    @Test
    public void testHandlerBeforeServletHandler() throws Exception
    {
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
       
        HandlerWrapper extra = new HandlerWrapper();
       
        context.getSessionHandler().insertHandler(extra);
       
        context.addServlet(TestServlet.class,"/test");
        context.setContextPath("/");
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.