Meta-Data Processing Framework


Overview

This framework makes use of the meta-data contributed by the content model annotations framework. It's intention in this release is to simplify how servcies such as 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 annotations 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:

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 ITypeDescriptor 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 IMetaDataEnabledFeature interface.

A default implementation, AbstractRootTypeDescriptor has been provided as a convenient starting point for implementing types and it itself implements AbstractMetaDataEnabledFeature. This allows the type descriptor to implement features itself which simplifies development.

Attribute Value Runtime Type Extension Point

We bind a type identifier in meta-data to a class through an extension point. org.eclipse.jst.jsf.metadataprocessing.AttributeValueRuntimeTypes. Please see content model annotations extension-point to see how the annotations file is created.

The JSF Tools project has implemented a type descriptor class org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.JavaClassType. In order to use this type, it must first be declared as an AttributeValueRuntimeTypes and then refernced in an annotation file.

Below comes from the org.eclipse.jst.jsf.taglibprocessing plugin that declares this type:

      <attributeValueRuntimeType
            class="org.eclipse.jst.jsf.taglibprocessing.internal.provisional.attributevalues.JavaClassType"
            id="attributevalues.JavaClassType"/>    

Below is the section of the jsf_core.xml annotation file from the taglibprocessing plugin that annotates the actionListener tag:

	<cm-element name="actionListener">
		<cm-attribute name="type">
			<property name="attribute-value-runtime-type">
				<value>
					org.eclipse.jst.jsf.taglibprocessing.attributevalues.JavaClassType
				</value>
			</property>
			<property name="valid-interfaces">
				<value>javax.faces.event.ActionListener</value>
			</property>		
		</cm-attribute>
	</cm-element>

Notice that the value of the property named attribute-value-runtime-type uses the plugin qualified id of the AttributeValueRuntimeType extension. This the property name of the annotation that associates the type identifier with the content model attribute.

For a complete list of implemented types and features, please see the API reference

The JavaClassType implements two Features:

Although not applicable to the JavaClassType, the following round out the Features defined by this release:

The Feature implementer can require additional information from the annotation. Notice that the JavaClassType gets the list of valid-interface values from the meta-data. For a complete list of the property names used by the Types and Features from the taglibprocessing 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 MetaDataEnabledProcessingFactory and the getAttributeValueRuntimeTypeFeatureProcessors method.. This method will lookup the runtime type from the annotations file that it will identify from the passed context. This method is currently being called by the JSPSemanticValidator with IValidValues.class and IValidELValues.class passed as the feature class along with the context. For content assist, IPossibleValues.class is being passed by the content assist processor.

A content model can be annotated by multiple plugins. This means that for a given attribute, there may be multiple runtime type assigned to it each implementing the same or different features. In other words, the caller could get back a list of multiple feature implementers from different plugins. The CMAnnotationContext returned with IMetaDataEnabledFeature could be useful in determining whether or not to use that feature. Generally, as is the case with the JSF content assist processor, this behaviour is "additive". All the features will be used which may result in multiple identical values appearing in the content assist popup menu. Currently there is no capabilty to "disable" Features to avoid this situation. It is presumed in the design that in most cases, only one plugin will provide annotations for a given content model.

Creating New Behaviors

Hopefully by now you know enough to create your own types, or reuse existing types in your annotation 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 org.eclipse.jst.jsf.metadataprocessing.MetaDataEnabledFeatures extension point.

Other Resources