Writing metadata plugins is easy in Hop. Any Plain Old Java Object can be used as a starting point.
This annotation signals to the Metadata plugin type that there is something worth looking at. The class which carries this annotation will contain the metadata.
Here are the attributes of the @HopMetadata annotation:
key : this uniquely identifies the plugin and will be the name of the folder in which the metadata resides when serialising to JSON (see below)
name : a human-readable name
description : an extended description
image : the path to an image which helps identify the metadata in the Hop GUI
The class with this annotation will be found either because it lives in the
folder of Hop or if it’s an internal class and is described in the file
All properties you want to have as part of the shared Hop Metadata should get the
annotation. All top level classes flagged with @HopMetadata should have a
property of type
Here are the @HopMetadataProperty attributes:
key : optional key if you want it to be different from the name of the field
password: set this to true if you want the String field to be encoded using the TwoWayPasswordEncoder of the IHopMetadataProvider interface.
storeWithName: if you want to store a reference to another shared metadata object, you can set this to true, otherwise all the properties of the object will be stored.
Here are the supported data types:
enum : any enum is serialized using its name
String : also see the password attribute above.
Integer / int
Long / long
Boolean / boolean
java.util.List<T> : with T any of the data types listed here.
POJO : Any class with more @HopMetadataProperty annotations in it.
You also want to have a way to edit the metadata in the GUI. This can be done by extending the class
The path to the Editor class will be found automatically by looking at the name of the metadata plugin class and then simply by appending Editor to it. If you prefer to keep metadata and GUI code separate the Hop GUI will also look in package
org.apache.hop.ui instead of
createControl() : create the various controls on the given parent Composite. The composite has a FormLayout set.
setWidgetsContent(): Using the metadata object (or getMetadata()) you can set the content on the created controls.
getWidgetsContent(): Grab the values of the various controls and modify the metadata
save(): verify settings, grab metadata and call super.save()
setFocus(): sets the focus on the metadata dialog or tab. Choose the control to set the focus to (usually the name).
createButtonsForButtonBar(): if you want to add buttons at the bottom to do things like testing, viewing, … you can use this method
As mentioned above, the key or ID the @HopMetadata plugin is used as a top level folder to store objects in. For the serialisation to JSON most simple data types are supported. However we suggest you use the KISS principle. If you want to serialize interfaces (for example like IDatabase used by DatabaseMeta) you might want to flag the interface with the @HopMetadataObject annotation. This annotation allows you to specify an object factory for those classes. Such an object factory implements interface
with the 2 following methods:
→ Creates an object using an ID. The parent object is often another metadata object. You can use it to check if it implements IVariables so you can inherit variables from there.
public Object createObject( String id, Object parentObject ) throws HopException
→ Retrieves the object ID from the given object. We recommend that you check the instance of the object until the factory interface supports generics. (TODO)
public String getObjectId( Object object ) throws HopException