Class TimerDecorator

  • All Implemented Interfaces:
    Decorator

    public class TimerDecorator
    extends AbstractHandlerAndFilterDecorator
    The timer decorator can decorate both Filter and Handler instances. It will log elapsed time within the decorated heap object.

    It has to be declared inside of the heap objects section:

     
     {
       "name": "myTimerDecorator",
       "type": "TimerDecorator"
     }
     
     

    If you want to specify the time unit:

     
     {
       "name": "myTimerDecorator",
       "type": "TimerDecorator"
       "config": {
         "timeUnit": "ms"
       }
     }
     
     
    The value of the timeUnit is a single string representation of the elapsed time unit as those supported by Duration. An invalid string or non recognized time unit will throw an error.

    To decorate a component, just add the decorator declaration next to the config element:

     
     {
       "type": "...",
       "timer": true,
       "config": { ... }
     }
     
     
    A default timer decorator is automatically created when OpenIG starts.
    • Constructor Detail

      • TimerDecorator

        public TimerDecorator​(String name)
        Builds a new TimerDecorator where the elapsed time unit is milliseconds.
        Parameters:
        name - The name of this decorator.
      • TimerDecorator

        public TimerDecorator​(String name,
                              TimeUnit timeUnit)
        Builds a new TimerDecorator with the given TimeUnit reference (not null), which logs the elapsed time within the decorated heap object.
        Parameters:
        name - The name of this decorator.
        timeUnit - The TimeUnit of the elapsed time.
    • 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