Class RateLimitingWebServiceHandlerPlugin
- java.lang.Object
-
- io.vertigo.vega.plugins.webservice.handler.RateLimitingWebServiceHandlerPlugin
-
- All Implemented Interfaces:
io.vertigo.core.node.component.CoreComponent
,io.vertigo.core.node.component.Plugin
,io.vertigo.core.node.definition.DefinitionProvider
,io.vertigo.core.node.definition.SimpleDefinitionProvider
,WebServiceHandlerPlugin
public final class RateLimitingWebServiceHandlerPlugin extends Object implements WebServiceHandlerPlugin, io.vertigo.core.node.definition.SimpleDefinitionProvider
Rate limit handler.- Author:
- npiedeloup
-
-
Field Summary
Fields Modifier and Type Field Description static int
STACK_INDEX
Stack index of the handler for sorting at startup
-
Constructor Summary
Constructors Constructor Description RateLimitingWebServiceHandlerPlugin(VSecurityManager securityManager, io.vertigo.core.daemon.DaemonManager daemonManager, Optional<Integer> windowSeconds, Optional<Long> limitValue)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
accept(WebServiceDefinition webServiceDefinition)
int
getStackIndex()
Return an index to compute the order of the handlers stack.Object
handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebServiceCallContext routeContext, HandlerChain chain)
Do handle of this route.List<? extends io.vertigo.core.node.definition.Definition>
provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
STACK_INDEX
public static final int STACK_INDEX
Stack index of the handler for sorting at startup- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RateLimitingWebServiceHandlerPlugin
@Inject public RateLimitingWebServiceHandlerPlugin(VSecurityManager securityManager, io.vertigo.core.daemon.DaemonManager daemonManager, Optional<Integer> windowSeconds, Optional<Long> limitValue)
Constructor.- Parameters:
windowSeconds
- the time windows use to limit calls ratelimitValue
- the rate limit ceiling valuesecurityManager
- Security ManagerdaemonManager
- Manager des daemons
-
-
Method Detail
-
provideDefinitions
public List<? extends io.vertigo.core.node.definition.Definition> provideDefinitions(io.vertigo.core.node.definition.DefinitionSpace definitionSpace)
- Specified by:
provideDefinitions
in interfaceio.vertigo.core.node.definition.SimpleDefinitionProvider
-
accept
public boolean accept(WebServiceDefinition webServiceDefinition)
- Specified by:
accept
in interfaceWebServiceHandlerPlugin
- Parameters:
webServiceDefinition
- WebServiceDefinition- Returns:
- If this handler should be use for this webService
-
handle
public Object handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, WebServiceCallContext routeContext, HandlerChain chain) throws SessionException
Do handle of this route.- Specified by:
handle
in interfaceWebServiceHandlerPlugin
- Parameters:
request
- Requestresponse
- ResponserouteContext
- Context of this requestchain
- current HandlerChain.- Returns:
- Response body
- Throws:
SessionException
- Session expired exception
-
getStackIndex
public int getStackIndex()
Description copied from interface:WebServiceHandlerPlugin
Return an index to compute the order of the handlers stack. Please check the index of the provided handlers by vertigo and choose the index for yours accordingly. Vertigo's handlers start à 10 and leave a space of 10 between each. The last handler must beRestfulServiceWebServiceHandlerPlugin
which has the index 120. Therefore the provided index must be between 0 and 119- Specified by:
getStackIndex
in interfaceWebServiceHandlerPlugin
- Returns:
- the index (between 0 and 119)
-
-