Interface Decorator

  • All Known Implementing Classes:
    AbstractDecorator, AbstractHandlerAndFilterDecorator, BaseUriDecorator, CaptureDecorator, GlobalDecorator, TimerDecorator

    public interface Decorator
    A Decorator is responsible for decorating existing object's instances.

    A Decorator cannot change the base type of the provided delegate: for example if the given instance is a Filter, the decorated (and returned) instance must also be a Filter, sub-classing is ok though.

    Decorators may be "global" to a heap or "local" to a component. Global decorators are applied to all components within the heap and any child heaps. Local decorators are only applied to their associated component. Decorators are applied such that inherited global decorators are applied first, then global decorators from the current heap, and finally local decorators. This means that requests will pass through decorators in the order local decorators, then global decorators, then inherited global decorators.

    Notice: This API is still considered experimental and is subject to change in subsequent releases.

    • Method Detail

      • accepts

        boolean accepts​(Class<?> type)
        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

        DecorationHandle decorate​(Object delegate,
                                  JsonValue decoratorConfig,
                                  Context context)
                           throws HeapException
        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