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
Specifying Whether an Attribute Is Required or Optional
Example of Defining an Attribute of an Element
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
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
Creating a transaction to update configuration data enables the data to be updated without the need to specify a dotted name in the set(1) subcommand. You can make the transaction available to system administrators in the following ways:
By adding an asadmin(1M) subcommand. If you are adding an asadmin subcommand, include the code for the transaction in the body of the subcommand's execute method. For more information, see Chapter 4, Extending the asadmin Utility.
By extending the Administration Console. For more information, see Chapter 3, Extending the Administration Console.
Any transaction that you create to modify configuration data must use a configuration change transaction to ensure that the change is atomic, consistent, isolated, and durable (ACID).
These setter methods are defined in the interface that represents the element whose elements you are setting.
In the invocation, pass the following information as parameters to the method:
Example 6-10 Creating a Transaction to Update Configuration Data
This example shows code in the execute method of an asadmin subcommand for updating the number-of-instances element of wombat-container-config element.
... import org.glassfish.api.Param; ... import org.jvnet.hk2.annotations.Inject; import org.jvnet.hk2.config.Transactions; import org.jvnet.hk2.config.ConfigSupport; import org.jvnet.hk2.config.SingleConfigCode; import org.jvnet.hk2.config.TransactionFailure; ... @Param String instances; @Inject WombatContainerConfig config; public void execute(AdminCommandContext adminCommandContext) { try { ConfigSupport.apply(new SingleConfigCode<WombatContainerConfig>() { public Object run(WombatContainerConfig wombatContainerConfig) throws PropertyVetoException, TransactionFailure { wombatContainerConfig.setNumberOfInstances(instances); return null; } }, config); } catch(TransactionFailure e) { } } ...