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


Java BeanInitializationException类代码示例

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


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

示例1: getDataSource

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
private DataSource getDataSource(ApplicationContext applicationContext, Persistence persistenceSettings) {
	DataSource dataSource = null;
	Map<String, DataSource> datasources = applicationContext.getBeansOfType(DataSource.class);
	int dsSize = null != datasources ? datasources.size() : 0;
	if (null != datasources && null != persistenceSettings.getDataSourceName()) {
		dataSource = datasources.get(persistenceSettings.getDataSourceName());
	} else if (null != datasources && dsSize == 1 && null == persistenceSettings.getDataSourceName()){
		dataSource = datasources.values().iterator().next();
	}
	
    if (dataSource == null) {
    	throw new BeanInitializationException(
    			"A datasource is required when starting Quartz-Scheduler in persisted mode. " +
    			"No DS found in map with size: " + dsSize + ", and configured DSName: " + persistenceSettings.getDataSourceName());
    }
    return dataSource;
}
 
开发者ID:andrehertwig,项目名称:spring-boot-starter-quartz,代码行数:18,代码来源:QuartzSchedulerAutoConfiguration.java

示例2: createInstance

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Override
protected AbstractShiroFilter createInstance() throws Exception {
	SecurityManager securityManager = getSecurityManager();
	if (securityManager == null){
		throw new BeanInitializationException("SecurityManager property must be set.");
	}

	if (!(securityManager instanceof WebSecurityManager)){
		throw new BeanInitializationException("The security manager does not implement the WebSecurityManager interface.");
	}

	PathMatchingFilterChainResolver chainResolver = new PathMatchingFilterChainResolver();
	FilterChainManager chainManager = createFilterChainManager();
	chainResolver.setFilterChainManager(chainManager);
	return new MySpringShiroFilter((WebSecurityManager)securityManager, chainResolver);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:17,代码来源:MyShiroFilterFactoryBean.java

示例3: awsRegion

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Bean
public Region awsRegion() {
    Region region;
    if(regionString != null && !regionString.isEmpty()) {
        region = RegionUtils.getRegion(regionString);
    } else {
        AwsRegionProvider regionProvider = new DefaultAwsRegionProviderChain();
        region = RegionUtils.getRegion(regionProvider.getRegion());
    }
    
    if(region == null) {
        throw new BeanInitializationException("Unable to determine AWS region");
    }
    
    return region;
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:17,代码来源:AwsConfig.java

示例4: createProperties

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
private void createProperties() {
	if (properties == null) {
		properties = (dynamic ? new ChangeableProperties() : new Properties());
		// init properties by copying config admin properties
		try {
			PropertiesUtil.initProperties(localProperties, localOverride, CMUtils.getConfiguration(bundleContext,
					persistentId, initTimeout), properties);
		} catch (IOException ioe) {
			throw new BeanInitializationException("Cannot retrieve configuration for pid=" + persistentId, ioe);
		}

		if (dynamic) {
			// perform eager registration
			registration = CMUtils.registerManagedService(bundleContext, new ConfigurationWatcher(), persistentId);
		}
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:18,代码来源:ConfigAdminPropertiesFactoryBean.java

示例5: postProcessPropertyValues

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的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

示例6: postProcessBeanFactory

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
/**
 * {@linkplain #mergeProperties Merge}, {@linkplain #convertProperties convert} and
 * {@linkplain #processProperties process} properties against the given bean factory.
 * @throws BeanInitializationException if any properties cannot be loaded
 */
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
	try {
		Properties mergedProps = mergeProperties();

		// Convert the merged properties, if necessary.
		convertProperties(mergedProps);

		// Let the subclass process the properties.
		processProperties(beanFactory, mergedProps);
	}
	catch (IOException ex) {
		throw new BeanInitializationException("Could not load properties", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PropertyResourceConfigurer.java

示例7: processProperties

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Override
protected void processProperties(ConfigurableListableBeanFactory beanFactory, Properties props)
		throws BeansException {

	for (Enumeration<?> names = props.propertyNames(); names.hasMoreElements();) {
		String key = (String) names.nextElement();
		try {
			processKey(beanFactory, key, props.getProperty(key));
		}
		catch (BeansException ex) {
			String msg = "Could not process key '" + key + "' in PropertyOverrideConfigurer";
			if (!this.ignoreInvalidKeys) {
				throw new BeanInitializationException(msg, ex);
			}
			if (logger.isDebugEnabled()) {
				logger.debug(msg, ex);
			}
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:PropertyOverrideConfigurer.java

示例8: processKey

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
/**
 * Process the given key as 'beanName.property' entry.
 */
protected void processKey(ConfigurableListableBeanFactory factory, String key, String value)
		throws BeansException {

	int separatorIndex = key.indexOf(this.beanNameSeparator);
	if (separatorIndex == -1) {
		throw new BeanInitializationException("Invalid key '" + key +
				"': expected 'beanName" + this.beanNameSeparator + "property'");
	}
	String beanName = key.substring(0, separatorIndex);
	String beanProperty = key.substring(separatorIndex+1);
	this.beanNames.add(beanName);
	applyPropertyValue(factory, beanName, beanProperty, value);
	if (logger.isDebugEnabled()) {
		logger.debug("Property '" + key + "' set to value [" + value + "]");
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:20,代码来源:PropertyOverrideConfigurer.java

示例9: postProcessBeanFactory

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    String[] beanNames = beanFactory.getBeanNamesForAnnotation(Job.class);

    for(String name : beanNames){
        JobDetail jobDetail = buildJobForBeanFactory(beanFactory, name);

        if (jobDetail == null){
            logger.warn("could not load JobDetail for {}", name);
            continue;
        }

        try {
            scheduler.addJob(jobDetail, true);
        } catch (SchedulerException e) {
            throw new BeanInitializationException("SchedulerException when adding job to scheduler", e);
        }
    }
}
 
开发者ID:taboola,项目名称:taboola-cronyx,代码行数:21,代码来源:QuartzJobRegistrarBeanFactoryPostProcessor.java

示例10: samzaContainer

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean
public SamzaContainer samzaContainer() {

    JobModel jobModel = samzaJobModel();

    int containerId = samzaContainerId();
    Assert.isTrue(containerId >= 0, "samzaContainerId must be a non-negative integer (0 or greater).");

    Map<Integer, ContainerModel> containers = jobModel.getContainers();
    ContainerModel containerModel = containers.get(containerId);
    if (containerModel == null) {
        String msg = "Container model does not exist for samza container id '" + containerId + "'.  " +
            "Ensure that samzaContainerId is a zero-based integer less than the total number " +
            "of containers for the job.  Number of containers in the model: " + containers.size();
        throw new BeanInitializationException(msg);
    }

    return SamzaContainer$.MODULE$.apply(containerModel, jobModel);
}
 
开发者ID:stormpath,项目名称:samza-spring-boot-starter,代码行数:21,代码来源:SamzaAutoConfiguration.java

示例11: postProcessAfterInitialization

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
	if (bean instanceof Portlet) {
		PortletConfig config = this.portletConfig;
		if (config == null || !this.useSharedPortletConfig) {
			config = new DelegatingPortletConfig(beanName, this.portletContext, this.portletConfig);
		}
		try {
			((Portlet) bean).init(config);
		}
		catch (PortletException ex) {
			throw new BeanInitializationException("Portlet.init threw exception", ex);
		}
	}
	return bean;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:SimplePortletPostProcessor.java

示例12: initServletContext

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
/**
 * Invoked on startup. Looks for a single FreeMarkerConfig bean to
 * find the relevant Configuration for this factory.
 * <p>Checks that the template for the default Locale can be found:
 * FreeMarker will check non-Locale-specific templates if a
 * locale-specific one is not found.
 * @see freemarker.cache.TemplateCache#getTemplate
 */
@Override
protected void initServletContext(ServletContext servletContext) throws BeansException {
	if (getConfiguration() != null) {
		this.taglibFactory = new TaglibFactory(servletContext);
	}
	else {
		FreeMarkerConfig config = autodetectConfiguration();
		setConfiguration(config.getConfiguration());
		this.taglibFactory = config.getTaglibFactory();
	}

	GenericServlet servlet = new GenericServletAdapter();
	try {
		servlet.init(new DelegatingServletConfig());
	}
	catch (ServletException ex) {
		throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex);
	}
	this.servletContextHashModel = new ServletContextHashModel(servlet, getObjectWrapper());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:FreeMarkerView.java

示例13: postProcessAfterInitialization

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
	if (bean instanceof Servlet) {
		ServletConfig config = this.servletConfig;
		if (config == null || !this.useSharedServletConfig) {
			config = new DelegatingServletConfig(beanName, this.servletContext);
		}
		try {
			((Servlet) bean).init(config);
		}
		catch (ServletException ex) {
			throw new BeanInitializationException("Servlet.init threw exception", ex);
		}
	}
	return bean;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:SimpleServletPostProcessor.java

示例14: mvcContentNegotiationManager

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
/**
 * Return a {@link ContentNegotiationManager} instance to use to determine
 * requested {@linkplain MediaType media types} in a given request.
 */
@Bean
public ContentNegotiationManager mvcContentNegotiationManager() {
	if (this.contentNegotiationManager == null) {
		ContentNegotiationConfigurer configurer = new ContentNegotiationConfigurer(this.servletContext);
		configurer.mediaTypes(getDefaultMediaTypes());
		configureContentNegotiation(configurer);
		try {
			this.contentNegotiationManager = configurer.getContentNegotiationManager();
		}
		catch (Exception ex) {
			throw new BeanInitializationException("Could not create ContentNegotiationManager", ex);
		}
	}
	return this.contentNegotiationManager;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:WebMvcConfigurationSupport.java

示例15: createListenerContainer

import org.springframework.beans.factory.BeanInitializationException; //导入依赖的package包/类
/**
 * Create and start a new container using the specified factory.
 */
protected MessageListenerContainer createListenerContainer(JmsListenerEndpoint endpoint,
		JmsListenerContainerFactory<?> factory) {

	MessageListenerContainer listenerContainer = factory.createListenerContainer(endpoint);

	if (listenerContainer instanceof InitializingBean) {
		try {
			((InitializingBean) listenerContainer).afterPropertiesSet();
		}
		catch (Exception ex) {
			throw new BeanInitializationException("Failed to initialize message listener container", ex);
		}
	}

	int containerPhase = listenerContainer.getPhase();
	if (containerPhase < Integer.MAX_VALUE) {  // a custom phase value
		if (this.phase < Integer.MAX_VALUE && this.phase != containerPhase) {
			throw new IllegalStateException("Encountered phase mismatch between container factory definitions: " +
					this.phase + " vs " + containerPhase);
		}
		this.phase = listenerContainer.getPhase();
	}

	return listenerContainer;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:JmsListenerEndpointRegistry.java


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