Package org.jboss.aerogear.controller.router

Examples of org.jboss.aerogear.controller.router.Route


        final Method targetMethod = routeContext.getRoute().getTargetMethod();
        return targetMethod.getParameterTypes().length == 0 ? new Object[] {} : new Object[] { t };
    }

    private RouteContext errorContext(final Throwable rootCause, final RouteContext orgContext) {
        final Route errorRoute = orgContext.getRoutes().routeFor(rootCause);
        return new RouteContext(errorRoute, wrapRequest(orgContext), orgContext.getResponse(), orgContext.getRoutes());
    }
View Full Code Here


     *
     * @throws Exception if access to the Route is denied.
     */
    @Override
    public InvocationResult process(final RouteContext routeContext) throws Exception {
        final Route route = routeContext.getRoute();
        if (route.isSecured()) {
            securityProvider.isRouteAllowed(route);
        }
        return delegate.process(routeContext);
    }
View Full Code Here

            @Override
            public void configuration() {
                route().from("/car/{id}").on(GET).produces(MediaType.JSON, custom).to(SampleController.class).find(param("id"));
            }
        }.build();
        final Route route = routes.routeFor(GET, "/car/1", acceptHeaders(MediaType.JSON.getType(), "application/custom"));
        assertThat(route.produces()).contains(MediaType.JSON, custom);
    }
View Full Code Here

            @Override
            public void configuration() throws Exception {
                route().from("/home").on(GET).to(SampleController.class).index();
            }
        }.build();
        Route route = routes.routeFor(new IllegalStateException());
        assertThat(route).isNotNull();
        assertThat(route.canHandle(new IllegalStateException())).isTrue();
        assertThat(route.canHandle(new Throwable())).isTrue();
        assertThat(route.getTargetClass()).isEqualTo(ErrorTarget.class);
    }
View Full Code Here

                route().on(SuperException.class).to(SampleController.class).superException();
                route().on(Exception.class).to(SampleController.class).error(param(Exception.class));
                route().from("/home").on(GET).to(SampleController.class).index();
            }
        }.build();
        final Route superErrorRoute = routes.routeFor(new SuperException());
        assertThat(superErrorRoute.canHandle(new SuperException())).isTrue();
        assertThat(superErrorRoute.canHandle(new SubException())).isTrue();
        assertThat(superErrorRoute.getTargetMethod().getName()).isEqualTo("superException");

        final Route subErrorRoute = routes.routeFor(new SubException());
        assertThat(subErrorRoute.canHandle(new SubException())).isTrue();
        assertThat(subErrorRoute.canHandle(new SuperException())).isFalse();
        assertThat(subErrorRoute.getTargetMethod().getName()).isEqualTo("subException");

        final Route genErrorRoute = routes.routeFor(new Exception());
        assertThat(genErrorRoute.canHandle(new SuperException())).isTrue();
        assertThat(genErrorRoute.canHandle(new SubException())).isTrue();
        assertThat(genErrorRoute.getTargetMethod().getName()).isEqualTo("error");
    }
View Full Code Here

    }

    @Test
    public void resolveCustomErrorPath() throws Exception {
        final ErrorViewResolver evs = new ErrorViewResolver(new JspViewResolver());
        final Route customErrorRoute = customErrorRoute(IllegalArgumentException.class);
        assertThat(evs.resolveViewPathFor(customErrorRoute)).isEqualTo("/WEB-INF/pages/ErrorTarget/errorPage.jsp");
    }
View Full Code Here

        return process(path);
    }

    public InvocationResult process(final String path) throws Exception {
        final String trimmed = mockRequest.extractQueryParameters(path);
        final Route route = routeFor(trimmed);
        return process(route);
    }
View Full Code Here

        } catch (final Throwable t) {
            if (t instanceof HttpStatusAwareException) {
                routeContext.getResponse().setStatus(((HttpStatusAwareException) t).getStatus());
            }
            final Throwable rootCause = Throwables.getRootCause(t);
            final Route errorRoute = routeContext.getRoutes().routeFor(rootCause);
            final RouteContext errorContext = new RouteContext(errorRoute, routeContext.getRequest(), routeContext.getResponse(), routeContext.getRoutes());
            final Object result = invokeErrorRoute(errorContext, rootCause);
            routeContext.getRequest().setAttribute(ErrorRoute.DEFAULT.getExceptionAttrName(), rootCause);
            responders.respond(errorContext, result);
        }
View Full Code Here

            responders.respond(errorContext, result);
        }
    }
   
    private Object invokeErrorRoute(final RouteContext routeContext, final Throwable t) throws ServletException {
        final Route errorRoute = routeContext.getRoute();
        Object response = null;
        try {
            final Method targetMethod = errorRoute.getTargetMethod();
            if (targetMethod.getParameterTypes().length == 0) {
                response =  targetMethod.invoke(getController(errorRoute));
            } else {
                response = targetMethod.invoke(getController(errorRoute), t);
            }
View Full Code Here

     *
     * @throws Exception if access to the Route is denied.
     */
    @Override
    public void process(final RouteContext routeContext) throws Exception {
        final Route route = routeContext.getRoute();
        if (route.isSecured()) {
            securityProvider.isRouteAllowed(route);
        }
        delegate.process(routeContext);
    }
View Full Code Here

TOP

Related Classes of org.jboss.aerogear.controller.router.Route

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.