當前位置: 首頁>>代碼示例>>Java>>正文


Java BeansException類代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:25,代碼來源:JpaEntityManagerFactory.java

示例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);
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:ContextJndiBeanFactoryLocator.java

示例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());
                }
            }

        }
    }

}
 
開發者ID:xuxueli,項目名稱:xxl-web,代碼行數:25,代碼來源:XxlWebHandlerFactory.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:22,代碼來源:RequiredAnnotationBeanPostProcessor.java

示例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);
                }
            }

        }

    };
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:22,代碼來源:MonitorAutoconfiguration.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:24,代碼來源:OsgiAnnotationPostProcessor.java

示例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();
                }
            }

        }
    }

}
 
開發者ID:ChenXun1989,項目名稱:ace,代碼行數:25,代碼來源:ConfigBeanFactoryPostProcessor.java

示例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();
		}
	}
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:14,代碼來源:HibernateDao.java

示例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;
   }
 
開發者ID:iaunzu,項目名稱:strqlbuilder,代碼行數:37,代碼來源:TypedQueryImpl.java

示例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));
        }
    }
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:13,代碼來源:ConfigurationBeanFactoryMetaData.java

示例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();
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:15,代碼來源:JdbcDao.java

示例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();
}
 
開發者ID:pchudzik,項目名稱:springmock,代碼行數:15,代碼來源:DoubleRegisteringProcessor.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:9,代碼來源:AutowiredAnnotationBeanPostProcessor.java

示例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);
  }
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:9,代碼來源:AbstractBundleXmlApplicationContextTest.java


注:本文中的org.springframework.beans.BeansException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。