Oracle GlassFish Server 3.0.1 Add-On Component Development Guide

Defining an Element

An element represents an item of configuration data. For example, to represent the configuration data for a network listener, GlassFish Server defines the network-listener element.

Define an element for each item of configuration data that you are adding.

ProcedureTo Define an Element

  1. Define a Java language interface to represent the element.

    Define one interface for each element. Do not represent multiple elements in a single interface.

    The name that you give to the interface determines name of the element 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, to define an interface to represent the wombat-container-config element, give the name WombatContainerConfig to the interface.

  2. Specify the parent of the element.

    To specify the parent, extend the interface that identifies the parent as shown in the following table.

    Parent Element 

    Interface to Extend 

    config

    org.glassfish.api.admin.config.Container

    applications

    org.glassfish.api.admin.config.ApplicationName

    Another element that you are defining 

    org.jvnet.hk2.config.ConfigBeanProxy

  3. Annotate the declaration of the interface with the org.jvnet.hk2.config.Configured annotation.


Example 6–1 Declaration of an Interface That Defines an Element

This example shows the declaration of the WombatContainerConfig interface that represents the wombat-container-config element. The parent of this element is the config element.

...
import org.jvnet.hk2.config.Configured;
...
import org.glassfish.api.admin.config.Container;
...
@Configured
public interface WombatContainerConfig extends Container {
...
} 

How Interfaces That Are Annotated With @Configured Are Implemented

You are not required to implement any interfaces that you annotate with the @Configured annotation. GlassFish Server implements these interfaces by using the Dom class. GlassFish Server creates a Java Platform, Standard Edition (Java SE) proxy for each Dom object to implement the interface.