当前位置: 首页>>代码示例>>Java>>正文


Java FatalBeanException类代码示例

本文整理汇总了Java中org.springframework.beans.FatalBeanException的典型用法代码示例。如果您正苦于以下问题:Java FatalBeanException类的具体用法?Java FatalBeanException怎么用?Java FatalBeanException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FatalBeanException类属于org.springframework.beans包,在下文中一共展示了FatalBeanException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureFeature

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
private void configureFeature(ObjectMapper objectMapper, Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
开发者ID:JetBrains,项目名称:teamcity-hashicorp-vault-plugin,代码行数:21,代码来源:Jackson2ObjectMapperBuilder.java

示例2: createApplicationContext

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
protected ApplicationContext createApplicationContext(String uri) throws MalformedURLException {
	Resource resource = Utils.resourceFromString(uri);
	LOG.debug("Using " + resource + " from " + uri);
	try {
		return new ResourceXmlApplicationContext(resource) {
			@Override
			protected ConfigurableEnvironment createEnvironment() {
				return new ReversePropertySourcesStandardServletEnvironment();
			}

			@Override
			protected void initPropertySources() {
				WebApplicationContextUtils.initServletPropertySources(getEnvironment().getPropertySources(),
						ServletContextHolder.getServletContext());
			}
		};
	} catch (FatalBeanException errorToLog) {
		LOG.error("Failed to load: " + resource + ", reason: " + errorToLog.getLocalizedMessage(), errorToLog);
		throw errorToLog;
	}
}
 
开发者ID:Hevelian,项目名称:hevelian-activemq,代码行数:23,代码来源:WebXBeanBrokerFactory.java

示例3: release

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
public void release() throws FatalBeanException {
	synchronized (bfgInstancesByKey) {
		BeanFactory savedRef = this.groupContextRef;
		if (savedRef != null) {
			this.groupContextRef = null;
			BeanFactoryGroup bfg = bfgInstancesByObj.get(savedRef);
			if (bfg != null) {
				bfg.refCount--;
				if (bfg.refCount == 0) {
					destroyDefinition(savedRef, resourceLocation);
					bfgInstancesByKey.remove(resourceLocation);
					bfgInstancesByObj.remove(savedRef);
				}
			}
			else {
				// This should be impossible.
				logger.warn("Tried to release a SingletonBeanFactoryLocator group definition " +
						"more times than it has actually been used. Resource name [" + resourceLocation + "]");
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:SingletonBeanFactoryLocator.java

示例4: configureFeature

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
private void configureFeature(Object feature, boolean enabled) {
	if (feature instanceof JsonParser.Feature) {
		this.objectMapper.configure((JsonParser.Feature) feature, enabled);
	}
	else if (feature instanceof JsonGenerator.Feature) {
		this.objectMapper.configure((JsonGenerator.Feature) feature, enabled);
	}
	else if (feature instanceof SerializationFeature) {
		this.objectMapper.configure((SerializationFeature) feature, enabled);
	}
	else if (feature instanceof DeserializationFeature) {
		this.objectMapper.configure((DeserializationFeature) feature, enabled);
	}
	else if (feature instanceof MapperFeature) {
		this.objectMapper.configure((MapperFeature) feature, enabled);
	}
	else {
		throw new FatalBeanException("Unknown feature class: " + feature.getClass().getName());
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:Jackson2ObjectMapperFactoryBean.java

示例5: afterPropertiesSet

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
/**
 * Is called by the Spring container after all properties have been set. <br>
 * It is implemented in order to initialize the beanClass field correctly and to make sure
 * that either the bean id or the bean itself have been set on this creator.
 * @see org.springframework.beans.factory.InitializingBean
 */
public void afterPropertiesSet()
{
    // make sure that either the bean or the beanId have been set correctly
    if (bean != null) {
        this.beanClass = bean.getClass();
    } else if (beanId != null) {
        this.beanClass = applicationContext.getType(beanId);
    } else {
        throw new FatalBeanException(
                "You should either set the bean property directly or set the beanId property");
    }

    // make sure to handle cglib proxies correctly
    if(AopUtils.isCglibProxyClass(this.beanClass)) {
        this.beanClass = this.beanClass.getSuperclass();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:BeanCreator.java

示例6: getMatchOutcome

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context,
    AnnotatedTypeMetadata metadata) {
  String prefix = (String) attribute(metadata, "prefix");
  Class<?> value = (Class<?>) attribute(metadata, "value");
  ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
  try {
    new Binder(ConfigurationPropertySources.from(environment.getPropertySources()))
        .bind(prefix, Bindable.of(value))
        .orElseThrow(
            () -> new FatalBeanException("Could not bind DataSourceSettings properties"));
    return new ConditionOutcome(true, String.format("Map property [%s] is not empty", prefix));
  } catch (Exception e) {
    //ignore
  }
  return new ConditionOutcome(false, String.format("Map property [%s] is empty", prefix));
}
 
开发者ID:lord-of-code,项目名称:loc-framework,代码行数:18,代码来源:PrefixPropertyCondition.java

示例7: postProcessAfterInitialization

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
	try {
		Class<?> wrapped = AopUtils.getTargetClass(bean);
		if (!isSpring(wrapped)) {
			Class<?> declaring = AnnotationUtils.findAnnotationDeclaringClass(Steps.class, wrapped);
			if (null != declaring) {
				processStepsBean(beanName, wrapped);
			}
		}
		return bean;
	}
	catch (Exception e) {
		throw new FatalBeanException("unable to processAnnotationContainer @Steps beans", e);
	}
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:17,代码来源:StepsAnnotationProcessor.java

示例8: afterPropertiesSet

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
/**
 * Is called by the Spring container after all properties have been set. <br>
 * It is implemented in order to initialize the beanClass field correctly and to make sure
 * that either the bean id or the bean itself have been set on this creator.
 * @see org.springframework.beans.factory.InitializingBean
 */
public void afterPropertiesSet()
{
    // make sure that either the bean or the beanId have been set correctly
    if (bean != null)
    {
        this.beanClass = bean.getClass();
    }
    else if (beanId != null)
    {
        this.beanClass = beanFactory.getType(beanId);
    }
    else
    {
        throw new FatalBeanException("You should either set the bean property directly or set the beanId property");
    }

    // make sure to handle cglib proxies correctly
    if (ClassUtils.isCglibProxyClass(this.beanClass))
    {
        this.beanClass = this.beanClass.getSuperclass();
    }
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:29,代码来源:BeanCreator.java

示例9: resolveBeanClassname

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
/**
 *  Tries to obtain the beanClassName from the definition and if that fails tries to get it from
 *  the parent (and even parent BeanFactory if we have to).
 *
 *  @param definition a non null instance
 *  @param registry a non null instance
 *  @return class name or null if not found
 */
protected String resolveBeanClassname(BeanDefinition definition, BeanDefinitionRegistry registry)
{
    String beanClassName = definition.getBeanClassName();
    while(!StringUtils.hasText(beanClassName))
    {
        try
        {
            Method m = definition.getClass().getMethod("getParentName", new Class[0]);
            String parentName = (String) m.invoke(definition, new Object[0]);
            BeanDefinition parentDefinition = findParentDefinition(parentName, registry);
            beanClassName = parentDefinition.getBeanClassName();
            definition = parentDefinition;
        } catch (Exception e)
        {
            throw new FatalBeanException("No parent bean could be found for " + definition, e);
        }
    }
    return beanClassName;
}
 
开发者ID:directwebremoting,项目名称:dwr,代码行数:28,代码来源:NamespaceParserHelper.java

示例10: handlerBeanNotFound

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Test
public void handlerBeanNotFound() throws Exception {
	MockServletContext sc = new MockServletContext("");
	XmlWebApplicationContext root = new XmlWebApplicationContext();
	root.setServletContext(sc);
	root.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map1.xml"});
	root.refresh();
	XmlWebApplicationContext wac = new XmlWebApplicationContext();
	wac.setParent(root);
	wac.setServletContext(sc);
	wac.setNamespace("map2err");
	wac.setConfigLocations(new String[] {"/org/springframework/web/servlet/handler/map2err.xml"});
	try {
		wac.refresh();
		fail("Should have thrown NoSuchBeanDefinitionException");
	}
	catch (FatalBeanException ex) {
		NoSuchBeanDefinitionException nestedEx = (NoSuchBeanDefinitionException) ex.getCause();
		assertEquals("mainControlle", nestedEx.getBeanName());
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:SimpleUrlHandlerMappingTests.java

示例11: validateDeclaredRemotingException

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
private void validateDeclaredRemotingException(Method method, Class<?> clazz) throws IllegalStateException {
	Class<?>[] exceptionTypeArray = method.getExceptionTypes();

	boolean located = false;
	for (int i = 0; i < exceptionTypeArray.length; i++) {
		Class<?> exceptionType = exceptionTypeArray[i];
		if (RemotingException.class.isAssignableFrom(exceptionType)) {
			located = true;
			break;
		}
	}

	if (located) {
		throw new FatalBeanException(String.format(
				"The method(%s) shouldn't be declared to throw a remote exception: org.bytesoft.compensable.RemotingException!",
				method));
	}

}
 
开发者ID:liuyangming,项目名称:ByteTCC,代码行数:20,代码来源:CompensableAnnotationValidator.java

示例12: processBeanDefinition

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
protected void processBeanDefinition(ConfigurableListableBeanFactory beanFactory, BeanDefinition bd, String beanClassName, String definitionName) throws FatalBeanException {
    if (beanFactory instanceof DefaultListableBeanFactory) {
        DefaultListableBeanFactory factory = (DefaultListableBeanFactory) beanFactory;
        try {
            final WebScript webScript = AnnotationUtils.findAnnotation(Class.forName(beanClassName), WebScript.class);
            if (webScript != null) {
                String beanName = webScript.value();
                if (StringUtils.hasText(beanName)) {
                    final String webScriptName = "webscript." + beanName + "." + webScript.method().toString().toLowerCase();
                    factory.removeBeanDefinition(definitionName);
                    factory.registerBeanDefinition(webScriptName, bd);
                } else {
                    throw new FatalBeanException(String.format("%s is @WebScript annotated, but no value set.", beanClassName));
                }
            }
        } catch (ClassNotFoundException e) {
            logger.warn(String.format("ClassNotFoundException while searching for ChildOf annotation on bean name '%s' of type '%s'. This error is expected on Alfresco Community 4.2.c. for some classes in package 'org.alfresco.repo'", definitionName, beanClassName));
        }
    } else {
        logger.error(String.format("Unable to register '%s' as webscript because beanFactory is not instance of 'DefaultListableBeanFactory'", definitionName));
    }
}
 
开发者ID:andreacomo,项目名称:alfresco-annotations,代码行数:24,代码来源:WebScriptConfigurer.java

示例13: processBeanDefinition

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
@Override
protected void processBeanDefinition(ConfigurableListableBeanFactory beanFactory, BeanDefinition bd, String beanClassName, String definitionName) throws FatalBeanException {
    try {
        final ChildOf childOf = AnnotationUtils.findAnnotation(Class.forName(beanClassName), ChildOf.class);
        if (childOf != null) {
            final String parentName = childOf.value();
            if (StringUtils.hasText(parentName)) {
                bd.setParentName(parentName);
            } else {
                throw new FatalBeanException(String.format("%s is @ChildOf annotated, but no value set.", beanClassName));
            }
        }
    } catch (ClassNotFoundException e) {
        logger.warn(String.format("ClassNotFoundException while searching for ChildOf annotation on bean name '%s' of type '%s'. This error is expected on Alfresco Community 4.2.c. for some classes in package 'org.alfresco.repo'", definitionName, beanClassName));
    }
}
 
开发者ID:andreacomo,项目名称:alfresco-annotations,代码行数:17,代码来源:ChildOfConfigurer.java

示例14: postProcessBeanFactory

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
    for (String definitionName : beanDefinitionNames) {
        try {
            final BeanDefinition bd = beanFactory.getBeanDefinition(definitionName);
            final String beanClassName = bd.getBeanClassName();
            if (StringUtils.hasText(beanClassName)) {
                try {
                    processBeanDefinition(beanFactory, bd, beanClassName, definitionName);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                    throw new FatalBeanException("Unknown class defined.", e);
                }
            }
        } catch (NoSuchBeanDefinitionException ex) {
            logger.warn(ex.getMessage());
            continue;
        }
    }
}
 
开发者ID:andreacomo,项目名称:alfresco-annotations,代码行数:21,代码来源:AbstractPostProcessorConfigurer.java

示例15: MergeClassPathXMLApplicationContext

import org.springframework.beans.FatalBeanException; //导入依赖的package包/类
/**
 * Create a new MergeClassPathXMLApplicationContext, loading the definitions from the given definitions. Note,
 * all sourceLocation files will be merged using standard Spring configuration override rules. However, the patch
 * files are fully merged into the result of the sourceLocations simple merge. Patch merges are first executed according
 * to beans with the same id. Subsequent merges within a bean are executed against tagnames - ignoring any
 * further id attributes.
 * 
 * @param sourceLocations array of relative (or absolute) paths within the class path for the source application context files
 * @param patchLocations array of relative (or absolute) paths within the class path for the patch application context files
 * @param parent the parent context
 * @throws BeansException
 */
public MergeClassPathXMLApplicationContext(String[] sourceLocations, String[] patchLocations, ApplicationContext parent) throws BeansException {
    this(parent);
    
    ResourceInputStream[] sources = new ResourceInputStream[sourceLocations.length];
    for (int j=0;j<sourceLocations.length;j++){
        sources[j] = new ResourceInputStream(getClassLoader(parent).getResourceAsStream(sourceLocations[j]), sourceLocations[j]);
    }
    
    ResourceInputStream[] patches = new ResourceInputStream[patchLocations.length];
    for (int j=0;j<patches.length;j++){
        patches[j] = new ResourceInputStream(getClassLoader(parent).getResourceAsStream(patchLocations[j]), patchLocations[j]);
    }

    ImportProcessor importProcessor = new ImportProcessor(this);
    try {
        sources = importProcessor.extract(sources);
        patches = importProcessor.extract(patches);
    } catch (MergeException e) {
        throw new FatalBeanException("Unable to merge source and patch locations", e);
    }

    this.configResources = new MergeApplicationContextXmlConfigResource().getConfigResources(sources, patches);
    refresh();
}
 
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:37,代码来源:MergeClassPathXMLApplicationContext.java


注:本文中的org.springframework.beans.FatalBeanException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。