Java 类org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader 实例源码

项目:spring4-understanding    文件:GroovyWebApplicationContext.java   
/**
 * Loads the bean definitions via an GroovyBeanDefinitionReader.
 * @see org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader
 * @see #initBeanDefinitionReader
 * @see #loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(DefaultListableBeanFactory beanFactory) throws BeansException, IOException {
    // Create a new XmlBeanDefinitionReader for the given BeanFactory.
    GroovyBeanDefinitionReader beanDefinitionReader = new GroovyBeanDefinitionReader(beanFactory);

    // Configure the bean definition reader with this context's
    // resource loading environment.
    beanDefinitionReader.setEnvironment(getEnvironment());
    beanDefinitionReader.setResourceLoader(this);

    // Allow a subclass to provide custom initialization of the reader,
    // then proceed with actually loading the bean definitions.
    initBeanDefinitionReader(beanDefinitionReader);
    loadBeanDefinitions(beanDefinitionReader);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:spring-boot-concourse    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:Mycat-openEP    文件:SpringInitializer.java   
private static void initGroovyConf(GenericApplicationContext context){
    String classPath=ProcessInfo.getGroovyClassPath();
    if(Help.isNotEmpty(classPath)){
        GroovyBeanDefinitionReader reader=new GroovyBeanDefinitionReader(context);
        reader.loadBeanDefinitions(new ClassPathResource(classPath));
    }
}
项目:contestparser    文件:BeanDefinitionLoader.java   
/**
 * Create a new {@link BeanDefinitionLoader} that will load beans into the specified
 * {@link BeanDefinitionRegistry}.
 * @param registry the bean definition registry that will contain the loaded beans
 * @param sources the bean sources
 */
