JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Oracle GlassFish Server 3.1 Add-On Component Development Guide
search filter icon
search icon

Document Information


1.   Introduction to the Development Environment for GlassFish Server Add-On Components

2.  Writing HK2 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 Element

To Define an Element

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

Defining a Subelement

To Define a Subelement

Validating Configuration Data

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

A.  Integration Point Reference


Creating a Transaction to Update Configuration Data

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:

To Create a Transaction to Update Configuration Data

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).

  1. Set a dependency on the configuration object to update.
  2. Define a method to invoke to perform the transaction.
    1. Use the generic SimpleConfigCode interface to define the method that is to be invoked on a single configuration object, namely: SingleConfigCode<T extends ConfigBeanProxy>().
    2. In the body of this method, implement the run method of the SingleConfigCode<T extends ConfigBeanProxy> interface.
    3. In the body of the run method, invoke the setter methods that are defined for the attributes that you are setting.

      These setter methods are defined in the interface that represents the element whose elements you are setting.

  3. Invoke the static method org.jvnet.hk2.config.ConfigSupport.ConfigSupport.apply.

    In the invocation, pass the following information as parameters to the method:

    • The code of the method that you defined in Step 2

    • The configuration object to update, on which you set the dependency in Step 1

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;
    String instances;

    WombatContainerConfig config;

    public void execute(AdminCommandContext adminCommandContext) {
        try {
            ConfigSupport.apply(new SingleConfigCode<WombatContainerConfig>() {
                public Object run(WombatContainerConfig wombatContainerConfig) 
                        throws PropertyVetoException, TransactionFailure {
                    return null;
            }, config);
        } catch(TransactionFailure e) {