Table of Contents

About

Example of (Descriptor|Metadata) implementation in java.

The source of the descriptor can be:

  • in the code
  • in an external file (xml, properties, …)
  • or generated (see class)

Descriptor

Class

The javase/9/docs/api/java/lang/Class.html is a public final class that describe a class.

Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.

System.out.println("The class of " + obj +
                            " is " + obj.getClass().getName());

Subclass

In a subclass, you can return (Describe|Metadata) information with the help of a function that returns

  • a static field
  • or a static class (usually inner) which is a singleton for every concrete action (or implementation).

If

a.getClass() == b.getClass()

then by default

a.getDescriptor() == b.getDescriptor()

The return value is static but the describe function is not (and then can be added to an interface definition)

(Deployment|Action)

See for instance: Java - Deployment descriptors (Metadata)

Property

Mutable or immutable

A descriptor can be mutable or immutable. An immutable descriptor, once created, never changes.

Documentation / Reference

Hudson

byShortName/Descriptor

A Descriptor/Describable combination is used throughout in Hudson to implement a configuration/extensibility mechanism.

Beans