public class CaptureDecorator extends AbstractHandlerAndFilterDecorator
Filter
and Handler
instances. It enables
the user to see the messages coming in and out of the decorated object.
Multiple input/output can be intercepted:
CapturePoint.ALL
: Prints all of the messagesCapturePoint.FILTERED_REQUEST
: Prints the outgoing request (Filter only)CapturePoint.FILTERED_RESPONSE
: Prints the outgoing responseCapturePoint.REQUEST
: Prints incoming + outgoing requestCapturePoint.RESPONSE
: Prints incoming + outgoing response
{
"name": "capture",
"type": "CaptureDecorator",
"config": {
"captureEntity": false,
"captureContext": false
}
}
The capture decorator can be configured to globally enable entity capture using the captureEntity
boolean attribute (default to false
).
To capture the context at the capture point as well, use the captureContext boolean attribute
(default to false
), Note that captureExchange is deprecated.
The common logSink attribute can be used to force message capture in a given sink. By default, messages
are sent to the heap object defined LogSink.
To decorate a component, just add the decorator declaration next to the config
element:
{
"type": "...",
"capture": [ "FILTERED_REQUEST", "RESPONSE" ],
"config": { ... }
}
Notice that the attribute name in the decorated object has to be the same as the decorator
heap object name (capture
in our example).
A default capture decorator is automatically created when OpenIG starts. It can be overridden
in the configuration files if default values are not satisfying.Modifier and Type | Class and Description |
---|---|
static class |
CaptureDecorator.Heaplet
Creates and initializes a CaptureDecorator in a heap environment.
|
Constructor and Description |
---|
CaptureDecorator(LazyReference<LogSink> reference,
boolean captureEntity,
boolean captureContext)
Builds a new
capture decorator with the given sink reference (possibly null )
printing (or not) the entity content. |
Modifier and Type | Method and Description |
---|---|
protected Filter |
decorateFilter(Filter delegate,
JsonValue decoratorConfig,
Context context)
|
protected Handler |
decorateHandler(Handler delegate,
JsonValue decoratorConfig,
Context context)
|
accepts, decorate
public CaptureDecorator(LazyReference<LogSink> reference, boolean captureEntity, boolean captureContext)
capture
decorator with the given sink reference (possibly null
)
printing (or not) the entity content.
If the sink
is specified (not null
), every message intercepted by this decorator will be
send to the provided sink.reference
- Log Sink reference for message capture (may be null
)captureEntity
- true
if the decorator needs to capture the entity, false
otherwisecaptureContext
- true
if the decorator needs to capture the context,
false
otherwiseprotected Filter decorateFilter(Filter delegate, JsonValue decoratorConfig, Context context) throws HeapException
AbstractHandlerAndFilterDecorator
decorateFilter
in class AbstractHandlerAndFilterDecorator
delegate
- Filter instance to be decorateddecoratorConfig
- the decorator configuration to applycontext
- contextual information of the decorated instanceHeapException
- when decoration failsprotected Handler decorateHandler(Handler delegate, JsonValue decoratorConfig, Context context) throws HeapException
AbstractHandlerAndFilterDecorator
decorateHandler
in class AbstractHandlerAndFilterDecorator
delegate
- Handler instance to be decorateddecoratorConfig
- the decorator configuration to applycontext
- contextual information of the decorated instanceHeapException
- when decoration failsCopyright 2011-2015 ForgeRock AS.