compiler.addTagLibrary(new CompositeResourceLibrary(context,
CompositeResourceLibrary.ALIAS_NAMESPACE_PREFIX));
compiler.addTagLibrary(new JsfLibrary());
compiler.addTagLibrary(new PassThroughLibrary());
RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(eContext);
if (!runtimeConfig.getComponentTagDeclarations().isEmpty())
{
// Set a dummy view root, to avoid Application.createComponent() to fail
ComponentTagDeclarationLibrary componentTagDeclarationLibrary = new ComponentTagDeclarationLibrary();
LoadComponentTagDeclarationFacesContextWrapper wrappedFacesContext =
new LoadComponentTagDeclarationFacesContextWrapper(context);
try
{
wrappedFacesContext.setWrapperAsCurrentFacesContext();
UIViewRoot root = new UIViewRoot();
root.setRenderKitId("HTML_BASIC");
wrappedFacesContext.setViewRoot(new UIViewRoot());
for (ComponentTagDeclaration declaration : runtimeConfig.getComponentTagDeclarations())
{
// We have here probably an inconsistency, because the annotation does not
// have a default renderer type. Let the renderer type be null will cause problems
// later, because application.createComponent() may not scan the renderer class if
// a rendererType is not provided. The easy way to overcome this situation is create
// a dummy instance and check its rendererType. If is set the renderer if any will be
// scanned for annotations, if not it just do things as usual. It is unlikely to create
// a component and does not set a default renderer type if is required.
UIComponent component = context.getApplication().createComponent(declaration.getComponentType());
componentTagDeclarationLibrary.addComponent(declaration.getNamespace(),
declaration.getTagName(), declaration.getComponentType(), component.getRendererType());
}
}
finally
{
wrappedFacesContext.restoreCurrentFacesContext();
}
compiler.addTagLibrary(componentTagDeclarationLibrary);
}
List<FaceletTagLibrary> faceletTagLibraries = runtimeConfig.getFaceletTagLibraries();
for (FaceletTagLibrary faceletTagLibrary : faceletTagLibraries)
{
//Create TagLibrary here, populate and add it to the compiler.
TagLibrary tl = TagLibraryConfig.create(context, faceletTagLibrary);
if (tl != null)