BeanDefinitionLoader(BeanDefinitionRegistry registry, Object... sources) {
    Assert.notNull(registry, "Registry must not be null");
    Assert.notEmpty(sources, "Sources must not be empty");
    this.sources = sources;
    this.annotatedReader = new AnnotatedBeanDefinitionReader(registry);
    this.xmlReader = new XmlBeanDefinitionReader(registry);
    if (isGroovyPresent()) {
        this.groovyReader = new GroovyBeanDefinitionReader(registry);
    }
    this.scanner = new ClassPathBeanDefinitionScanner(registry);
    this.scanner.addExcludeFilter(new ClassExcludeFilter(sources));
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:introducing-spring-framework    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:spring4-understanding    文件:ConfigurationClassBeanDefinitionReader.java   
private void loadBeanDefinitionsFromImportedResources(
        Map<String, Class<? extends BeanDefinitionReader>> importedResources) {

    Map<Class<?>, BeanDefinitionReader> readerInstanceCache = new HashMap<Class<?>, BeanDefinitionReader>();

    for (Map.Entry<String, Class<? extends BeanDefinitionReader>> entry : importedResources.entrySet()) {
        String resource = entry.getKey();
        Class<? extends BeanDefinitionReader> readerClass = entry.getValue();

        // Default reader selection necessary?
        if (BeanDefinitionReader.class == readerClass) {
            if (StringUtils.endsWithIgnoreCase(resource, ".groovy")) {
                // When clearly asking for Groovy, that's what they'll get...
                readerClass = GroovyBeanDefinitionReader.class;
            }
            else {
                // Primarily ".xml" files but for any other extension as well
                readerClass = XmlBeanDefinitionReader.class;
            }
        }

        BeanDefinitionReader reader = readerInstanceCache.get(readerClass);
        if (reader == null) {
            try {
                // Instantiate the specified BeanDefinitionReader
                reader = readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry);
                // Delegate the current ResourceLoader to it if possible
                if (reader instanceof AbstractBeanDefinitionReader) {
                    AbstractBeanDefinitionReader abdr = ((AbstractBeanDefinitionReader) reader);
                    abdr.setResourceLoader(this.resourceLoader);
                    abdr.setEnvironment(this.environment);
                }
                readerInstanceCache.put(readerClass, reader);
            }
            catch (Exception ex) {
                throw new IllegalStateException(
                        "Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
            }
        }

        // TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
        reader.loadBeanDefinitions(resource);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:BeanDefinitionLoader.java   
private int load(GroovyBeanDefinitionSource source) {
    int before = this.xmlReader.getRegistry().getBeanDefinitionCount();
    ((GroovyBeanDefinitionReader) this.groovyReader).beans(source.getBeans());
    int after = this.xmlReader.getRegistry().getBeanDefinitionCount();
    return after - before;
}
项目:spring    文件:ConfigurationClassBeanDefinitionReader.java   
private void loadBeanDefinitionsFromImportedResources(
        Map<String, Class<? extends BeanDefinitionReader>> importedResources) {

    Map<Class<?>, BeanDefinitionReader> readerInstanceCache = new HashMap<Class<?>, BeanDefinitionReader>();

    for (Map.Entry<String, Class<? extends BeanDefinitionReader>> entry : importedResources.entrySet()) {
        String resource = entry.getKey();
        Class<? extends BeanDefinitionReader> readerClass = entry.getValue();

        // Default reader selection necessary?
        if (BeanDefinitionReader.class == readerClass) {
            if (StringUtils.endsWithIgnoreCase(resource, ".groovy")) {
                // When clearly asking for Groovy, that's what they'll get...
                readerClass = GroovyBeanDefinitionReader.class;
            }
            else {
                // Primarily ".xml" files but for any other extension as well
                readerClass = XmlBeanDefinitionReader.class;
            }
        }

        BeanDefinitionReader reader = readerInstanceCache.get(readerClass);
        if (reader == null) {
            try {
                // Instantiate the specified BeanDefinitionReader
                reader = readerClass.getConstructor(BeanDefinitionRegistry.class).newInstance(this.registry);
                // Delegate the current ResourceLoader to it if possible
                if (reader instanceof AbstractBeanDefinitionReader) {
                    AbstractBeanDefinitionReader abdr = ((AbstractBeanDefinitionReader) reader);
                    abdr.setResourceLoader(this.resourceLoader);
                    abdr.setEnvironment(this.environment);
                }
                readerInstanceCache.put(readerClass, reader);
            }
            catch (Exception ex) {
                throw new IllegalStateException(
                        "Could not instantiate BeanDefinitionReader class [" + readerClass.getName() + "]");
            }
        }

        // TODO SPR-6310: qualify relative path locations as done in AbstractContextLoader.modifyLocations
        reader.loadBeanDefinitions(resource);
    }
}
项目:spring-boot-concourse    文件:BeanDefinitionLoader.java   
private int load(GroovyBeanDefinitionSource source) {
    int before = this.xmlReader.getRegistry().getBeanDefinitionCount();
    ((GroovyBeanDefinitionReader) this.groovyReader).beans(source.getBeans());
    int after = this.xmlReader.getRegistry().getBeanDefinitionCount();
    return after - before;
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:isf-book    文件:MyDocumentsBeanDefinitionReaderTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:spring4-sandbox    文件:GroovyJpaConferenceDaoImplTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:spring4-sandbox    文件:GroovyConferenceServiceTest.java   
@Override
protected BeanDefinitionReader createBeanDefinitionReader(
        GenericApplicationContext context) {
    return new GroovyBeanDefinitionReader(context);
}
项目:spring4-understanding    文件:GroovyWebApplicationContext.java   
/**
 * Load the bean definitions with the given GroovyBeanDefinitionReader.
 * <p>The lifecycle of the bean factory is handled by the refreshBeanFactory method;
 * therefore this method is just supposed to load and/or register bean definitions.
 * <p>Delegates to a ResourcePatternResolver for resolving location patterns
 * into Resource instances.
 * @throws IOException if the required Groovy script or XML file isn't found
 * @see #refreshBeanFactory
 * @see #getConfigLocations
 * @see #getResources
 * @see #getResourcePatternResolver
 */
protected void loadBeanDefinitions(GroovyBeanDefinitionReader reader) throws IOException {
    String[] configLocations = getConfigLocations();
    if (configLocations != null) {
        for (String configLocation : configLocations) {
            reader.loadBeanDefinitions(configLocation);
        }
    }
}
项目:lams    文件:GenericGroovyApplicationContext.java   
/**
 * Exposes the underlying {@link GroovyBeanDefinitionReader} for convenient access
 * to the {@code loadBeanDefinition} methods on it as well as the ability
 * to specify an inline Groovy bean definition closure.
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(org.springframework.core.io.Resource...)
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(String...)
 */
public final GroovyBeanDefinitionReader getReader() {
    return this.reader;
}
项目:spring4-understanding    文件:GenericGroovyApplicationContext.java   
/**
 * Exposes the underlying {@link GroovyBeanDefinitionReader} for convenient access
 * to the {@code loadBeanDefinition} methods on it as well as the ability
 * to specify an inline Groovy bean definition closure.
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(org.springframework.core.io.Resource...)
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(String...)
 */
public final GroovyBeanDefinitionReader getReader() {
    return this.reader;
}
项目:spring4-understanding    文件:GroovyWebApplicationContext.java   
/**
 * Initialize the bean definition reader used for loading the bean
 * definitions of this context. Default implementation is empty.
 * <p>Can be overridden in subclasses.
 * @param beanDefinitionReader the bean definition reader used by this context
 */
protected void initBeanDefinitionReader(GroovyBeanDefinitionReader beanDefinitionReader) {
}
项目:spring4-understanding    文件:GenericGroovyXmlWebContextLoader.java   
/**
 * Load bean definitions into the supplied {@link GenericWebApplicationContext context}
 * from the locations in the supplied {@code WebMergedContextConfiguration} using a
 * {@link GroovyBeanDefinitionReader}.
 *
 * @param context the context into which the bean definitions should be loaded
 * @param webMergedConfig the merged context configuration
 * @see AbstractGenericWebContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericWebApplicationContext context,
        WebMergedContextConfiguration webMergedConfig) {
    new GroovyBeanDefinitionReader(context).loadBeanDefinitions(webMergedConfig.getLocations());
}
项目:spring4-understanding    文件:GenericGroovyXmlContextLoader.java   
/**
 * Load bean definitions into the supplied {@link GenericApplicationContext context}
 * from the locations in the supplied {@code MergedContextConfiguration} using a
 * {@link GroovyBeanDefinitionReader}.
 *
 * @param context the context into which the bean definitions should be loaded
 * @param mergedConfig the merged context configuration
 * @see org.springframework.test.context.support.AbstractGenericContextLoader#loadBeanDefinitions
 */
@Override
protected void loadBeanDefinitions(GenericApplicationContext context, MergedContextConfiguration mergedConfig) {
    new GroovyBeanDefinitionReader(context).loadBeanDefinitions(mergedConfig.getLocations());
}
项目:my-spring-cache-redis    文件:GenericGroovyApplicationContext.java   
/**
 * Exposes the underlying {@link GroovyBeanDefinitionReader} for convenient access
 * to the {@code loadBeanDefinition} methods on it as well as the ability
 * to specify an inline Groovy bean definition closure.
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(org.springframework.core.io.Resource...)
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(String...)
 */
public final GroovyBeanDefinitionReader getReader() {
    return this.reader;
}
项目:spring    文件:GenericGroovyApplicationContext.java   
/**
 * Exposes the underlying {@link GroovyBeanDefinitionReader} for convenient access
 * to the {@code loadBeanDefinition} methods on it as well as the ability
 * to specify an inline Groovy bean definition closure.
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(org.springframework.core.io.Resource...)
 * @see GroovyBeanDefinitionReader#loadBeanDefinitions(String...)
 */
public final GroovyBeanDefinitionReader getReader() {
    return this.reader;
}