Package org.apache.wink.server.handlers

Examples of org.apache.wink.server.handlers.RequestHandlersChain


     * but <tt>initRequestUserHandlers</tt> instead.
     *
     * @see initRequestUserHandlers
     */
    protected RequestHandlersChain initRequestHandlersChain() {
        RequestHandlersChain handlersChain = new RequestHandlersChain();
        handlersChain.addHandler(createHandler(SearchResultHandler.class));
        handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
        handlersChain.addHandler(createHandler(HeadMethodHandler.class));
        handlersChain.addHandler(createHandler(FindRootResourceHandler.class));
        handlersChain.addHandler(createHandler(FindResourceMethodHandler.class));
        handlersChain.addHandler(createHandler(CreateInvocationParametersHandler.class));
        for (RequestHandler h : requestUserHandlers) {
            h.init(properties);
            handlersChain.addHandler(h);
        }
        handlersChain.addHandler(createHandler(InvokeMethodHandler.class));
        return handlersChain;
    }
View Full Code Here


     * but <tt>initRequestUserHandlers</tt> instead.
     *
     * @see initRequestUserHandlers
     */
    protected RequestHandlersChain initRequestHandlersChain() {
        RequestHandlersChain handlersChain = new RequestHandlersChain();
        handlersChain.addHandler(createHandler(SearchResultHandler.class));
        handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
        handlersChain.addHandler(createHandler(HeadMethodHandler.class));
        handlersChain.addHandler(createHandler(FindRootResourceHandler.class));
        handlersChain.addHandler(createHandler(FindResourceMethodHandler.class));
        handlersChain.addHandler(createHandler(CreateInvocationParametersHandler.class));
        if (requestUserHandlers != null) {
            for (RequestHandler h : requestUserHandlers) {
                h.init(properties);
                handlersChain.addHandler(h);
            }
        }
        handlersChain.addHandler(createHandler(InvokeMethodHandler.class));
        logger.debug("Request handlers chain is: {}", handlersChain);
        return handlersChain;
    }
View Full Code Here

     * but <tt>initRequestUserHandlers</tt> instead.
     *
     * @see initRequestUserHandlers
     */
    protected RequestHandlersChain initRequestHandlersChain() {
        RequestHandlersChain handlersChain = new RequestHandlersChain();
        handlersChain.addHandler(createHandler(SearchResultHandler.class));
        handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
        handlersChain.addHandler(createHandler(HeadMethodHandler.class));
        handlersChain.addHandler(createHandler(FindRootResourceHandler.class));
        handlersChain.addHandler(createHandler(FindResourceMethodHandler.class));
        handlersChain.addHandler(createHandler(CreateInvocationParametersHandler.class));
        if (requestUserHandlers != null) {
            for (RequestHandler h : requestUserHandlers) {
                h.init(properties);
                handlersChain.addHandler(h);
            }
        }
        handlersChain.addHandler(createHandler(InvokeMethodHandler.class));
        logger.debug("Request handlers chain is: {}", handlersChain); //$NON-NLS-1$
        return handlersChain;
    }
View Full Code Here

     * but <tt>initRequestUserHandlers</tt> instead.
     *
     * @see initRequestUserHandlers
     */
    protected RequestHandlersChain initRequestHandlersChain() {
        RequestHandlersChain handlersChain = new RequestHandlersChain();
        handlersChain.addHandler(createHandler(SearchResultHandler.class));
        handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
        handlersChain.addHandler(createHandler(HeadMethodHandler.class));
        handlersChain.addHandler(createHandler(FindRootResourceHandler.class));
        handlersChain.addHandler(createHandler(FindResourceMethodHandler.class));
        handlersChain.addHandler(createHandler(CreateInvocationParametersHandler.class));
        if (requestUserHandlers != null) {
            for (RequestHandler h : requestUserHandlers) {
                h.init(properties);
                handlersChain.addHandler(h);
            }
        }
        handlersChain.addHandler(createHandler(InvokeMethodHandler.class));
        logger.debug("Request handlers chain is: {}", handlersChain); //$NON-NLS-1$
        return handlersChain;
    }
