Class CaptureDecorator

  • All Implemented Interfaces:
    Decorator

    public class CaptureDecorator
    extends AbstractDecorator
    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 set a limit on the maximum length of entities to capture, use maxEntityLength and set it to a value in bytes, the default is 512K. To capture the context at the capture point as well, use the captureContext boolean attribute (default to false). To mask values from headers and/or values from the attributes context, use the optional masks section to match by header and/or attribute name and mask the actual value. The name to match can be a regular expression. To override the default mask value of *****, provide the optional mask to set a different mask value.
         
         {
           "name": "capture",
           "type": "CaptureDecorator",
           "config": {
               "masks": {
                  "headers": [ "x-token" ],
                  "attributes": [ "replay" ],
                  "mask": "*** my mask value ***"
               }
           }
         }
         
     

    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 IG 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
      • CaptureDecorator

        public CaptureDecorator​(String name,
                                boolean captureEntity,
                                boolean captureContext,
                                int maxEntityLength,
                                KeyValueProcessor headerProcessor,
                                KeyValueProcessor attributeProcessor,
                                KeyValueProcessor trailerProcessor)
        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
        maxEntityLength - Set the maximum entity length to capture if captureEntity is enabled.
        headerProcessor - The KeyValueProcessor to apply to header values.
        attributeProcessor - The KeyValueProcessor to apply to attribute values.
        trailerProcessor - The KeyValueProcessor to apply to trailer values.
    • Method Detail

      • accepts

        public boolean accepts​(Class<?> type)
        Description copied from interface: Decorator
        Returns true if this decorator is compatible with the provided component type. Note that a return value of true does not necessarily indicate that decoration will be performed since it may also depend on other factors
        Parameters:
        type - type under test
        Returns:
        true if the decorator can decorate instance of the given type, false otherwise.
      • decorate

        public DecorationHandle decorate​(Object delegate,
                                         JsonValue decoratorConfig,
                                         Context context)
                                  throws HeapException
        Description copied from interface: Decorator
        Decorates the provided delegate instance with the provided decoratorConfig configuration. The implementation should take care of not changing the base type of the delegate.
        Parameters:
        delegate - instance to be decorated
        decoratorConfig - the decorator configuration to apply
        context - contextual information of the decorated instance
        Returns:
        a handle of the decoration that was setup, never null.
        Throws:
        HeapException - when decoration fails