本文整理汇总了Java中org.springframework.beans.factory.parsing.BeanDefinitionParsingException类的典型用法代码示例。如果您正苦于以下问题:Java BeanDefinitionParsingException类的具体用法?Java BeanDefinitionParsingException怎么用?Java BeanDefinitionParsingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeanDefinitionParsingException类属于org.springframework.beans.factory.parsing包,在下文中一共展示了BeanDefinitionParsingException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: xmlns
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* 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);
}
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:GroovyBeanDefinitionReader.java
示例2: configurationClassesMayNotBeFinal
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void configurationClassesMayNotBeFinal() {
@Configuration
final class Config { }
BeanDefinition configBeanDef = rootBeanDefinition(Config.class).getBeanDefinition();
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
beanFactory.registerBeanDefinition("config", configBeanDef);
try {
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
fail("expected exception");
}
catch (BeanDefinitionParsingException ex) {
assertTrue(ex.getMessage(), ex.getMessage().contains("Remove the final modifier"));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:InvalidConfigurationClassDefinitionTests.java
示例3: xmlns
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* 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);
}
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:GroovyBeanDefinitionReader.java
示例4: xmlns
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* 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);
}
}
}
开发者ID:txazo,项目名称:spring,代码行数:23,代码来源:GroovyBeanDefinitionReader.java
示例5: parseInternal
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* @param element
* @param parserContext
* @return
* @see org.springframework.beans.factory.xml.AbstractBeanDefinitionParser#parseInternal(org.w3c.dom.Element,
* org.springframework.beans.factory.xml.ParserContext)
*/
@Override
protected AbstractBeanDefinition parseInternal(final Element element,
final ParserContext parserContext)
{
final BeanDefinitionBuilder factory = parsePFixture(element);
final List<Element> childElements = DomUtils.getChildElementsByTagName(element,
CoreSchemaConstants.ELEMENT_LOCATION);
// Must have at least one element
if (childElements == null || childElements.isEmpty())
{
throw new BeanDefinitionParsingException(
new Problem(
"Portable test fixture manager must be wired with at least one context location",
new Location(parserContext.getReaderContext().getResource())));
}
parseChildLocations(childElements, factory);
return factory.getBeanDefinition();
}
开发者ID:openfurther,项目名称:further-open-core,代码行数:28,代码来源:PFixtureManagerBeanDefinitionParser.java
示例6: testInvalidDefaultsCheck
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
public void testInvalidDefaultsCheck() throws Exception {
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(appContext);
try {
reader.loadBeanDefinitions(new ClassPathResource("osgiInvalidDefaults.xml", getClass()));
fail("should have failed since osgi:defaults cannot be used outside the root element");
}
catch (BeanDefinitionParsingException ex) {
// expected
}
}
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:InvalidOsgiDefaultsTest.java
示例7: loadBeanDefinitions
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* Load bean definitions from the specified Groovy script.
* @param encodedResource the resource descriptor for the Groovy script,
* allowing to specify an encoding to use for parsing the file
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
Closure beans = new Closure(this){
public Object call(Object[] args) {
invokeBeanDefiningClosure((Closure) args[0]);
return null;
}
};
Binding binding = new Binding() {
@Override
public void setVariable(String name, Object value) {
if (currentBeanDefinition !=null) {
applyPropertyToBeanDefinition(name, value);
}
else {
super.setVariable(name, value);
}
}
};
binding.setVariable("beans", beans);
int countBefore = getRegistry().getBeanDefinitionCount();
try {
GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
shell.evaluate(encodedResource.getReader(), encodedResource.getResource().getFilename());
}
catch (Throwable ex) {
throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
new Location(encodedResource.getResource()), null, ex));
}
return getRegistry().getBeanDefinitionCount() - countBefore;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:GroovyBeanDefinitionReader.java
示例8: testDuplicatePointcutConfig
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void testDuplicatePointcutConfig() {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(getClass(), "pointcutDuplication.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
}
catch (BeanDefinitionStoreException ex) {
assertTrue(ex.contains(BeanDefinitionParsingException.class));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AopNamespaceHandlerPointcutErrorTests.java
示例9: testMissingPointcutConfig
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void testMissingPointcutConfig() {
try {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(getClass(), "pointcutMissing.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
}
catch (BeanDefinitionStoreException ex) {
assertTrue(ex.contains(BeanDefinitionParsingException.class));
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:13,代码来源:AopNamespaceHandlerPointcutErrorTests.java
示例10: simpleCircularImportIsDetected
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void simpleCircularImportIsDetected() throws Exception {
boolean threw = false;
try {
newParser().parse(loadAsConfigurationSource(A.class), "A");
}
catch (BeanDefinitionParsingException ex) {
assertTrue("Wrong message. Got: " + ex.getMessage(),
ex.getMessage().contains(
"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.B' " +
"to import class 'AbstractCircularImportDetectionTests.A'"));
threw = true;
}
assertTrue(threw);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AbstractCircularImportDetectionTests.java
示例11: complexCircularImportIsDetected
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void complexCircularImportIsDetected() throws Exception {
boolean threw = false;
try {
newParser().parse(loadAsConfigurationSource(X.class), "X");
}
catch (BeanDefinitionParsingException ex) {
assertTrue("Wrong message. Got: " + ex.getMessage(),
ex.getMessage().contains(
"Illegal attempt by @Configuration class 'AbstractCircularImportDetectionTests.Z2' " +
"to import class 'AbstractCircularImportDetectionTests.Z'"));
threw = true;
}
assertTrue(threw);
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:16,代码来源:AbstractCircularImportDetectionTests.java
示例12: testInvalidConfigScopedProxy
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
@SuppressWarnings("resource")
public void testInvalidConfigScopedProxy() throws Exception {
exception.expect(BeanDefinitionParsingException.class);
exception.expectMessage(containsString("Cannot define both 'scope-resolver' and 'scoped-proxy' on <component-scan> tag"));
exception.expectMessage(containsString("Offending resource: class path resource [org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml]"));
new ClassPathXmlApplicationContext("org/springframework/context/annotation/scopedProxyInvalidConfigTests.xml");
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:ComponentScanParserScopedProxyTests.java
示例13: loadBeanDefinitions
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* Load bean definitions from the specified Groovy script or XML file.
* <p>Note that {@code ".xml"} files will be parsed as XML content; all other kinds
* of resources will be parsed as Groovy scripts.
* @param encodedResource the resource descriptor for the Groovy script or XML file,
* allowing specification of an encoding to use for parsing the file
* @return the number of bean definitions found
* @throws BeanDefinitionStoreException in case of loading or parsing errors
*/
public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
// Check for XML files and redirect them to the "standard" XmlBeanDefinitionReader
String filename = encodedResource.getResource().getFilename();
if (StringUtils.endsWithIgnoreCase(filename, ".xml")) {
return this.standardXmlBeanDefinitionReader.loadBeanDefinitions(encodedResource);
}
Closure beans = new Closure(this) {
public Object call(Object[] args) {
invokeBeanDefiningClosure((Closure) args[0]);
return null;
}
};
Binding binding = new Binding() {
@Override
public void setVariable(String name, Object value) {
if (currentBeanDefinition != null) {
applyPropertyToBeanDefinition(name, value);
}
else {
super.setVariable(name, value);
}
}
};
binding.setVariable("beans", beans);
int countBefore = getRegistry().getBeanDefinitionCount();
try {
GroovyShell shell = new GroovyShell(getResourceLoader().getClassLoader(), binding);
shell.evaluate(encodedResource.getReader(), "beans");
}
catch (Throwable ex) {
throw new BeanDefinitionParsingException(new Problem("Error evaluating Groovy script: " + ex.getMessage(),
new Location(encodedResource.getResource()), null, ex));
}
return getRegistry().getBeanDefinitionCount() - countBefore;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:47,代码来源:GroovyBeanDefinitionReader.java
示例14: beanMethodOverloadingWithoutInheritance
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void beanMethodOverloadingWithoutInheritance() {
@SuppressWarnings({ "hiding" })
@Configuration class Config {
@Bean String aString() { return "na"; }
@Bean String aString(Integer dependency) { return "na"; }
}
this.thrown.expect(BeanDefinitionParsingException.class);
this.thrown.expectMessage("overloaded @Bean methods named 'aString'");
new AnnotationConfigApplicationContext(Config.class);
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:14,代码来源:BeanMethodPolymorphismTests.java
示例15: loadBeanDefinitions
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
/**
* Wrapper for Load Bean Definitions
*
* @param xmlReader
* @param resourceName
*/
private static void loadBeanDefinitions(XmlBeanDefinitionReader xmlReader, String resourceName) throws RuntimeException {
try {
xmlReader.loadBeanDefinitions(new ClassPathResource(resourceName));
} catch (final BeanDefinitionParsingException bdpe) {
if (resourceName.equalsIgnoreCase(defaultSecurity)) {
return;
} else {
throw bdpe;
}
}
}
开发者ID:jaschenk,项目名称:jeffaschenk-commons,代码行数:18,代码来源:SetUpSpringContainerBootStrap.java
示例16: testMultipleElements
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void testMultipleElements() throws Exception {
this.expectedException.expect(BeanDefinitionParsingException.class);
this.expectedException.expectMessage("only allowed once per");
//noinspection ResultOfObjectAllocationIgnored
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-testMultipleElements.xml", getClass());
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:9,代码来源:ContextCredentialsBeanDefinitionParserTest.java
示例17: testWithEmptyAccessKey
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void testWithEmptyAccessKey() throws Exception {
this.expectedException.expect(BeanDefinitionParsingException.class);
this.expectedException.expectMessage("The 'access-key' attribute must not be empty");
//noinspection ResultOfObjectAllocationIgnored
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-testWithEmptyAccessKey.xml", getClass());
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:8,代码来源:ContextCredentialsBeanDefinitionParserTest.java
示例18: testWithEmptySecretKey
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void testWithEmptySecretKey() throws Exception {
this.expectedException.expect(BeanDefinitionParsingException.class);
this.expectedException.expectMessage("The 'secret-key' attribute must not be empty");
//noinspection ResultOfObjectAllocationIgnored
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-testWithEmptySecretKey.xml", getClass());
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:8,代码来源:ContextCredentialsBeanDefinitionParserTest.java
示例19: parse_autoDetectionAndStaticRegionProvider_reportsError
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void parse_autoDetectionAndStaticRegionProvider_reportsError() throws Exception {
//Arrange
this.expectedException.expect(BeanDefinitionParsingException.class);
this.expectedException.expectMessage("The attribute 'auto-detect' can only be enabled without a region or region-provider specified");
//Act
//noinspection ResultOfObjectAllocationIgnored
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-testAutoDetectionWithConfiguredRegion.xml", getClass());
//Assert
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:13,代码来源:ContextRegionBeanDefinitionParserTest.java
示例20: parse_noValidRegionProviderConfigured_reportsError
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException; //导入依赖的package包/类
@Test
public void parse_noValidRegionProviderConfigured_reportsError() throws Exception {
//Arrange
this.expectedException.expect(BeanDefinitionParsingException.class);
this.expectedException.expectMessage("Either auto-detect must be enabled, or a region or region-provider must be specified");
//Act
//noinspection ResultOfObjectAllocationIgnored
new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-testNoValidRegionProviderConfigurationSpecified.xml", getClass());
//Assert
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:13,代码来源:ContextRegionBeanDefinitionParserTest.java
注:本文中的org.springframework.beans.factory.parsing.BeanDefinitionParsingException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论