Interface Decorator
-
- All Known Implementing Classes:
AbstractDecorator,AbstractHandlerAndFilterDecorator,BaseUriDecorator,CaptureDecorator,GlobalDecorator,TimerDecorator
public interface DecoratorA 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 aFilter, 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 Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleanaccepts(Class<?> type)Returnstrueif this decorator is compatible with the provided component type.DecorationHandledecorate(Object delegate, JsonValue decoratorConfig, Context context)Decorates the provideddelegateinstance with the provideddecoratorConfigconfiguration.
-
-
-
Method Detail
-
accepts
boolean accepts(Class<?> type)
Returnstrueif this decorator is compatible with the provided component type. Note that a return value oftruedoes not necessarily indicate that decoration will be performed since it may also depend on other factors- Parameters:
type- type under test- Returns:
trueif the decorator can decorate instance of the given type,falseotherwise.
-
decorate
DecorationHandle decorate(Object delegate, JsonValue decoratorConfig, Context context) throws HeapException
Decorates the provideddelegateinstance with the provideddecoratorConfigconfiguration. The implementation should take care of not changing the base type of the delegate.- Parameters:
delegate- instance to be decorateddecoratorConfig- the decorator configuration to applycontext- contextual information of the decorated instance- Returns:
- a handle of the decoration that was setup, never
null. - Throws:
HeapException- when decoration fails
-
-