org.jvnet.hk2.config
Annotation Type Attribute


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

Indicates that this property or the field value must be injected from an XML attribute in a configuration file.

Author:
Kohsuke Kawaguchi
See Also:
Element

Optional Element Summary
 Class dataType
          Specifies the data type.
 String defaultValue
          Specifies the default value of the attribute.
 boolean key
          Indicates that this property becomes the name of the component.
 boolean reference
          Indicates that this property is a reference to another configured inhabitant.
 boolean required
          Indicates that this attribute is required.
 String value
          Attribute name.
 boolean variableExpansion
          Indicates that the variable expansion should be performed on this proeprty.
 

value

public abstract String value
Attribute name.

Default Name

If this value is omitted, the default name is inferred from the field/method name. First, if this is a method and the name starts with "set", then "set" will be trimmed off.

Then names are tokenized according to the camel case word separator, then tokens are combined with '-', then finally the whole thing is converted to the lower case.

Therefore, for example, a field name "httpBufferSize" would yield "http-buffer-size", and a method name "setThreadCount" would yield "thread-count"

Default:
""

key

public abstract boolean key
Indicates that this property becomes the name of the component. There can be only one key on a class.

Default:
false

required

public abstract boolean required
Indicates that this attribute is required.

To specify the default value, simply use the field initializer to set it to a certain value. The field/method values are only set when the value is present.

Default:
false

reference

public abstract boolean reference
Indicates that this property is a reference to another configured inhabitant. See Element.reference() for more details of the semantics.

When a reference property is a collection/array, then the key values are separated by ',' with surrounding whitespaces ignored. That is, it can be things like " foo , bar " (which would mean the same thing as "foo,bar".)

Default:
false

variableExpansion

public abstract boolean variableExpansion
Indicates that the variable expansion should be performed on this proeprty. See Element.variableExpansion() for more details.

Default:
true

defaultValue

public abstract String defaultValue
Specifies the default value of the attribute.

Returns:
default value as String
Default:
"\u0000"

dataType

public abstract Class dataType
Specifies the data type. It should be the fully qualified name of the class that identifies the real data type. For attributes that are of type defined by basic Java primitives (or wrappers), there is no need to specify this field. The default value is derived from method/field declaration.

Returns:
String specifying the name of the data type for the values of this attribute
See Also:
DataType}
Default:
java.lang.String.class


Copyright © 2013 Oracle Corporation. All Rights Reserved.