Annotation Type ContextParam


  • @Qualifier
    @Retention(RUNTIME)
    @Target({METHOD,FIELD,PARAMETER})
    public @interface ContextParam

    The CDI annotation @ContextParam allows you to inject a web.xml context parameter from the current application in a CDI managed bean. It's basically like @ManagedProperty("#{initParam['some.key']}") private String someKey; in a "plain old" Faces managed bean.

    By default the name of the context parameter is taken from the name of the variable into which injection takes place. The example below injects the context parameter with name foo.

     @Inject @ContextParam
     private String foo;
     

    The name can be optionally specified via the name attribute, which shall more often be used as context parameters may have a.o. periods and/or hyphens in the name, which are illegal in variable names. The example below injects the context parameter with name foo.bar into a variable named bar.

     @Inject @ContextParm(name="foo.bar")
     private String bar;
     
    Since:
    2.2
    Author:
    Bauke Scholtz
    See Also:
    ContextParamProducer
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      String name
      (Optional) The name of the context parameter.
    • Element Detail

      • name

        String name
        (Optional) The name of the context parameter. If not specified the name of the injection target field will be used.
        Returns:
        The name of the context parameter.
        Default:
        ""