T
- public abstract class IOCDecoratorExtension<T extends Annotation> extends Object
For example, it may be desirable to register the instance of a newly created bean with a specific API as part of the bootstrapping code. A decorator makes this possible by making the IOC container's code generator reach out to a registered decorator associated with the specified annotation and providing the decorator an opportunity to return it's own generated code associated wth the instance value.
Decorators can be registered for any element type (classes, methods, constructors, fields, and parameters). And the type of element is automatically inferred by the element types which the registered annotation apply to.
Errai's own built in support for facilities such as @Service and @Observes implement their functionality as decorators.
Modifier | Constructor and Description |
---|---|
protected |
IOCDecoratorExtension(Class<T> decoratesWith) |
Modifier and Type | Method and Description |
---|---|
Class<T> |
decoratesWith() |
abstract List<?> |
generateDecorator(InjectableInstance<T> ctx)
The generateDecorator() method is called at the point the container has finished constructing a
reference to an element annotated with the configured annotation.
|
public abstract List<?> generateDecorator(InjectableInstance<T> ctx)
Note:
This method returns List<Object> instead of List<Statement> because this method is
always called with a raw type. To be applicable an unchecked conversion is necessary which causes the erasure
of the return type (JLS, Java SE 7 Edition, section 15.12.2.6).
This compiles with warnings with a JDK7 but fails regardless of the source-level with JDK 8.
See: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7144506
TODO: Remove calls with raw types to this method
ctx
- the InjectableInstance
reference, representing
the value of the element which is annotated.Copyright © 2013-2015 JBoss, a division of Red Hat. All Rights Reserved.