Interface Decorator
- All Known Implementing Classes:
AbstractDecorator
,AbstractHandlerAndFilterDecorator
,BaseUriDecorator
,CaptureDecorator
,GlobalDecorator
,NoOpGlobalDecorator
,TimerDecorator
,TracingDecorator
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 Summary
Modifier and TypeMethodDescriptionboolean
Returnstrue
if this decorator is compatible with the provided component type.Decorates the provideddelegate
instance with the provideddecoratorConfig
configuration.
-
Method Details
-
accepts
Returnstrue
if this decorator is compatible with the provided component type. Note that a return value oftrue
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 provideddelegate
instance with the provideddecoratorConfig
configuration. 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
-