Should a resource class need to reference other Nucleus components, the framework provides the @NucleusComponent
annotation. This annotation resolves the component and allows you to inject it as a value for the field. This annotation should only be used when a REST resource class is not itself a Nucleus component. It is recommended that any resource that needs a reference to another Nucleus component should itself be a Nucleus component with the reference a standard Nucleus property of the resource component.
The following steps describe how to resolve a non-Nucleus component:
Identify the global or request scope that should be resolved in the endpoint or resource.
Use the
@NucleusComponent
annotation to resolve the component. Place the annotation on the line preceding the variable definition. Note: It is best not use the@NucleusComponent
annotation to resolve session-scope components in an endpoint or resource class.