The DD API has been developed in order to satisfy the requirement to access the web module deployment descriptor for other Netbeans modules in a simple and servlet spec.-independant way.

1. The Overall Architecture

The DD API is based on a bunch of interfaces based on the deployment descriptor xml structure. The names of interfaces correspond to the names of deployment descriptor elements in web.xml file. The DD API interfaces are organized in a hierarchic tree structure where they are accassible through the root - {@link org.netbeans.api.web.dd.WebApp} - interface. The implementation of DD API interfaces is hidden for clients. It is based on schema2beans infrastructure and is the DD version - specific. (there is always requirement to support at least two successive versions of DD specification). The root of the deployment descriptor is accessible through the {@link org.netbeans.api.web.dd.DDProvider} class.

2. What it is not.

The DD API provides no UI for deployment descriptor editing.

3. The Hierarchic structure of DD API Interfaces

Package: {@link org.netbeans.api.web.dd}

All DD API interfaces are included to this package.
Here is the hierarchic structure of the DD API interfaces :

{@link org.netbeans.api.web.dd.WebApp}
  - {@link org.netbeans.api.web.dd.Icon} [*]
  - {@link org.netbeans.api.web.dd.InitParam} [*]
  - {@link org.netbeans.api.web.dd.Filter} [*]
    - {@link org.netbeans.api.web.dd.Icon} [*]
    - {@link org.netbeans.api.web.dd.InitParam} [*]
  - {@link org.netbeans.api.web.dd.FilterMapping} [*]
  - {@link org.netbeans.api.web.dd.Listener} [*]
    - {@link org.netbeans.api.web.dd.Icon} [*]
  - {@link org.netbeans.api.web.dd.Servlet} [*]
    - {@link org.netbeans.api.web.dd.Icon} [*]
    - {@link org.netbeans.api.web.dd.InitParam} [*]
    - {@link org.netbeans.api.web.dd.RunAs} [*]
    - {@link org.netbeans.api.web.dd.SecurityRoleRef} [*]
  - {@link org.netbeans.api.web.dd.ServletMapping} [*]
  - {@link org.netbeans.api.web.dd.SessionConfig} [?]	
  - {@link org.netbeans.api.web.dd.MimeMapping} [*]
  - {@link org.netbeans.api.web.dd.WelcomeFileList} [?]
  - {@link org.netbeans.api.web.dd.ErrorPage} [*]
  - {@link org.netbeans.api.web.dd.Taglib} [*]
  - {@link org.netbeans.api.web.dd.JspConfig} [?]
    - {@link org.netbeans.api.web.dd.Taglib} [*]
    - {@link org.netbeans.api.web.dd.JspPropertyGroup} [*]
  - {@link org.netbeans.api.web.dd.SecurityConstraint} [*]
    - {@link org.netbeans.api.web.dd.WebResourceCollection} [+]
    - {@link org.netbeans.api.web.dd.AuthConstraint} [?]
    - {@link org.netbeans.api.web.dd.UserDataConstraint} [?]
  - {@link org.netbeans.api.web.dd.LoginConfig} [?]
    - {@link org.netbeans.api.web.dd.FormLoginConfig} [?]
  - {@link org.netbeans.api.web.dd.SecurityRole} [*]
  - {@link org.netbeans.api.web.dd.EnvEntry} [*]
  - {@link org.netbeans.api.web.dd.EjbRef} [*]
  - {@link org.netbeans.api.web.dd.EjbLocalRef} [*]
  - {@link org.netbeans.api.web.dd.ServiceRef} [*]
    - {@link org.netbeans.api.web.dd.Icon} [*]
    - {@link org.netbeans.api.web.dd.PortComponentRef} [*]
    - {@link org.netbeans.api.web.dd.ServiceRefHandler} [*]
      - {@link org.netbeans.api.web.dd.InitParam} [*]
  - {@link org.netbeans.api.web.dd.ResourceRef} [*]
  - {@link org.netbeans.api.web.dd.ResourceEnvRef} [*]
  - {@link org.netbeans.api.web.dd.MessageDestinationRef} [*]
  - {@link org.netbeans.api.web.dd.MessageDestination} [*]
    - {@link org.netbeans.api.web.dd.Icon} [*]
  - {@link org.netbeans.api.web.dd.LocaleEncodingMappingList} [?]
    - {@link org.netbeans.api.web.dd.LocaleEncodingMapping} [+]

Comments : 
[*] - objects occur multiple times in parent object (0-n)
[+] - objects occur multiple times in parent object (1-n)
[?] - object can occur only once in parent object (0-1)

4. The structure of method names.

The syntax and usage of interfaces methods is very simple and straightforward.
If certain object [of XYZ interface] occurs multiple times in parent object these methods are present in parent interface :


If certain object [of XYZ interface] can occur only once in parent object these methods are present in parent interface :
Example : The {@link org.netbeans.api.web.dd.WebApp} interface contains these methods for getting/setting {@link org.netbeans.api.web.dd.Servlet}s and {@link org.netbeans.api.web.dd.WelcomeFileList} :
Interfaces contain additional methods corresponding to the simple(String) properties following the deployment descriptor xml syntax.
Example : The {@link org.netbeans.api.web.dd.Taglib} interface contains these additional getters/setters :
Interfaces usually extends some interfaces from the {@link org.netbeans.api.web.dd.common} package. For example if a DD element has the description property, it extends the {@link org.netbeans.api.web.dd.common.DescriptionInterface} containing the methods for description property handling.
Example : The {@link org.netbeans.api.web.dd.WebApp}, {@link org.netbeans.api.web.dd.Servlet}, {@link org.netbeans.api.web.dd.Filter}, {@link org.netbeans.api.web.dd.Listener}, {@link org.netbeans.api.web.dd.ServiceRef}, {@link org.netbeans.api.web.dd.WebResourceCollection} interfaces have the additional functionality for description proprty.

5. DDProvider class - getting the root interface from web.xml file.

Package: {@link org.netbeans.api.web.dd}

Provides the access to the deployment descriptor root - {@link org.netbeans.api.web.dd.WebApp} - object. The {@link org.netbeans.api.web.dd.DDProvider} class is a singleton and caches the WebApp objects in IDE.
There are following methods for accessing {@link org.netbeans.api.web.dd.WebApp} object in DDProvider :

6. Deployment descriptor modification.

DD API enables the full modification of deployment descriptor elements including:

See the Examples of usage.

7. Writing changes.

The modificated {@link org.netbeans.api.web.dd.WebApp} object can be serialized to FileObject using :

There is also another write mathod available on any interface to serialize the fraction of deployment descriptor to OutputStream :

See the Examples of usage.


See also :