Search in sources :

Example 1 with GrailsPluginManager

use of grails.plugins.GrailsPluginManager in project grails-core by grails.

the class ClosureClassIgnoringComponentScanBeanDefinitionParser method createScanner.

@Override
protected ClassPathBeanDefinitionScanner createScanner(XmlReaderContext readerContext, boolean useDefaultFilters) {
    final ClassPathBeanDefinitionScanner scanner = super.createScanner(readerContext, useDefaultFilters);
    BeanDefinitionRegistry beanDefinitionRegistry = readerContext.getRegistry();
    GrailsPluginManager pluginManager = null;
    if (beanDefinitionRegistry instanceof HierarchicalBeanFactory) {
        HierarchicalBeanFactory beanFactory = (HierarchicalBeanFactory) beanDefinitionRegistry;
        BeanFactory parent = beanFactory.getParentBeanFactory();
        if (parent != null && parent.containsBean(GrailsPluginManager.BEAN_NAME)) {
            pluginManager = parent.getBean(GrailsPluginManager.BEAN_NAME, GrailsPluginManager.class);
        }
    }
    if (pluginManager != null) {
        List<TypeFilter> typeFilters = pluginManager.getTypeFilters();
        for (TypeFilter typeFilter : typeFilters) {
            scanner.addIncludeFilter(typeFilter);
        }
    }
    return scanner;
}
Also used : ClassPathBeanDefinitionScanner(org.springframework.context.annotation.ClassPathBeanDefinitionScanner) GrailsPluginManager(grails.plugins.GrailsPluginManager) HierarchicalBeanFactory(org.springframework.beans.factory.HierarchicalBeanFactory) BeanFactory(org.springframework.beans.factory.BeanFactory) BeanDefinitionRegistry(org.springframework.beans.factory.support.BeanDefinitionRegistry) TypeFilter(org.springframework.core.type.filter.TypeFilter) HierarchicalBeanFactory(org.springframework.beans.factory.HierarchicalBeanFactory)

Example 2 with GrailsPluginManager

use of grails.plugins.GrailsPluginManager in project grails-core by grails.

the class GroovyPageMetaInfo method initializePluginPath.

private void initializePluginPath() {
    if (grailsApplication == null || pageClass == null) {
        return;
    }
    final ApplicationContext applicationContext = grailsApplication.getMainContext();
    if (applicationContext == null || !applicationContext.containsBean(GrailsPluginManager.BEAN_NAME)) {
        return;
    }
    GrailsPluginManager pluginManager = applicationContext.getBean(GrailsPluginManager.BEAN_NAME, GrailsPluginManager.class);
    pluginPath = pluginManager.getPluginPathForClass(pageClass);
    if (pluginPath == null)
        pluginPath = DEFAULT_PLUGIN_PATH;
    pagePlugin = pluginManager.getPluginForClass(pageClass);
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) GrailsPluginManager(grails.plugins.GrailsPluginManager)

Example 3 with GrailsPluginManager

use of grails.plugins.GrailsPluginManager in project grails-core by grails.

the class Holders method currentPluginManager.

public static GrailsPluginManager currentPluginManager() {
    GrailsPluginManager current = getPluginManager();
    Assert.notNull(current, "No PluginManager set");
    return current;
}
Also used : GrailsPluginManager(grails.plugins.GrailsPluginManager)

Aggregations

GrailsPluginManager (grails.plugins.GrailsPluginManager)3 BeanFactory (org.springframework.beans.factory.BeanFactory)1 HierarchicalBeanFactory (org.springframework.beans.factory.HierarchicalBeanFactory)1 BeanDefinitionRegistry (org.springframework.beans.factory.support.BeanDefinitionRegistry)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ClassPathBeanDefinitionScanner (org.springframework.context.annotation.ClassPathBeanDefinitionScanner)1 TypeFilter (org.springframework.core.type.filter.TypeFilter)1