Search in sources :

Example 1 with InlineMetaDataTransformer

use of org.apache.deltaspike.core.spi.config.view.InlineMetaDataTransformer in project deltaspike by apache.

the class ViewConfigExtension method addIndirectlyInheritedMetaData.

protected void addIndirectlyInheritedMetaData(Class configClass, Set<Annotation> annotations) {
    for (Annotation annotation : annotations) {
        InlineViewMetaData inlineViewMetaData = annotation.annotationType().getAnnotation(InlineViewMetaData.class);
        if (inlineViewMetaData != null) {
            Class<? extends TargetViewConfigProvider> targetViewConfigProviderClass = inlineViewMetaData.targetViewConfigProvider();
            TargetViewConfigProvider targetViewConfigProvider = ClassUtils.tryToInstantiateClass(targetViewConfigProviderClass);
            for (Class<? extends ViewConfig> viewConfigRef : targetViewConfigProvider.getTarget(annotation)) {
                ViewConfigNode viewConfigNode = findNode(viewConfigRef);
                if (viewConfigNode == null) {
                    addPageDefinition(viewConfigRef);
                    viewConfigNode = findNode(viewConfigRef);
                    if (viewConfigNode == null) {
                        throw new IllegalStateException("No node created for: " + viewConfigRef);
                    }
                }
                Class<? extends InlineMetaDataTransformer> inlineNodeTransformerClass = inlineViewMetaData.inlineMetaDataTransformer();
                if (!InlineMetaDataTransformer.class.equals(inlineNodeTransformerClass)) {
                    InlineMetaDataTransformer inlineMetaDataTransformer = ClassUtils.tryToInstantiateClass(inlineNodeTransformerClass);
                    viewConfigNode.getInheritedMetaData().add(inlineMetaDataTransformer.convertToViewMetaData(annotation, configClass));
                } else // no custom transformer registered -> add the annotation itself
                {
                    viewConfigNode.getInheritedMetaData().add(annotation);
                }
            }
            break;
        }
    }
}
Also used : InlineMetaDataTransformer(org.apache.deltaspike.core.spi.config.view.InlineMetaDataTransformer) InlineViewMetaData(org.apache.deltaspike.core.api.config.view.metadata.InlineViewMetaData) ViewConfigNode(org.apache.deltaspike.core.spi.config.view.ViewConfigNode) TargetViewConfigProvider(org.apache.deltaspike.core.spi.config.view.TargetViewConfigProvider) Annotation(java.lang.annotation.Annotation)

Aggregations

Annotation (java.lang.annotation.Annotation)1 InlineViewMetaData (org.apache.deltaspike.core.api.config.view.metadata.InlineViewMetaData)1 InlineMetaDataTransformer (org.apache.deltaspike.core.spi.config.view.InlineMetaDataTransformer)1 TargetViewConfigProvider (org.apache.deltaspike.core.spi.config.view.TargetViewConfigProvider)1 ViewConfigNode (org.apache.deltaspike.core.spi.config.view.ViewConfigNode)1