Skip Navigation Links | |
Exit Print View | |
![]() |
Oracle GlassFish Server 3.1 Add-On Component Development Guide |
1. Introduction to the Development Environment for GlassFish Server Add-On Components
3. Extending the Administration Console
4. Extending the asadmin Utility
5. Adding Monitoring Capabilities
6. Adding Configuration Data for a Component
How GlassFish Server Stores Configuration Data
Defining an Attribute of an Element
Representing an Attribute of an Element
Specifying the Data Type of an Attribute
Identifying an Attribute of an Element
Specifying the Name of an Attribute
Specifying the Default Value of an Attribute
Initializing a Component's Configuration Data
To Define a Component's Initial Configuration Data
To Write a Component's Initial Configuration Data to the domain.xml File
Creating a Transaction to Update Configuration Data
To Create a Transaction to Update Configuration Data
Dotted Names and REST URLs of Configuration Attributes
Examples of Adding Configuration Data for a Component
7. Adding Container Capabilities
8. Creating a Session Persistence Module
9. Packaging, Integrating, and Delivering an Add-On Component
The attributes of an element describe the characteristics of the element. For example, the port attribute of the network-listener element identifies the port number on which the listener listens.
Represent each attribute of an element as the property of a pair of JavaBeans specification getter and setter methods of the interface that defines the element. The component for which the configuration data is being defined can then access the attribute through the getter method. The setter method enables the attribute to be updated.
The data type of an attribute is the return type of the getter method that is associated with the attribute. To enable the attribute take properties in the form ${property-name} as values, specify the data type as String.
To identify an attribute of an element, annotate the declaration of the getter method that is associated with the attribute with the org.jvnet.hk2.config.Attribute annotation.
To specify the properties of the attribute, use the elements of the @Attribute annotation as explained in the sections that follow.
To specify the name of an attribute, set the value element of the @Attribute annotation to a string that specifies the name. If you do not set this element, the name is derived from the name of the property as follows:
A change from lowercase to uppercase in the interface name is transformed to the hyphen (-) separator character.
The element name is all lowercase.
For example, if the getter method getNumberOfInstances is defined for the property NumberOfInstances to represent an attribute, the name of the attribute is number-of-instances.
The default value of an attribute is the value that is applied if the attribute is omitted when the element is written to the domain configuration file.
To specify the default value of an attribute, set the defaultValue element of the @Attribute annotation to a string that contains the default value. If you do not set this element, the parameter has no default value.
Whether an attribute is required or optional determines how GlassFish Server responds if the parameter is omitted when the element is written to the domain configuration file:
If the attribute is required, an error occurs.
If the attribute is optional, the element is written successfully to the domain configuration file.
To specify whether an attribute is required or optional, set the required element of the @Attribute annotation as follows:
If the attribute is required, set the required element to true.
If the attribute is optional, set the required element to false. This value is the default.
Example 6-2 Defining an Attribute of an Element
This example defines the attribute number-of-instances. To enable the attribute take properties in the form ${property-name} as values, the data type of this attribute is String.
import org.jvnet.hk2.config.Attribute; ... @Attribute public String getNumberOfInstances(); public void setNumberOfInstances(String instances) throws PropertyVetoException; ...