Interface BaseExecutionContext
- All Known Subinterfaces:
BaseMessageExecutionContext,ExecutionContext,GenericExecutionContext,HttpBaseExecutionContext,HttpExecutionContext,HttpExecutionContext,HttpMessageExecutionContext,HttpPlainExecutionContext,KafkaConnectionContext,KafkaExecutionContext,KafkaMessageExecutionContext,MessageExecutionContext,NativeExecutionContext,NativeMessageExecutionContext,TcpExecutionContext,TcpExecutionContext
public interface BaseExecutionContext
Base interface any execution context interface can inherit from.
It defines the common concepts of an execution context (attributes, internal attributes, template engine, ...).
- Author:
- Jeoffrey HAEYAERT (jeoffrey.haeyaert at graviteesource.com), GraviteeSource Team
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescription<T> TgetAttribute(String name) Returns the value of the attribute cast in the expected type T, ornullif no attribute for the given name exists.<T> List<T>getAttributeAsList(String name) Return the attribute as an immutableList.Returns an Enumeration containing the names of the attributes available to this request.Get all attributes available.<T> TgetComponent(Class<T> componentClass) <T> TgetInternalAttribute(String name) Returns the value of the internal attribute cast in the expected type T, ornullif no attribute for the given name exists.Get all internal attributes available.io.gravitee.el.TemplateEngineGet theTemplateEnginethat can be used to evaluate EL expressions.Get theTracerthat can be used to trace any spans.Returns the Internet Protocol (IP) address of the interface on which the request was received.voidputAttribute(String name, Object value) Stores an attribute in this request.voidputInternalAttribute(String name, Object value) Stores an internal attribute in this request.Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.voidremoveAttribute(String name) Removes an attribute from this request.voidRemoves an internal attribute from this request.voidsetAttribute(String name, Object value) Same aputAttribute(String, Object).voidsetInternalAttribute(String name, Object value) longvoidwarnWith(ExecutionWarn warn) Adds a warning to the execution context without interrupting the flow.
-
Field Details
-
TEMPLATE_ATTRIBUTE_CONTEXT
- See Also:
-
-
Method Details
-
getComponent
-
setAttribute
Same aputAttribute(String, Object).- Parameters:
name- a String specifying the name of the attribute.value- the Object to be stored.
-
putAttribute
Stores an attribute in this request. Attributes are reset between requests. Note: prefer use ofputInternalAttribute(String, Object)in case the attribute is not set by the user itself.- Parameters:
name- a String specifying the name of the attribute.value- the Object to be stored.
-
removeAttribute
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.- Parameters:
name- the name of the attribute to remove.
-
getAttribute
Returns the value of the attribute cast in the expected type T, ornullif no attribute for the given name exists.- Type Parameters:
T- the expected type of the attribute value. SpecifyObjectif you expect value of any type.- Parameters:
name- the name of the attribute.- Returns:
- an Object containing the value of the attribute, or null if the attribute does not exist.
-
getAttributeAsList
Return the attribute as an immutableList. This method acts differently depending on the type of the attribute's value. Elements of theListare mapped as follows:For String:
- comma separated string are spitted and returned trimmed
- Parsable JSON Array elements are returned as strings (including objects)
- if none of the above, the string is simply wrapped
For Collection:
- Elements of the collection are wrapped in a new List
For Array:
- Each elements of the is wrapped into the returned List
For any other cases: the value is simply wrapped into the returned List. Notes: One calling
setAttribute(String, Object)with a mutable collection will retrieve an immutable one.- Type Parameters:
T- the expected type of the attribute value. SpecifyObjectif you expect value of any type.- Parameters:
name- the name of the attribute.- Returns:
- an immutable List with the attribute values.
-
getAttributeNames
Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it.- Returns:
- a set of strings containing the names of the request's attributes.
-
getAttributes
Get all attributes available.- Type Parameters:
T- the expected type of the attribute values. SpecifyObjectif you expect values of any types.- Returns:
- the list of all the attributes.
-
setInternalAttribute
- Parameters:
name- the name of the attribute.value- the Object to be stored.
-
putInternalAttribute
Stores an internal attribute in this request. Attributes are reset between requests. Internal attributes can be used to avoid mixin with attributes set by the user during the request processing.- Parameters:
name- the name of the attribute.value- the Object to be stored.
-
removeInternalAttribute
Removes an internal attribute from this request.- Parameters:
name- the name of the internal attribute to remove.
-
getInternalAttribute
Returns the value of the internal attribute cast in the expected type T, ornullif no attribute for the given name exists.- Type Parameters:
T- the expected type of the attribute value. SpecifyObjectif you expect value of any type.- Parameters:
name- a String specifying the name of the attribute.- Returns:
- an Object containing the value of the attribute, or null if the attribute does not exist
-
getInternalAttributes
Get all internal attributes available. Internal attributes are not intended to be manipulated by end-users. You can safely use internal attribute to temporary store useful objects required during different phases of the execution.- Type Parameters:
T- the expected type of the values. SpecifyObjectif you expect values of any types.- Returns:
- the list of all the internal attributes.
-
getTemplateEngine
io.gravitee.el.TemplateEngine getTemplateEngine()Get theTemplateEnginethat can be used to evaluate EL expressions.- Returns:
- the El
TemplateEngine.
-
getTracer
Tracer getTracer()Get theTracerthat can be used to trace any spans.- Returns:
- the
Tracercontextualized.
-
timestamp
long timestamp() -
remoteAddress
String remoteAddress()Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.- Returns:
- a
Stringcontaining the IP address of the client that sent the request.
-
localAddress
String localAddress()Returns the Internet Protocol (IP) address of the interface on which the request was received.- Returns:
- a
Stringcontaining the IP address on which the request was received.
-
tlsSession
TlsSession tlsSession()- Returns:
- TlsSession associated to the request. Acts as a SSLSession, with additional mechanisms. It can for example extract a client certificate from a given header.
- See Also:
-
warnWith
Adds a warning to the execution context without interrupting the flow. The warning will be stored and can be accessed later through metrics.
-