View Full Code Here

        public void init(Properties props) {
        }
    }

    public void testRequestChain() throws Throwable {
        RequestHandlersChain chain = new RequestHandlersChain();
        chain.addHandler(new Handler1());
        chain.addHandler(new Handler2());
        chain.addHandler(new Handler3());

        chain.run(null);
        assertEquals(1, Handler1.requests);
        assertEquals(1, Handler2.requests);
        assertEquals(1, Handler3.requests);

        chain.run(null);
        assertEquals(2, Handler1.requests);
        assertEquals(2, Handler2.requests);
        assertEquals(3, Handler3.requests);

        chain.run(null);
        assertEquals(3, Handler1.requests);
        assertEquals(4, Handler2.requests);
        assertEquals(3, Handler3.requests);

        chain.run(null);
        assertEquals(4, Handler1.requests);
        assertEquals(4, Handler2.requests);
        assertEquals(3, Handler3.requests);
    }
View Full Code Here

        assertEquals(4, Handler2.responses);
        assertEquals(3, Handler3.responses);
    }

    public void testHandlerThrowingException() throws Throwable {
        RequestHandlersChain chain = new RequestHandlersChain();
        chain.addHandler(new HandlerException1());
        chain.addHandler(new HandlerException2());
        chain.addHandler(new HandlerException3());

        chain.run(null);
        assertEquals(2, HandlerException2.requests);
        assertEquals(3, HandlerException3.requests);
    }
View Full Code Here

        public void init(Properties props) {
        }
    }

    public void testRequestChain() throws Throwable {
        RequestHandlersChain chain = new RequestHandlersChain();
        chain.addHandler(new Handler1());
        chain.addHandler(new Handler2());
        chain.addHandler(new Handler3());

        chain.run(null);
        assertEquals(1, Handler1.requests);
        assertEquals(1, Handler2.requests);
        assertEquals(1, Handler3.requests);

        chain.run(null);
        assertEquals(2, Handler1.requests);
        assertEquals(2, Handler2.requests);
        assertEquals(3, Handler3.requests);

        chain.run(null);
        assertEquals(3, Handler1.requests);
        assertEquals(4, Handler2.requests);
        assertEquals(3, Handler3.requests);

        chain.run(null);
        assertEquals(4, Handler1.requests);
        assertEquals(4, Handler2.requests);
        assertEquals(3, Handler3.requests);
    }
View Full Code Here

        assertEquals(4, Handler2.responses);
        assertEquals(3, Handler3.responses);
    }

    public void testHandlerThrowingException() throws Throwable {
        RequestHandlersChain chain = new RequestHandlersChain();
        chain.addHandler(new HandlerException1());
        chain.addHandler(new HandlerException2());
        chain.addHandler(new HandlerException3());

        chain.run(null);
        assertEquals(2, HandlerException2.requests);
        assertEquals(3, HandlerException3.requests);
    }
View Full Code Here

     *
     * @see initRequestUserHandlers
     */
    @SuppressWarnings("unchecked")
    protected RequestHandlersChain initRequestHandlersChain() {
        RequestHandlersChain handlersChain = new RequestHandlersChain();
        handlersChain.addHandler(createHandler(Requests.class));
        handlersChain.addHandler(createHandler(ResourceInvocation.class));
        handlersChain.addHandler(createHandler(SearchResultHandler.class));
        String optionsHandler =
            properties.getProperty("org.apache.wink.server.options.handler",
                                   OptionsMethodHandler.class.getName());
        if ("none".equals(optionsHandler)) {
            optionsHandler = OptionsMethodHandler.class.getName();
        }
        logger.trace("org.apache.wink.server.options.handler value is {}", optionsHandler);
        try {
            handlersChain.addHandler(createHandler((Class<? extends RequestHandler>)Class
                .forName(optionsHandler)));
        } catch (Exception e) {
            logger.trace("Could not load handlers class so adding default");
            handlersChain.addHandler(createHandler(OptionsMethodHandler.class));
        }

        handlersChain.addHandler(createHandler(HeadMethodHandler.class));
        handlersChain.addHandler(createHandler(FindRootResourceHandler.class));
        handlersChain.addHandler(createHandler(FindResourceMethodHandler.class));
        handlersChain.addHandler(createHandler(CreateInvocationParametersHandler.class));
        if (requestUserHandlers != null) {
            for (RequestHandler h : requestUserHandlers) {
                h.init(properties);
                handlersChain.addHandler(h);
            }
        }
        handlersChain.addHandler(createHandler(InvokeMethodHandler.class));
        logger.trace("Request handlers chain is: {}", handlersChain); //$NON-NLS-1$
        return handlersChain;
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.server.handlers.RequestHandlersChain

Copyright © 2018 www.massapicom. 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.