本文整理汇总了Java中org.springframework.beans.BeansException类的典型用法代码示例。如果您正苦于以下问题:Java BeansException类的具体用法?Java BeansException怎么用?Java BeansException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeansException类属于org.springframework.beans包,在下文中一共展示了BeansException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setApplicationContext
import org.springframework.beans.BeansException; //导入依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
for (DataSourceRegister dataSourceRegister : applicationContext.getBeansOfType(DataSourceRegister.class).values()) {
if(dataSourceRegister.getName().equals(dataSourceName)){
this.setDataSource(dataSourceRegister.getDataSource());
if(dataSourceRegister.isAsDefault()){
this.asDefault=true;
}
}
}
List<String> packageNames=new ArrayList<String>();
for(AnnotationPackages packages:applicationContext.getBeansOfType(AnnotationPackages.class).values()){
packageNames.addAll(packages.getScanPackages());
}
if(scanPackages!=null){
packageNames.addAll(scanPackages);
}
if(packageNames.size()>0){
String[] tmp=new String[packageNames.size()];
packageNames.toArray(tmp);
super.setPackagesToScan(tmp);
}
}
示例2: useBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
/**
* Load/use a bean factory, as specified by a factory key which is a JNDI
* address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
* contents of this JNDI location must be a string containing one or more
* classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
* if there is more than one. The resulting BeanFactory (or ApplicationContext)
* will be created from the combined resources.
* @see #createBeanFactory
*/
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
try {
String beanFactoryPath = lookup(factoryKey, String.class);
if (logger.isTraceEnabled()) {
logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
"] is: " + beanFactoryPath);
}
String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
return createBeanFactory(paths);
}
catch (NamingException ex) {
throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
"the class path locations of XML bean definition files", ex);
}
}
示例3: setApplicationContext
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
//Map<String, Object> serviceMap = applicationContext.getBeansWithAnnotation(XxlWebHandlerMapping.class);
String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
if (beanDefinitionNames!=null && beanDefinitionNames.length>0) {
for (String beanDefinitionName : beanDefinitionNames) {
boolean isApiHandler = applicationContext.isTypeMatch(beanDefinitionName, XxlWebHandler.class);
if (isApiHandler) { // if (beanDefinition instanceof XxlWebHandler) {
Object beanDefinition = applicationContext.getBean(beanDefinitionName);
// valid annotation
XxlWebHandlerMapping annotation = beanDefinition.getClass().getAnnotation(XxlWebHandlerMapping.class);
if (annotation!=null && annotation.value()!=null && annotation.value().trim().length()>0 ) {
handlerRepository.put(annotation.value(), (XxlWebHandler) beanDefinition);
logger.warn(">>>>>>>>>>> xxl-hex, bind hex handler success : {}", annotation.value());
}
}
}
}
}
示例4: postProcessPropertyValues
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public PropertyValues postProcessPropertyValues(
PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName)
throws BeansException {
if (!this.validatedBeanNames.contains(beanName)) {
if (!shouldSkip(this.beanFactory, beanName)) {
List<String> invalidProperties = new ArrayList<String>();
for (PropertyDescriptor pd : pds) {
if (isRequiredProperty(pd) && !pvs.contains(pd.getName())) {
invalidProperties.add(pd.getName());
}
}
if (!invalidProperties.isEmpty()) {
throw new BeanInitializationException(buildExceptionMessage(invalidProperties, beanName));
}
}
this.validatedBeanNames.add(beanName);
}
return pvs;
}
示例5: beanFactoryPostProcessor
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Bean
public BeanFactoryPostProcessor beanFactoryPostProcessor(ApplicationContext applicationContext) {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (beanFactory instanceof BeanDefinitionRegistry) {
try {
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(registry);
scanner.setResourceLoader(applicationContext);
scanner.scan("com.quancheng.saluki.boot.web");
} catch (Throwable e) {
log.error(e.getMessage(), e);
}
}
}
};
}
示例6: postProcessBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
throws BeansException, OsgiException {
Bundle bundle = bundleContext.getBundle();
try {
// Try and load the annotation code using the bundle classloader
Class<?> annotationBppClass = bundle.loadClass(ANNOTATION_BPP_CLASS);
// instantiate the class
final BeanPostProcessor annotationBeanPostProcessor = (BeanPostProcessor) BeanUtils.instantiateClass(annotationBppClass);
// everything went okay so configure the BPP and add it to the BF
((BeanFactoryAware) annotationBeanPostProcessor).setBeanFactory(beanFactory);
((BeanClassLoaderAware) annotationBeanPostProcessor).setBeanClassLoader(beanFactory.getBeanClassLoader());
((BundleContextAware) annotationBeanPostProcessor).setBundleContext(bundleContext);
beanFactory.addBeanPostProcessor(annotationBeanPostProcessor);
}
catch (ClassNotFoundException exception) {
log.info("Spring-DM annotation package could not be loaded from bundle ["
+ OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]; annotation processing disabled...");
if (log.isDebugEnabled())
log.debug("Cannot load annotation injection processor", exception);
}
}
示例7: postProcessBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
Iterator<String> iterator = configurableListableBeanFactory.getBeanNamesIterator();
while (iterator.hasNext()) {
Object obj = configurableListableBeanFactory.getBean(iterator.next());
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
if (field.getType().isAnnotationPresent(ConfigBean.class)) {
field.setAccessible(true);
try {
Object value = config.configBeanParser(field.getType()).getConfigBean();
field.set(obj, value);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
}
示例8: setApplicationContext
import org.springframework.beans.BeansException; //导入依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
Map<String, HibernateSessionFactoryRepository> map = applicationContext
.getBeansOfType(HibernateSessionFactoryRepository.class);
if (map.size() > 0) {
this.sessionFactoryRepository = map.values().iterator().next();
} else if (applicationContext.getParent() != null) {
map = applicationContext.getParent().getBeansOfType(HibernateSessionFactoryRepository.class);
if (map.size() > 0) {
this.sessionFactoryRepository = map.values().iterator().next();
}
}
}
示例9: parseResultSet
import org.springframework.beans.BeansException; //导入依赖的package包/类
private X parseResultSet(Object rs) {
try {
IPojoFactory<X> pojoFactory = getPojoFactory();
if (pojoFactory.isPrimitive()) {
return pojoFactory.parsePrimitive(rs);
}
Object[] row;
if (rs instanceof Object[]) {
row = (Object[]) rs;
} else {
row = new Object[] { rs };
}
if (row.length < aliases.size()) {
throw new ParseSqlException(
"En número de alias de la select no coindicen con el numero de columnas devueltas por la query. Alias definidos: " + aliases);
}
X result = pojoFactory.newInstance();
IBeanWrapper bean = new BeanWrapper(result);
prepareBeanWrapper(bean);
int index = 0;
for (String propertyName : aliases.getBeanAliases()) {
Object value = row[index++];
bean.setPropertyValue(propertyName, value);
}
return result;
} catch (BeansException e) {
log.error("Error haciendo set " + targetClass, e);
}
return null;
}
示例10: postProcessBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
this.beanFactory = beanFactory;
for (String name : beanFactory.getBeanDefinitionNames()) {
BeanDefinition definition = beanFactory.getBeanDefinition(name);
String method = definition.getFactoryMethodName();
String bean = definition.getFactoryBeanName();
if (method != null && bean != null) {
this.beans.put(name, new MetaData(bean, method));
}
}
}
示例11: setApplicationContext
import org.springframework.beans.BeansException; //导入依赖的package包/类
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
this.applicationContext=applicationContext;
Collection<DataSourceRepository> dataSourceRepositoryCollection=applicationContext.getBeansOfType(DataSourceRepository.class).values();
if(dataSourceRepositoryCollection.size()>0){
this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();
}else if(applicationContext.getParent()!=null){
dataSourceRepositoryCollection=applicationContext.getParent().getBeansOfType(DataSourceRepository.class).values();
if(dataSourceRepositoryCollection.size()>0){
this.dataSourceRepository=dataSourceRepositoryCollection.iterator().next();
}
}
this.dialects=applicationContext.getBeansOfType(IDialect.class).values();
}
示例12: getObject
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public ChromeDriver getObject() throws BeansException {
if (properties.getChrome().isEnabled()) {
try {
return new ChromeDriver(chromeDriverService);
} catch (IllegalStateException e) {
e.printStackTrace();
// swallow the exception
}
}
return null;
}
开发者ID:PacktPublishing,项目名称:Learning-Spring-Boot-2.0-Second-Edition,代码行数:13,代码来源:ChromeDriverFactory.java
示例13: postProcessBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
final BeanDefinitionFinder beanDefinitionFinder = new BeanDefinitionFinder(beanFactory);
doubleRegistry
.mockSearch()
.forEach(mockDefinition -> postProcessBeanFactoryForMock(beanDefinitionFinder, mockDefinition));
doubleRegistry
.spySearch()
.forEach(spyDefinition -> postProcessBeanFactoryForSpy(beanDefinitionFinder, spyDefinition));
beanDefinitionFinder.execute();
}
示例14: setBeanFactory
import org.springframework.beans.BeansException; //导入依赖的package包/类
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
if (!(beanFactory instanceof ConfigurableListableBeanFactory)) {
throw new IllegalArgumentException(
"AutowiredAnnotationBeanPostProcessor requires a ConfigurableListableBeanFactory");
}
this.beanFactory = (ConfigurableListableBeanFactory) beanFactory;
}
示例15: createContext
import org.springframework.beans.BeansException; //导入依赖的package包/类
private void createContext() {
xmlContext = new OsgiBundleXmlApplicationContext(new String[] {}) {
public void refresh() throws BeansException {
// no-op
}
};
xmlContext.setBundleContext(context);
}