Java - (Descriptor|Metadata)

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

3 - Descriptor

3.1 - Class

The java/lang/Class 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());

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


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)

3.3 - (Deployment|Action)

4 - Property

4.1 - Mutable or immutable

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

5 - Documentation / Reference

5.1 - Hudson


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

5.2 - Beans

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap