org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader Java Examples
The following examples show how to use
org.springframework.beans.factory.groovy.GroovyBeanDefinitionReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyWebApplicationContext.java From spring-analysis-note with MIT License | 6 votes |
/** * 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); }
Example #2
Source File: GroovyWebApplicationContext.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * 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); }
Example #3
Source File: GroovyWebApplicationContext.java From lams with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example #4
Source File: GroovyWebApplicationContext.java From java-technology-stack with MIT License | 6 votes |
/** * 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); }
Example #5
Source File: SpringInitializer.java From Mycat-openEP with Apache License 2.0 | 5 votes |
private static void initGroovyConf(GenericApplicationContext context){ String classPath=ProcessInfo.getGroovyClassPath(); if(Help.isNotEmpty(classPath)){ GroovyBeanDefinitionReader reader=new GroovyBeanDefinitionReader(context); reader.loadBeanDefinitions(new ClassPathResource(classPath)); } }
Example #6
Source File: GroovyConferenceServiceTest.java From spring4-sandbox with Apache License 2.0 | 4 votes |
@Override protected BeanDefinitionReader createBeanDefinitionReader( GenericApplicationContext context) { return new GroovyBeanDefinitionReader(context); }
Example #7
Source File: ConfigurationClassBeanDefinitionReader.java From spring-analysis-note with MIT License | 4 votes |
private void loadBeanDefinitionsFromImportedResources( Map<String, Class<? extends BeanDefinitionReader>> importedResources) { Map<Class<?>, BeanDefinitionReader> readerInstanceCache = new HashMap<>(); importedResources.forEach((resource, readerClass) -> { // 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 (Throwable 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); }); }
Example #8
Source File: GroovyJpaConferenceDaoImplTest.java From spring4-sandbox with Apache License 2.0 | 4 votes |
@Override protected BeanDefinitionReader createBeanDefinitionReader( GenericApplicationContext context) { return new GroovyBeanDefinitionReader(context); }
Example #9
Source File: ConfigurationClassBeanDefinitionReader.java From spring4-understanding with Apache License 2.0 | 4 votes |
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); } }
Example #10
Source File: ConfigurationClassBeanDefinitionReader.java From lams with GNU General Public License v2.0 | 4 votes |
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 (Throwable 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); } }
Example #11
Source File: ConfigurationClassBeanDefinitionReader.java From java-technology-stack with MIT License | 4 votes |
private void loadBeanDefinitionsFromImportedResources( Map<String, Class<? extends BeanDefinitionReader>> importedResources) { Map<Class<?>, BeanDefinitionReader> readerInstanceCache = new HashMap<>(); importedResources.forEach((resource, readerClass) -> { // 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 (Throwable 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); }); }
Example #12
Source File: GroovyWebApplicationContext.java From java-technology-stack with MIT License | 3 votes |
/** * 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); } } }
Example #13
Source File: GroovyWebApplicationContext.java From spring-analysis-note with MIT License | 3 votes |
/** * 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); } } }
Example #14
Source File: GroovyWebApplicationContext.java From lams with GNU General Public License v2.0 | 3 votes |
/** * 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); } } }
Example #15
Source File: GroovyWebApplicationContext.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * 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); } } }
Example #16
Source File: GenericGroovyApplicationContext.java From spring-analysis-note with MIT License | 2 votes |
/** * 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; }
Example #17
Source File: GroovyWebApplicationContext.java From java-technology-stack with MIT License | 2 votes |
/** * 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) { }
Example #18
Source File: GroovyWebApplicationContext.java From spring-analysis-note with MIT License | 2 votes |
/** * 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) { }
Example #19
Source File: GenericGroovyXmlContextLoader.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * 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()); }
Example #20
Source File: GenericGroovyXmlWebContextLoader.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * 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()); }
Example #21
Source File: GroovyWebApplicationContext.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * 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) { }
Example #22
Source File: GenericGroovyXmlWebContextLoader.java From spring-analysis-note with MIT License | 2 votes |
/** * 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()); }
Example #23
Source File: GenericGroovyApplicationContext.java From spring4-understanding with Apache License 2.0 | 2 votes |
/** * 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; }
Example #24
Source File: GenericGroovyXmlContextLoader.java From spring-analysis-note with MIT License | 2 votes |
/** * 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()); }
Example #25
Source File: GenericGroovyApplicationContext.java From lams with GNU General Public License v2.0 | 2 votes |
/** * 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; }
Example #26
Source File: GroovyWebApplicationContext.java From lams with GNU General Public License v2.0 | 2 votes |
/** * 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) { }
Example #27
Source File: GenericGroovyApplicationContext.java From java-technology-stack with MIT License | 2 votes |
/** * 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; }
Example #28
Source File: GenericGroovyXmlContextLoader.java From java-technology-stack with MIT License | 2 votes |
/** * 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()); }
Example #29
Source File: GenericGroovyXmlWebContextLoader.java From java-technology-stack with MIT License | 2 votes |
/** * 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()); }