Class CaptureDecorator

  • All Implemented Interfaces:
    Decorator

    public class CaptureDecorator
    extends AbstractHandlerAndFilterDecorator
    The capture decorator can decorates both 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:

    Notice that camel case is not important: all equals ALL and even AlL. It has to be declared inside of the heap objects section:
         
         {
           "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).

    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.
    • Constructor Detail

      • CaptureDecorator

        public CaptureDecorator​(String name,
                                boolean captureEntity,
                                boolean captureContext)
        Builds a new capture decorator.
        Parameters:
        name - The name of this decorator
        captureEntity - true if the decorator needs to capture the entity, false otherwise
        captureContext - true if the decorator needs to capture the context, false otherwise
    • Method Detail

      • decorateFilter

        protected org.forgerock.http.Filter decorateFilter​(org.forgerock.http.Filter delegate,
                                                           org.forgerock.json.JsonValue decoratorConfig,
                                                           Context context)
                                                    throws HeapException
        Description copied from class: AbstractHandlerAndFilterDecorator
        Decorates the provided delegate Filter instance with the provided decoratorConfig configuration.
        Specified by:
        decorateFilter in class AbstractHandlerAndFilterDecorator
        Parameters:
        delegate - Filter instance to be decorated
        decoratorConfig - the decorator configuration to apply
        context - contextual information of the decorated instance
        Returns:
        a decorated filter instance (or original filter delegate)
        Throws:
        HeapException - when decoration fails
      • decorateHandler

        protected org.forgerock.http.Handler decorateHandler​(org.forgerock.http.Handler delegate,
                                                             org.forgerock.json.JsonValue decoratorConfig,
                                                             Context context)
                                                      throws HeapException
        Description copied from class: AbstractHandlerAndFilterDecorator
        Decorates the provided delegate Handler instance with the provided decoratorConfig configuration.
        Specified by:
        decorateHandler in class AbstractHandlerAndFilterDecorator
        Parameters:
        delegate - Handler instance to be decorated
        decoratorConfig - the decorator configuration to apply
        context - contextual information of the decorated instance
        Returns:
        a decorated handler instance (or original handler delegate)
        Throws:
        HeapException - when decoration fails