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,
"captureExchange": false
}
}
The capture decorator can be configured to globally enable entity capture using the captureEntity
boolean attribute (default to false
).
To capture the exchange without the request and response at the capture point as well,
use the captureExchange boolean attribute (default to false
).
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.
|
Modifier and Type | Field and Description |
---|---|
static String |
CAPTURE_HEAP_KEY
Key to retrieve a
CaptureDecorator instance from the Heap . |
Constructor and Description |
---|
CaptureDecorator(LazyReference<LogSink> reference,
boolean captureEntity,
boolean captureExchange)
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,
org.forgerock.json.fluent.JsonValue decoratorConfig,
Context context)
|
protected Handler |
decorateHandler(Handler delegate,
org.forgerock.json.fluent.JsonValue decoratorConfig,
Context context)
|
accepts, decorate
public static final String CAPTURE_HEAP_KEY
CaptureDecorator
instance from the Heap
.public CaptureDecorator(LazyReference<LogSink> reference, boolean captureEntity, boolean captureExchange)
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
otherwisecaptureExchange
- true
if the decorator needs to capture the exchange excluding request and response,
false
otherwiseprotected Filter decorateFilter(Filter delegate, org.forgerock.json.fluent.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, org.forgerock.json.fluent.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 © 2014 ForgeRock AS. All rights reserved.