public class AttributeManagerGenerator extends AbstractGenerator
The AttributeManager mainly holds a [component name/attributes] map, and the code to create that map is the main things this generator generates. Prior to this generator, Mojarra maintained a static list of passthrough attributes that would be applied to all components when rendered. The main problem with doing this is that some components have a very small list of passthrough attributes and so we'd waste cycles processing the generic list. To alleviate this issue:
1. Added a new code generator, AttributeManagerGenerator, which will
leverage the xml metadata in jsf-api/doc to generate a class which
has knowledge of which components have which pass through attributes.
This generated class will expose a method that will allow renderers
to lookup the set of passthrough attributes appropriate to the component
they handle.
2. Update all renderers that render passthrough attributes to store
the attribute lookup result in a static variable
3. Remove the RenderKitUtil.renderPassThruAttributes() methods containing
excludes. Rely on the generator to provide the correct attributes.
4. Remove all the logic (sorting, verifying) associated with the excludes
5. Update the RenderKitUtils.shouldRenderAttribute() logic to check
if the value to be rendered is a String (as most are). If it is, return
true and bypass the remainder of the checks.
After profiling RenderKitUtils.renderPassThruAttributes has dropped quite in terms of cpu usage compared to the previous implementation.
The following shows an example of this generated Map:
private static Map<String,Attribute[]> ATTRIBUTE_LOOKUP=CollectionsUtils.<String,Attribute[]>map()
.add("CommandButton",ar(
attr("accesskey")
,attr("alt")
,attr("dir")
,attr("lang")
,attr("onblur","blur")
...
AbstractGenerator.CodeWriterJAVA_KEYWORDS, TYPE_DEFAULTS| Constructor and Description |
|---|
AttributeManagerGenerator(PropertyManager manager) |
| Modifier and Type | Method and Description |
|---|---|
void |
generate(FacesConfigBean configBean)
Perform whatever generation tasks are necessary using
the provided
FacesConfigBean as the model. |
static void |
main(String[] args) |
capitalize, mangle, options, primitive, shortNamepublic AttributeManagerGenerator(PropertyManager manager)
public void generate(FacesConfigBean configBean)
GeneratorPerform whatever generation tasks are necessary using
the provided FacesConfigBean as the model.
configBean - model dataCopyright © 2010–2020 JBoss by Red Hat. All rights reserved.