當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。