org.baswell.routes
Interface RouteInstancePool

All Known Implementing Classes:
DefaultRouteInstancePool

public interface RouteInstancePool

When routes are added to RoutingTable as class objects, a route instance must be used each time to process a HTTP request. This interface controls the lifecycle of those route instances.

See Also:
RoutesConfiguration.routeInstancePool

Method Summary
 java.lang.Object borrowRouteInstance(java.lang.Class routeClass)
          Called when a route match has been made to a method in the given class and an instance is needed to process the request.
 void returnRouteInstance(java.lang.Object routeInstance)
          The Routes engine is done using this route instance.
 

Method Detail

borrowRouteInstance

java.lang.Object borrowRouteInstance(java.lang.Class routeClass)
                                     throws RouteInstanceBorrowException
Called when a route match has been made to a method in the given class and an instance is needed to process the request. If the route class is not thread safe then once an instance is returned from this method it should not be used again until it's put back in the pool (returnRouteInstance).

Parameters:
routeClass - A route class that was added to the RoutingTable.
Returns:
A instance of the given route class this is ready to process an HTTP request.
Throws:
RouteInstanceBorrowException - If a route instance cannot be borrowed for any reason.

returnRouteInstance

void returnRouteInstance(java.lang.Object routeInstance)
The Routes engine is done using this route instance.

Parameters:
routeInstance - A route object previous retrieved from borrowRouteInstance.