Yep, that makes sense. I'll extract it a method but keep the actual
invocation outside of this method. I'll push and you can take a look as see
what you think.


On 23 January 2013 15:47, Bruno Oliveira <notifications@github.com> wrote:

> In
> src/main/java/org/jboss/aerogear/controller/router/DefaultRouteProcessor.java:
>
> > @@ -60,9 +68,37 @@ public DefaultRouteProcessor(BeanManager beanManager, Instance<Consumer> consume
> >      @Override
> >      public void process(RouteContext routeContext) throws Exception {
> >          final Route route = routeContext.getRoute();
> > -        final Object[] arguments = extractArguments(routeContext, consumers);
> > -        final Object result = route.getTargetMethod().invoke(getController(route), arguments);
> > -        responders.respond(routeContext, result);
> > +        final Map<String, Object> arguments = extractArguments(routeContext, consumers);
> > +        if (hasPaginatedAnnotation(route.getTargetMethod())) {
> > +            processPaged(routeContext, arguments);
> > +        } else {
> > +            responders.respond(routeContext, route.getTargetMethod().invoke(getController(route), arguments.values().toArray()));
> > +        }
> > +    }
> > +
>
> Hi @danbev <https://github.com/danbev> might be interesting to extract
> the method below. I don't have a perfect idea now, but something like this
> might work:
>
> private Object extractPaginationParameters(Map<String, Object> arguments, Route route, PagingStrategy pagingStrategy) throws IllegalAccessException, InvocationTargetException {
>     final PaginationInfo pagingationInfo = pagingStrategy.getPagingationInfo();
>     final List<Object> pagingArgs = new LinkedList<Object>();
>
>     arguments.remove(pagingationInfo.getOffsetParamName());
>     arguments.remove(pagingationInfo.getLimitParamName());
>
>     pagingArgs.add(pagingationInfo);
>     pagingArgs.addAll(arguments.values());
>
>     return route.getTargetMethod().invoke(getController(route), pagingArgs.toArray());
> }
>
> Wdyt?
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/aerogear/aerogear-controller/pull/43/files#r2742278>.
>
>