Package org.jvnet.hk2.config
Annotation Type GenerateServiceFromMethod
-
@Documented @Retention(RUNTIME) @Target(ANNOTATION_TYPE) public @interface GenerateServiceFromMethod
This annotation is put on user-supplied annotations in order to cause the hk2-inhabitant-generator tool to create descriptors with certain properties.The user-supplied annotation must have the following properties:
- Must only apply to methods (or classes also annotated with
Decorator
) - Must be available at runtime
- Must only be applied to interfaces marked with
Configured
- May have one or zero String fields marked with
GeneratedServiceName
) or which take a single parameter and a void return type may be annotated with the user-supplied annotation. The parameterized actual type (or the type of the parameter) will end up being used as a field in the descriptor. A single method may have multiple user-supplied annotations marked with this annotation, in which case a different descriptor will be generated for each user-supplied annotation. When a method on an
Configured
interface has a user-supplied annotation that is annotated with this interface the hk2-inhabitant-generator will generate a service descriptor with the following properties:- The implementation class will be as specified in this annotation
- The available contracts will be as specified in this annotation
- The scope will be as specified in this annotation
- If the user-supplied annotation has a field marked with
GeneratedServiceName
it will be the name in the descriptor - It will have a metadata entry with the name of the actual type of the List parameterized return type (or the single parametere type) with key METHOD_ACTUAL
- It will have a metadata entry with the name of the method with key METHOD_NAME
- It will have a metadata entry with the name of the parent
Configured
class with key PARENT_CONFGIURED
If a class is annotated with a user-supplied annotation marked with this annotation then that class *must* also be annotated with the
Decorate
annotation. TheDecorate
annotation will provide the values for several of the fields as described below.When a class on an
Configured
interface has a user-supplied annotation that is annotated with this interface the hk2-inhabitant-generator will generate a service descriptor with the following properties:- The implementation class will be as specified in this annotation
- The available contracts will be as specified in this annotation
- The scope will be as specified in this annotation
- The name will come from the field annotated with
GeneratedServiceName
from the user-supplied annotation defined by theDecorate#with()
method - It will have a metadata entry with the
Decorate#targetType()
value with key METHOD_ACTUAL - It will have a metadata entry with the
Decorate#methodName()
value with key METHOD_NAME - It will have a metadata entry with the name of the parent
Configured
class with key PARENT_CONFGIURED
- Author:
- jwells
- Must only apply to methods (or classes also annotated with
-
-
Field Summary
Fields Modifier and Type Fields Description static String
METHOD_ACTUAL
This is the key in the metadata that will contain the actual type of the List return type of the method where the user-supplied annotation has been placedstatic String
METHOD_NAME
This is the key in the metadata that will contain the name of the method where the user-supplied annotation has been placedstatic String
PARENT_CONFIGURED
This is the key in the metadata that will contain the fully qualified class name of the class markedConfigured
that contains this annotation
-
Required Element Summary
Required Elements Modifier and Type Required Element Description String[]
advertisedContracts
The set of fully qualified class names of the advertised contracts that are to be used in the generated descriptor.String
implementation
This must have the fully qualified class name of the implementation that is to be used in the generated descriptor
-
-
-
Field Detail
-
METHOD_ACTUAL
static final String METHOD_ACTUAL
This is the key in the metadata that will contain the actual type of the List return type of the method where the user-supplied annotation has been placed
-
-
-
METHOD_NAME
static final String METHOD_NAME
This is the key in the metadata that will contain the name of the method where the user-supplied annotation has been placed
-
-
-
PARENT_CONFIGURED
static final String PARENT_CONFIGURED
This is the key in the metadata that will contain the fully qualified class name of the class markedConfigured
that contains this annotation
-
-
Element Detail
-
implementation
String implementation
This must have the fully qualified class name of the implementation that is to be used in the generated descriptor- Returns:
- The fully qualified class name of the implementation
-
-
-
advertisedContracts
String[] advertisedContracts
The set of fully qualified class names of the advertised contracts that are to be used in the generated descriptor. Note that the implementation class is not automatically added to this list- Returns:
- The fully qualified class names of the advertised contracts the generated descriptor should take
-
-
-
scope
String scope
The scope that the descriptor should take. Defaults to PerLookup- Returns:
- The fully qualified class names of the scope the descriptor should take
- Default:
- "org.glassfish.hk2.api.PerLookup"
-
-