Package org.atmosphere.interceptor
Class SimpleRestInterceptor
java.lang.Object
org.atmosphere.cpr.AtmosphereInterceptorAdapter
org.atmosphere.interceptor.SimpleRestInterceptor
- All Implemented Interfaces:
AtmosphereInterceptor,AtmosphereConfigAware,InvokationOrder
An Atmosphere interceptor to enable a simple rest binding protocol.
This protocol is a simplified version of SwaggerSocket with some new features
https://github.com/swagger-api/swaggersocket
This interceptor currently handles both Websocket and SSE protocols.
It was originally developed for enabling atmosphere for kafka-rest at
https://github.com/elakito/kafka-rest-atmosphere
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.atmosphere.interceptor.InvokationOrder
InvokationOrder.PRIORITY -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringstatic final StringThe internal header consisting of the {tracking-id}#{request-id}Fields inherited from interface org.atmosphere.interceptor.InvokationOrder
AFTER_DEFAULT, BEFORE_DEFAULT, FIRST_BEFORE_DEFAULT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(AtmosphereConfig config) Configure an AtmosphereFramework object.protected AtmosphereRequestcreateAtmosphereRequest(AtmosphereRequest request, String body) protected byte[]createResponse(AtmosphereResponse response, byte[] payload) protected static booleangetBoolean(tools.jackson.databind.JsonNode obj, String key) Read a boolean field from the parsed JSON header.protected Stringprotected Stringprotected Object[]protected static StringRead a string field from the parsed JSON header.Invoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.protected static booleanisJSONObject(byte[] b) protected static booleanisLastResponse(AtmosphereRequest request, AtmosphereResponse response) protected static tools.jackson.databind.JsonNodeparseJsonPart(Reader reader) Parse the JSON header part of a SwaggerSocket-style request body into a Jackson tree.protected static byte[]quote(byte[] b) Methods inherited from class org.atmosphere.cpr.AtmosphereInterceptorAdapter
destroy, postInspect, priority, toString
-
Field Details
-
X_REQUEST_KEY
The internal header consisting of the {tracking-id}#{request-id}- See Also:
-
REQUEST_DISPATCHED
- See Also:
-
REQUEST_ID
- See Also:
-
-
Constructor Details
-
SimpleRestInterceptor
public SimpleRestInterceptor()
-
-
Method Details
-
configure
Description copied from interface:AtmosphereConfigAwareConfigure an AtmosphereFramework object.- Specified by:
configurein interfaceAtmosphereConfigAware- Overrides:
configurein classAtmosphereInterceptorAdapter- Parameters:
config-AtmosphereConfig
-
inspect
Description copied from interface:AtmosphereInterceptorInvoked before anAtmosphereResourcegets dispatched toAtmosphereHandler.- Specified by:
inspectin interfaceAtmosphereInterceptor- Overrides:
inspectin classAtmosphereInterceptorAdapter- Parameters:
r- aAtmosphereResource- Returns:
Action.CONTINUEorAction.SUSPENDto dispatch theAtmosphereResourceto otherAtmosphereInterceptororAtmosphereHandler. ReturnAction.TYPE.CANCELLEDto stop the processing.
-
getHeartbeatBroadcasterName
-
getHeartbeatTemplate
-
getHeartbeatTemplateArguments
-
createAtmosphereRequest
protected AtmosphereRequest createAtmosphereRequest(AtmosphereRequest request, String body) throws IOException - Throws:
IOException
-
createResponse
-
isLastResponse
-
isJSONObject
protected static boolean isJSONObject(byte[] b) -
quote
protected static byte[] quote(byte[] b) -
parseJsonPart
Parse the JSON header part of a SwaggerSocket-style request body into a Jackson tree.API change in 4.0.42: the return type changed from a legacy third-party
JSONObjectto Jackson'sJsonNodewhen that legacy JSON dependency was dropped (CVE hygiene). External subclasses that read the parsed JSON should migrate toJsonNodeorObjectMapper.convertValue(java.lang.Object, java.lang.Class<T>)for a typed shape.- Throws:
IOException- when the input is not parseable JSON.
-
getString
Read a string field from the parsed JSON header. Returnsnullwhen the field is absent, null-valued, or non-textual — matching the legacygetStringswallow-on-miss semantic. -
getBoolean
Read a boolean field from the parsed JSON header. Returnsfalsewhen the field is absent, null-valued, or non-boolean — matching the legacygetBooleanswallow-on-miss semantic.
-