Package org.swisspush.gateleen.hook
Class HttpHook
- java.lang.Object
-
- org.swisspush.gateleen.hook.HttpHook
-
public class HttpHook extends Object
Represents a hook.- Author:
- https://github.com/ljucam [Mario Ljuca]
-
-
Field Summary
Fields Modifier and Type Field Description static intCONNECTION_MAX_WAIT_QUEUE_SIZE_DEFAULT_VALUEstatic StringCONNECTION_MAX_WAIT_QUEUE_SIZE_PROPERTY_NAMEstatic intCONNECTION_POOL_SIZE_DEFAULT_VALUEstatic StringCONNECTION_POOL_SIZE_PROPERTY_NAMEstatic intCONNECTION_TIMEOUT_SEC_DEFAULT_VALUEstatic StringCONNECTION_TIMEOUT_SEC_PROPERTY_NAME
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddTranslateStatus(Pattern key, Integer value)IntegergetConnectionPoolSize()StringgetDestination()The destination of the hook.Optional<org.joda.time.DateTime>getExpirationTime()PatterngetFilter()Returns the precompiled pattern, to match a given url.org.swisspush.gateleen.core.http.HeaderFunctiongetHeaderFunction()PatterngetHeadersFilterPattern()HookTriggerTypegetHookTriggerType()Retuns the trigger type of the hook.IntegergetMaxWaitQueueSize()List<String>getMethods()Returns the methods which should pass the hook.io.vertx.core.net.ProxyOptionsgetProxyOptions()Get custom proxy options for this hookintgetQueueExpireAfter()Gets the expiry (x-queue-expire-after header) for the requests in the queue send to the listener.QueueingStrategygetQueueingStrategy()Returns the queueing strategy for the hookIntegergetTimeout()Map<Pattern,Integer>getTranslateStatus()booleanisCollection()Indicates if a hook points to a collection (default: true) or not.booleanisFullUrl()Returns whether the hook forwards using the full initial url or only the appendix.booleanisListable()Indicates if a route hook should be listed for a GET request or not.voidsetCollection(boolean collection)Sets if a hook points to a collection (default: true) or not.voidsetConnectionPoolSize(Integer connectionPoolSize)voidsetDestination(String destination)Sets the destination of the hook.voidsetExpirationTime(org.joda.time.DateTime expirationTime)Sets the expiration time of this hook.voidsetFilter(String regex)Set a regexp to filter the hook.voidsetFullUrl(boolean fullUrl)Sets whether the hook forwards using the full initial url or only the appendix.voidsetHeaderFunction(org.swisspush.gateleen.core.http.HeaderFunction headerFunction)voidsetHeadersFilterPattern(Pattern headersFilterPattern)voidsetHookTriggerType(HookTriggerType hookTriggerType)Sets the trigger type of the hook.voidsetListable(boolean listable)Sets if a route hook should be listed for a GET request or not.voidsetMaxWaitQueueSize(Integer maxWaitQueueSize)voidsetMethods(List<String> methods)Sets the methods which should pass the hook.voidsetProxyOptions(io.vertx.core.net.ProxyOptions proxyOptions)Set custom proxy options for this hookvoidsetQueueExpireAfter(int queueExpireAfter)Sets the expiry (x-queue-expire-after header) for the requests in the queue send to the listener.voidsetQueueingStrategy(QueueingStrategy queueingStrategy)Sets the queueing strategy for the hookvoidsetTimeout(Integer timeout)SeegetTimeout().
-
-
-
Field Detail
-
CONNECTION_POOL_SIZE_PROPERTY_NAME
public static final String CONNECTION_POOL_SIZE_PROPERTY_NAME
- See Also:
- Constant Field Values
-
CONNECTION_MAX_WAIT_QUEUE_SIZE_PROPERTY_NAME
public static final String CONNECTION_MAX_WAIT_QUEUE_SIZE_PROPERTY_NAME
- See Also:
- Constant Field Values
-
CONNECTION_POOL_SIZE_DEFAULT_VALUE
public static final int CONNECTION_POOL_SIZE_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
CONNECTION_MAX_WAIT_QUEUE_SIZE_DEFAULT_VALUE
public static final int CONNECTION_MAX_WAIT_QUEUE_SIZE_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
CONNECTION_TIMEOUT_SEC_PROPERTY_NAME
public static final String CONNECTION_TIMEOUT_SEC_PROPERTY_NAME
- See Also:
- Constant Field Values
-
CONNECTION_TIMEOUT_SEC_DEFAULT_VALUE
public static final int CONNECTION_TIMEOUT_SEC_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HttpHook
public HttpHook(String destination)
Creates a new hook.- Parameters:
destination- destination
-
-
Method Detail
-
getDestination
public String getDestination()
The destination of the hook.- Returns:
- String
-
setDestination
public void setDestination(String destination)
Sets the destination of the hook.- Parameters:
destination- destination
-
getMethods
public List<String> getMethods()
Returns the methods which should pass the hook.- Returns:
- a list of HTTP methods or empty, if all methods do pass.
-
setMethods
public void setMethods(List<String> methods)
Sets the methods which should pass the hook.- Parameters:
methods- a list of HTTP methods or empty, if all methods do pass.
-
getHeadersFilterPattern
public Pattern getHeadersFilterPattern()
-
setHeadersFilterPattern
public void setHeadersFilterPattern(Pattern headersFilterPattern)
-
getExpirationTime
public Optional<org.joda.time.DateTime> getExpirationTime()
- Returns:
- Expiration time of this hook. This is null for hooks with infinite expiration.
-
setExpirationTime
public void setExpirationTime(org.joda.time.DateTime expirationTime)
Sets the expiration time of this hook.- Parameters:
expirationTime- expirationTime
-
isFullUrl
public boolean isFullUrl()
Returns whether the hook forwards using the full initial url or only the appendix.- Returns:
- fullUrl
-
setFullUrl
public void setFullUrl(boolean fullUrl)
Sets whether the hook forwards using the full initial url or only the appendix.- Parameters:
fullUrl- fullUrl
-
getQueueingStrategy
public QueueingStrategy getQueueingStrategy()
Returns the queueing strategy for the hook- Returns:
- queueingStrategy
-
setQueueingStrategy
public void setQueueingStrategy(QueueingStrategy queueingStrategy)
Sets the queueing strategy for the hook- Parameters:
queueingStrategy-
-
getFilter
public Pattern getFilter()
Returns the precompiled pattern, to match a given url.- Returns:
- - a precompiled pattern
-
setFilter
public void setFilter(String regex)
Set a regexp to filter the hook.- Parameters:
regex- - a regular expression
-
getQueueExpireAfter
public int getQueueExpireAfter()
Gets the expiry (x-queue-expire-after header) for the requests in the queue send to the listener. A -1 means that no expiry is set (the header will not be set).- Returns:
- a value in seconds
-
setQueueExpireAfter
public void setQueueExpireAfter(int queueExpireAfter)
Sets the expiry (x-queue-expire-after header) for the requests in the queue send to the listener. A -1 means that no expiry is set (the header will not be set!).- Parameters:
queueExpireAfter- - a value in seconds
-
getHeaderFunction
public org.swisspush.gateleen.core.http.HeaderFunction getHeaderFunction()
-
setHeaderFunction
public void setHeaderFunction(org.swisspush.gateleen.core.http.HeaderFunction headerFunction)
-
getHookTriggerType
public HookTriggerType getHookTriggerType()
Retuns the trigger type of the hook.- Returns:
- the trigger type of the hook
-
setHookTriggerType
public void setHookTriggerType(HookTriggerType hookTriggerType)
Sets the trigger type of the hook. If nothing is set, the default value is 'before'.- Parameters:
hookTriggerType- the trigger type of the hook
-
isListable
public boolean isListable()
Indicates if a route hook should be listed for a GET request or not.- Returns:
- true if the route hook should be listed
-
setListable
public void setListable(boolean listable)
Sets if a route hook should be listed for a GET request or not.- Parameters:
listable- true if the route hook should be listed
-
isCollection
public boolean isCollection()
Indicates if a hook points to a collection (default: true) or not.- Returns:
- true (default) if hook points to collection.
-
setCollection
public void setCollection(boolean collection)
Sets if a hook points to a collection (default: true) or not.- Parameters:
collection- true (default) if hook points to collection.
-
getConnectionPoolSize
public Integer getConnectionPoolSize()
- Returns:
- Max count of connections made to configured destination. This may returning null in case there's no value specified. Callers may catch that by fall back to a default.
-
setConnectionPoolSize
public void setConnectionPoolSize(Integer connectionPoolSize)
-
getMaxWaitQueueSize
public Integer getMaxWaitQueueSize()
- Returns:
- Maximum number of requests allowed in the wait queue. This may returning null in case there's no value specified. Callers may catch that by fall back to a default.
-
setMaxWaitQueueSize
public void setMaxWaitQueueSize(Integer maxWaitQueueSize)
-
getTimeout
@Nullable public Integer getTimeout()
- Returns:
- Timeout for request in milliseconds. Defines the time up until an ongoing request will be aborted if there was no reply given before. This may returning null in case there's no value specified. Callers may catch that by fall back to a default.
-
setTimeout
public void setTimeout(Integer timeout)
SeegetTimeout().
-
getProxyOptions
public io.vertx.core.net.ProxyOptions getProxyOptions()
Get custom proxy options for this hook- Returns:
- Custom proxy options or
null
-
setProxyOptions
public void setProxyOptions(io.vertx.core.net.ProxyOptions proxyOptions)
Set custom proxy options for this hook- Parameters:
proxyOptions- the custom proxy options to set
-
-