org.springframework.core.io.DescriptiveResource Java Examples
The following examples show how to use
org.springframework.core.io.DescriptiveResource.
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: GroovyBeanDefinitionReader.java From java-technology-stack with MIT License | 6 votes |
/** * Define a Spring XML namespace definition to use. * @param definition the namespace definition */ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String,String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
Example #2
Source File: GroovyBeanDefinitionReader.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Define a Spring XML namespace definition to use. * @param definition the namespace definition */ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String,String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
Example #3
Source File: GroovyBeanDefinitionReader.java From lams with GNU General Public License v2.0 | 6 votes |
private GroovyDynamicElementReader createDynamicElementReader(String namespace) { XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource( "Groovy")); BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext); boolean decorating = (this.currentBeanDefinition != null); if (!decorating) { this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace); } return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) { @Override protected void afterInvocation() { if (!this.decorating) { currentBeanDefinition = null; } } }; }
Example #4
Source File: GroovyBeanDefinitionReader.java From blog_demos with Apache License 2.0 | 6 votes |
/** * Define a Spring namespace definition to use. * @param definition the namespace definition */ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String,String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.xmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
Example #5
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); beanFactory.registerBeanDefinition("bar", rbd); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); beanFactory.setAllowBeanDefinitionOverriding(false); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); try { pp.postProcessBeanFactory(beanFactory); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { assertTrue(ex.getMessage().contains("bar")); assertTrue(ex.getMessage().contains("SingletonBeanConfig")); assertTrue(ex.getMessage().contains(TestBean.class.getName())); } }
Example #6
Source File: GroovyBeanDefinitionReader.java From spring-analysis-note with MIT License | 6 votes |
private GroovyDynamicElementReader createDynamicElementReader(String namespace) { XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource( "Groovy")); BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext); boolean decorating = (this.currentBeanDefinition != null); if (!decorating) { this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace); } return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) { @Override protected void afterInvocation() { if (!this.decorating) { currentBeanDefinition = null; } } }; }
Example #7
Source File: GroovyBeanDefinitionReader.java From spring-analysis-note with MIT License | 6 votes |
/** * Define a Spring XML namespace definition to use. * @param definition the namespace definition */ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String,String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve(uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
Example #8
Source File: ConfigurationClassPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); beanFactory.registerBeanDefinition("bar", rbd); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); beanFactory.setAllowBeanDefinitionOverriding(false); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); try { pp.postProcessBeanFactory(beanFactory); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { assertTrue(ex.getMessage().contains("bar")); assertTrue(ex.getMessage().contains("SingletonBeanConfig")); assertTrue(ex.getMessage().contains(TestBean.class.getName())); } }
Example #9
Source File: GroovyBeanDefinitionReader.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Define a Spring XML namespace definition to use. * @param definition the namespace definition */ public void xmlns(Map<String, String> definition) { if (!definition.isEmpty()) { for (Map.Entry<String,String> entry : definition.entrySet()) { String namespace = entry.getKey(); String uri = entry.getValue(); if (uri == null) { throw new IllegalArgumentException("Namespace definition must supply a non-null URI"); } NamespaceHandler namespaceHandler = this.groovyDslXmlBeanDefinitionReader.getNamespaceHandlerResolver().resolve( uri); if (namespaceHandler == null) { throw new BeanDefinitionParsingException(new Problem("No namespace handler found for URI: " + uri, new Location(new DescriptiveResource(("Groovy"))))); } this.namespaces.put(namespace, uri); } } }
Example #10
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void postProcessorFailsOnImplicitOverrideIfOverridingIsNotAllowed() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); beanFactory.registerBeanDefinition("bar", rbd); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); beanFactory.setAllowBeanDefinitionOverriding(false); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); try { pp.postProcessBeanFactory(beanFactory); fail("Should have thrown BeanDefinitionStoreException"); } catch (BeanDefinitionStoreException ex) { assertTrue(ex.getMessage().contains("bar")); assertTrue(ex.getMessage().contains("SingletonBeanConfig")); assertTrue(ex.getMessage().contains(TestBean.class.getName())); } }
Example #11
Source File: GroovyBeanDefinitionReader.java From spring4-understanding with Apache License 2.0 | 6 votes |
private GroovyDynamicElementReader createDynamicElementReader(String namespace) { XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource( "Groovy")); BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext); boolean decorating = (this.currentBeanDefinition != null); if (!decorating) { this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace); } return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) { @Override protected void afterInvocation() { if (!this.decorating) { currentBeanDefinition = null; } } }; }
Example #12
Source File: VelocityConfigurerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void velocityConfigurerWithCsvPathAndNonFileAccess() throws IOException, VelocityException { VelocityConfigurer vc = new VelocityConfigurer(); vc.setResourceLoaderPath("file:/mydir,file:/yourdir"); vc.setResourceLoader(new ResourceLoader() { @Override public Resource getResource(String location) { if ("file:/yourdir/test".equals(location)) { return new DescriptiveResource(""); } return new ByteArrayResource("test".getBytes(), "test"); } @Override public ClassLoader getClassLoader() { return getClass().getClassLoader(); } }); vc.setPreferFileSystemAccess(false); vc.afterPropertiesSet(); assertThat(vc.createVelocityEngine(), instanceOf(VelocityEngine.class)); VelocityEngine ve = vc.createVelocityEngine(); assertEquals("test", VelocityEngineUtils.mergeTemplateIntoString(ve, "test", Collections.emptyMap())); }
Example #13
Source File: GroovyBeanDefinitionReader.java From java-technology-stack with MIT License | 6 votes |
private GroovyDynamicElementReader createDynamicElementReader(String namespace) { XmlReaderContext readerContext = this.groovyDslXmlBeanDefinitionReader.createReaderContext(new DescriptiveResource( "Groovy")); BeanDefinitionParserDelegate delegate = new BeanDefinitionParserDelegate(readerContext); boolean decorating = (this.currentBeanDefinition != null); if (!decorating) { this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(namespace); } return new GroovyDynamicElementReader(namespace, this.namespaces, delegate, this.currentBeanDefinition, decorating) { @Override protected void afterInvocation() { if (!this.decorating) { currentBeanDefinition = null; } } }; }
Example #14
Source File: ConfigurationClass.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param clazz the underlying {@link Class} to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(Class<?> clazz, String beanName) { Assert.notNull(beanName, "Bean name must not be null"); this.metadata = AnnotationMetadata.introspect(clazz); this.resource = new DescriptiveResource(clazz.getName()); this.beanName = beanName; }
Example #15
Source File: ConfigurationClass.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param clazz the underlying {@link Class} to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(Class<?> clazz, String beanName) { Assert.hasText(beanName, "Bean name must not be null"); this.metadata = new StandardAnnotationMetadata(clazz, true); this.resource = new DescriptiveResource(clazz.getName()); this.beanName = beanName; }
Example #16
Source File: ConfigurationClass.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param metadata the metadata for the underlying class to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(AnnotationMetadata metadata, String beanName) { Assert.hasText(beanName, "Bean name must not be null"); this.metadata = metadata; this.resource = new DescriptiveResource(metadata.getClassName()); this.beanName = beanName; }
Example #17
Source File: ConfigurationClassPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void postProcessorDoesNotOverrideRegularBeanDefinitions() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); beanFactory.registerBeanDefinition("bar", rbd); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); beanFactory.getBean("foo", Foo.class); beanFactory.getBean("bar", TestBean.class); }
Example #18
Source File: ConfigurationClass.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param clazz the underlying {@link Class} to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(Class<?> clazz, String beanName) { Assert.hasText(beanName, "Bean name must not be null"); this.metadata = new StandardAnnotationMetadata(clazz, true); this.resource = new DescriptiveResource(clazz.toString()); this.beanName = beanName; }
Example #19
Source File: ConfigurationClass.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param metadata the metadata for the underlying class to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(AnnotationMetadata metadata, String beanName) { Assert.hasText(beanName, "Bean name must not be null"); this.metadata = metadata; this.resource = new DescriptiveResource(metadata.getClassName()); this.beanName = beanName; }
Example #20
Source File: FailFastProblemReporterTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testWarn() throws Exception { Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException()); Log log = mock(Log.class); FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.setLogger(log); reporter.warning(problem); verify(log).warn(any(), isA(IllegalArgumentException.class)); }
Example #21
Source File: ConfigurationClassPostProcessorTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void postProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); BeanDefinitionHolder proxied = ScopedProxyUtils.createScopedProxy( new BeanDefinitionHolder(rbd, "bar"), beanFactory, true); beanFactory.registerBeanDefinition("bar", proxied.getBeanDefinition()); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); beanFactory.getBean("foo", Foo.class); beanFactory.getBean("bar", TestBean.class); }
Example #22
Source File: FailFastProblemReporterTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testWarn() throws Exception { Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException()); Log log = mock(Log.class); FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.setLogger(log); reporter.warning(problem); verify(log).warn(any(), isA(IllegalArgumentException.class)); }
Example #23
Source File: ContextFunctionCatalogAutoConfigurationTests.java From spring-cloud-function with Apache License 2.0 | 5 votes |
@Override public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { RootBeanDefinition beanDefinition = new RootBeanDefinition( FunctionFactoryBean.class); beanDefinition.setSource(new DescriptiveResource("Function")); registry.registerBeanDefinition("function", beanDefinition); }
Example #24
Source File: FailFastProblemReporterTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testWarn() throws Exception { Problem problem = new Problem("VGER", new Location(new DescriptiveResource("here")), null, new IllegalArgumentException()); Log log = mock(Log.class); FailFastProblemReporter reporter = new FailFastProblemReporter(); reporter.setLogger(log); reporter.warning(problem); verify(log).warn(any(), isA(IllegalArgumentException.class)); }
Example #25
Source File: ConfigurationClassPostProcessorTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void postProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); BeanDefinitionHolder proxied = ScopedProxyUtils.createScopedProxy( new BeanDefinitionHolder(rbd, "bar"), beanFactory, true); beanFactory.registerBeanDefinition("bar", proxied.getBeanDefinition()); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); beanFactory.getBean("foo", Foo.class); beanFactory.getBean("bar", TestBean.class); }
Example #26
Source File: ConfigurationClass.java From spring-analysis-note with MIT License | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param metadata the metadata for the underlying class to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(AnnotationMetadata metadata, String beanName) { Assert.notNull(beanName, "Bean name must not be null"); this.metadata = metadata; this.resource = new DescriptiveResource(metadata.getClassName()); this.beanName = beanName; }
Example #27
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void postProcessorDoesNotOverrideRegularBeanDefinitionsEvenWithScopedProxy() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); BeanDefinitionHolder proxied = ScopedProxyUtils.createScopedProxy( new BeanDefinitionHolder(rbd, "bar"), beanFactory, true); beanFactory.registerBeanDefinition("bar", proxied.getBeanDefinition()); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); beanFactory.getBean("foo", Foo.class); beanFactory.getBean("bar", TestBean.class); }
Example #28
Source File: ConfigurationClass.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param clazz the underlying {@link Class} to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(Class<?> clazz, String beanName) { Assert.notNull(beanName, "Bean name must not be null"); this.metadata = new StandardAnnotationMetadata(clazz, true); this.resource = new DescriptiveResource(clazz.getName()); this.beanName = beanName; }
Example #29
Source File: ConfigurationClassPostProcessorTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void postProcessorDoesNotOverrideRegularBeanDefinitions() { RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class); rbd.setResource(new DescriptiveResource("XML or something")); beanFactory.registerBeanDefinition("bar", rbd); beanFactory.registerBeanDefinition("config", new RootBeanDefinition(SingletonBeanConfig.class)); ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor(); pp.postProcessBeanFactory(beanFactory); beanFactory.getBean("foo", Foo.class); beanFactory.getBean("bar", TestBean.class); }
Example #30
Source File: ConfigurationClass.java From java-technology-stack with MIT License | 5 votes |
/** * Create a new {@link ConfigurationClass} with the given name. * @param metadata the metadata for the underlying class to represent * @param beanName name of the {@code @Configuration} class bean * @see ConfigurationClass#ConfigurationClass(Class, ConfigurationClass) */ public ConfigurationClass(AnnotationMetadata metadata, String beanName) { Assert.notNull(beanName, "Bean name must not be null"); this.metadata = metadata; this.resource = new DescriptiveResource(metadata.getClassName()); this.beanName = beanName; }