org.jvnet.hk2.annotations
Annotation Type Inject


@Retention(value=RUNTIME)
@Target(value={METHOD,FIELD,PARAMETER})
public @interface Inject

Annotation to define a required resource for a component. The HK2 runtime inject all instance variables annotated with @Inject as well as setter methods.

Examples:

        @Inject("GlassfishMBeanServer")
        MBeanServer mbeanserver;

        @Inject  // unnamed
        MBeanServer mbeanserver;

Author:
Jerome Dochez
See Also:
Habitat

Optional Element Summary
 String name
          Returns the name.
 boolean optional
          When true, it is not an error if not present.
 

name

public abstract String name
Returns the name.

Returns:
name of the resource
Default:
""

optional

public abstract boolean optional
When true, it is not an error if not present. When false, a failure occurs when not present.

Returns:
true if optional, false otherwise
Default:
false


Copyright © 2012 Oracle Corporation. All Rights Reserved.