Annotation Interface AemObject


@Target({METHOD,FIELD,PARAMETER}) @Retention(RUNTIME) @InjectAnnotation public @interface AemObject
Injects common AEM objects that can be derived from a SlingHttpServletRequest. The injection is class-based, but may be supported by name hints when multiple targets are available for the same class.

Supports the following objects:

Supported objects
Class Description Name hint Request ResourceResolver Resource
PageManager AEM Page manager X X X
Page AEM page addressed by the current request. Default to be injected for Page types. currentPage X X* X
Page AEM page containing the current resource. resourcePage X X* X
WCMMode Current AEM WCM mode X X* X*
AuthoringUIMode Current AEM Authoring UI mode. Defaults to Touch UI if mode is not set. X X* X*
ComponentContext AEM component context of current request X X* X*
Designer AEM designer X X X
Design AEM design of the current page X X* X
Style AEM design style of the current component X X* X*
XSSAPI AEM XSS API object for the current request X X* X*
I18n I18n object for the current resource/page context. Default to be injected for I18n types. resourceI18n X X* X*
I18n I18n object for the current user userI18n X X* X*
TagManager AEM Tag manager X X X
WorkflowSession Granite Workflow Session X X X

In case of X* the class cannot be derived from the adaptable, but is derived from the request of the current thread detected via RequestContext. If the current thread is not associated with a request nothing is injected.

  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    org.apache.sling.models.annotations.injectorspecific.InjectionStrategy
    if set to REQUIRED injection is mandatory, if set to OPTIONAL injection is optional, in case of DEFAULT the standard annotations (Optional, Required) are used.
    Specifies the name of the request attribute.
    boolean
    Deprecated.
  • Element Details

    • name

      String name
      Specifies the name of the request attribute. If empty or not set, then the name is derived from the method or field.

      For most injections of AemObject this is not required, it is only use as name-hint for injectint a Page object.

      Returns:
      Name
      Default:
      ""
    • injectionStrategy

      org.apache.sling.models.annotations.injectorspecific.InjectionStrategy injectionStrategy
      if set to REQUIRED injection is mandatory, if set to OPTIONAL injection is optional, in case of DEFAULT the standard annotations (Optional, Required) are used. If even those are not available the default injection strategy defined on the Model applies. Default value = DEFAULT.
      Returns:
      Injection strategy
      Default:
      DEFAULT
    • optional

      @Deprecated(since="1.2.0") boolean optional
      Deprecated.
      If set to true, the model can be instantiated even if there is no request attribute with the given name found. Default = false.
      Returns:
      Optional
      Default:
      false