aerogear-controller 1.0.2

org.jboss.aerogear.controller.router.rest.pagination
Class AbstractPaginationStrategy

java.lang.Object
  extended by org.jboss.aerogear.controller.router.rest.pagination.AbstractPaginationStrategy
All Implemented Interfaces:
PaginationStrategy

public abstract class AbstractPaginationStrategy
extends Object
implements PaginationStrategy

A PaginationStrategy that expects the target endpoint method to take a PaginationInfo as a parameter.

Subclasses can implement setResponseHeaders(PaginationMetadata, HttpServletResponse, int) to set the HTTP Response headers.


Constructor Summary
AbstractPaginationStrategy()
           
 
Method Summary
private  int argAsInt(Map<String,Object> args, String argName)
           
private  PaginationMetadata createMetadata(RouteContext routeContext, PaginationInfo pagingInfo)
           
 PaginationInfo createPaginationInfo(RouteContext routeContext, Map<String,Object> args)
          Creates a PaginationInfo instance.
private  String getResourcePath(RouteContext routeContext)
           
private  List<Object> merge(PaginationInfo paginationInfo, Map<String,Object> arguments)
           
 Object postInvocation(Collection<?> results, RouteContext routeContext, PaginationInfo pagingInfo)
          Called after the target endpoint method has been invoked and allows the strategy to set HTTP Response headers.
 Object[] preInvocation(PaginationInfo paginationInfo, Map<String,Object> arguments)
          Called before the target endpoint method has been invoked and enables a concrete strategy to manipulate the arguments that will be passed to the target endpoint method.
abstract  void setResponseHeaders(PaginationMetadata metadata, javax.servlet.http.HttpServletResponse response, int resultSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPaginationStrategy

public AbstractPaginationStrategy()
Method Detail

setResponseHeaders

public abstract void setResponseHeaders(PaginationMetadata metadata,
                                        javax.servlet.http.HttpServletResponse response,
                                        int resultSize)

createPaginationInfo

public PaginationInfo createPaginationInfo(RouteContext routeContext,
                                           Map<String,Object> args)
Description copied from interface: PaginationStrategy
Creates a PaginationInfo instance. How this information is gathered, be it from an Annotation on the target endpoint method, or by using separate request parameters is up to the concrete implementation.

Specified by:
createPaginationInfo in interface PaginationStrategy
Parameters:
routeContext - the RouteContext of the route being processed.
args - the extracted arguments from the current request.
Returns:
PaginationInfo the information required for paging.

preInvocation

public Object[] preInvocation(PaginationInfo paginationInfo,
                              Map<String,Object> arguments)
Description copied from interface: PaginationStrategy
Called before the target endpoint method has been invoked and enables a concrete strategy to manipulate the arguments that will be passed to the target endpoint method.

Specified by:
preInvocation in interface PaginationStrategy
Parameters:
paginationInfo - the PaginationInfo instance created by this strategy.
arguments - the extracted arguments from the current request.
Returns:
Object[] the arguments that will be passed to the target endpoint method.

merge

private List<Object> merge(PaginationInfo paginationInfo,
                           Map<String,Object> arguments)

postInvocation

public Object postInvocation(Collection<?> results,
                             RouteContext routeContext,
                             PaginationInfo pagingInfo)
Description copied from interface: PaginationStrategy
Called after the target endpoint method has been invoked and allows the strategy to set HTTP Response headers.

Specified by:
postInvocation in interface PaginationStrategy
Parameters:
results - the result returned from the target endpoint method.
routeContext - the RouteContext.
pagingInfo - the PaginationInfo instance created by this strategy.
Returns:
Object Either the unchanged result or a modified result depending on the underlying implementation.

createMetadata

private PaginationMetadata createMetadata(RouteContext routeContext,
                                          PaginationInfo pagingInfo)

getResourcePath

private String getResourcePath(RouteContext routeContext)

argAsInt

private int argAsInt(Map<String,Object> args,
                     String argName)

aerogear-controller 1.0.2

Copyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.