Meta-Data Processing Framework
This framework makes use of the meta-data contributed by the
Design-time Meta-data Framework. It's intention in this release is to simplify how services like Content Assist and Validation can be provided in source editors for tag library based attributes values.
The goal for this framework is to allow developers to assign "runtime type" information to an attibute's value using meta-data and then, because based on that type, "features" can naturally be exposed.
To make this more concrete, let's consider the example of the JSF Core
actionListener tag and its
type attribute. The value should resolve to a Java class type that implements the interface
javax.faces.event.ActionListener. Having this knowledge is enough to provide:
- Validation - ensure that the specified class can be found and implements the correct interface
- Content Assist - provide a list of all of the classes that can be found that implement the interface
- Quick Fix/Quick Assist - open the new Java class wizard with the required interface preset in the dialog
Types and Features
In the above example, the "Type" is a Java class type and we have identified three "Feature" that the type implements.
We have created an interface called
that represents the runtime type of the attribute value of a tag. An implementor needs to return a list of feature adapters that this type supports. The features must implement the
A default implementation,
has been provided as a convenient starting point for implementing types, and it itself implements
. This allows the type descriptor to implement features itself which should simplify development.
Attribute Value Runtime Type Extension Point
We bind a type identifier in meta-data to a class through an extension point.
. Please see
Design-time Meta-Data Framework to see how the meta-data files are created.
The JSF Tools project has implemented a type descriptor class
org.eclipse.jst.jsf.core.attributevalues.JavaClassType. In order to use this type, it must first be declared as an
AttributeValueRuntimeType and then referenced in a meta-data file.
Below comes from the
org.eclipse.jst.jsf.core plugin that declares this type:
Below is the section of the jsf_core.xml meta-data file from the core plugin that supplies meta-data for the
Notice that the value of the
attribute-value-runtime-type trait uses the plugin qualified id of the AttributeValueRuntimeType extension.
For a complete list of implemented types and features, please see the
JavaClassType implements two Features:
IValidValues - an interface used by a WTP Validation framework validator class to check and provide validation error messages if invalid when being used in a non-EL context
IPossibleValues - an interface used by an extension to the WTP SSE editor for content assistance
Although not applicable to the
JavaClassType, the following round out the Features defined by this release:
IValidELValues - an interface used by a WTP Validation framework validator class to check and provide validation error messages if invalid when being used in an EL context
IDefaultValue - an interface for providing a default value
ICreateValues - an unimplemented experimental interface with intentoin of being used for providing Quick Fix/Quick Assist services
The Feature implementer can require additional information from meta-data. Notice that the
JavaClassType calls back to the meta-data to get the list of
valid-interface values. For a complete list of the property names used by the Types and Features from the core plugin see the
constant values reference page
How are these used?
A client interested in requesting a set of all the Feature implementers for a given tag attribute will use the
This method will lookup the runtime type from the meta-data file that it will identify from the passed context.
This method is currently being called by the
IValidELValues.class passed as the feature class along with the context. For content assist,
IPossibleValues.class is being passed by the content assist processor.
Creating New Behaviors
Hopefully by now you know enough knowledge to create your own types, or reuse existing types in your meta-data files. But what if you wanted to associate a completely new behaviour(Feature) with a runtime type? This is handled by implementing a new
IMetaDataEnabledFeature and registering it against a type identifier.
To register, use the