本文整理汇总了Java中org.springframework.beans.factory.BeanCreationException类的典型用法代码示例。如果您正苦于以下问题:Java BeanCreationException类的具体用法?Java BeanCreationException怎么用?Java BeanCreationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BeanCreationException类属于org.springframework.beans.factory包,在下文中一共展示了BeanCreationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: casSamlIdPMetadataResolver
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Bean
public MetadataResolver casSamlIdPMetadataResolver() {
try {
final SamlIdPProperties idp = casProperties.getAuthn().getSamlIdp();
final ResourceBackedMetadataResolver resolver = new ResourceBackedMetadataResolver(
ResourceHelper.of(new FileSystemResource(idp.getMetadata().getMetadataFile())));
resolver.setParserPool(this.openSamlConfigBean.getParserPool());
resolver.setFailFastInitialization(idp.getMetadata().isFailFast());
resolver.setRequireValidMetadata(idp.getMetadata().isRequireValidMetadata());
resolver.setId(idp.getEntityId());
resolver.initialize();
return resolver;
} catch (final Exception e) {
throw new BeanCreationException(e.getMessage(), e);
}
}
示例2: azureAuthenticatorInstance
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Bean
public PFAuth azureAuthenticatorInstance() {
try {
final MultifactorAuthenticationProperties.Azure azure = casProperties.getAuthn().getMfa().getAzure();
final File cfg = new File(azure.getConfigDir());
if (!cfg.exists() || !cfg.isDirectory()) {
throw new FileNotFoundException(cfg.getAbsolutePath() + " does not exist or is not a directory");
}
final PFAuth pf = new PFAuth();
pf.setDebug(true);
pf.setAllowInternationalCalls(azure.isAllowInternationalCalls());
final String dir = StringUtils.appendIfMissing(azure.getConfigDir(), "/");
pf.initialize(dir, azure.getPrivateKeyPassword());
return pf;
} catch (final Exception e) {
throw new BeanCreationException(e.getMessage(), e);
}
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:20,代码来源:AzureAuthenticatorAuthenticationEventExecutionPlanConfiguration.java
示例3: duoAuthenticationHandler
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@RefreshScope
@Bean
public AuthenticationHandler duoAuthenticationHandler() {
final DuoAuthenticationHandler h;
final List<MultifactorAuthenticationProperties.Duo> duos = casProperties.getAuthn().getMfa().getDuo();
if (!duos.isEmpty()) {
final String name = duos.get(0).getName();
if (duos.size() > 1) {
LOGGER.debug("Multiple Duo Security providers are available; Duo authentication handler is named after [{}]", name);
}
h = new DuoAuthenticationHandler(name, servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProvider());
} else {
h = new DuoAuthenticationHandler(StringUtils.EMPTY, servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProvider());
throw new BeanCreationException("No configuration/settings could be found for Duo Security. Review settings and ensure the correct syntax is used");
}
return h;
}
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:18,代码来源:DuoSecurityAuthenticationEventExecutionPlanConfiguration.java
示例4: userGraphicalAuthenticationRepository
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "userGraphicalAuthenticationRepository")
public UserGraphicalAuthenticationRepository userGraphicalAuthenticationRepository() {
final GraphicalUserAuthenticationProperties gua = casProperties.getAuthn().getGua();
if (StringUtils.isNotBlank(gua.getResource().getLocation())) {
return new StaticUserGraphicalAuthenticationRepository();
}
if (StringUtils.isNotBlank(gua.getLdap().getLdapUrl())
&& StringUtils.isNotBlank(gua.getLdap().getUserFilter())
&& StringUtils.isNotBlank(gua.getLdap().getBaseDn())
&& StringUtils.isNotBlank(gua.getLdap().getImageAttribute())) {
return new LdapUserGraphicalAuthenticationRepository();
}
throw new BeanCreationException("A repository instance must be configured to locate user-defined graphics");
}
示例5: surrogateAuthenticationService
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@RefreshScope
@ConditionalOnMissingBean(name = "surrogateAuthenticationService")
@Bean
public SurrogateAuthenticationService surrogateAuthenticationService() {
try {
final SurrogateAuthenticationProperties su = casProperties.getAuthn().getSurrogate();
if (su.getJson().getConfig().getLocation() != null) {
LOGGER.debug("Using JSON resource [{}] to locate surrogate accounts", su.getJson().getConfig().getLocation());
return new JsonResourceSurrogateAuthenticationService(su.getJson().getConfig().getLocation());
}
if (StringUtils.hasText(su.getLdap().getLdapUrl()) && StringUtils.hasText(su.getLdap().getSearchFilter())
&& StringUtils.hasText(su.getLdap().getBaseDn()) && StringUtils.hasText(su.getLdap().getMemberAttributeName())) {
LOGGER.debug("Using LDAP [{}] with baseDn [{}] to locate surrogate accounts",
su.getLdap().getLdapUrl(), su.getLdap().getBaseDn());
final ConnectionFactory factory = Beans.newLdaptivePooledConnectionFactory(su.getLdap());
return new LdapSurrogateUsernamePasswordService(factory, su.getLdap());
}
final Map<String, Set> accounts = new LinkedHashMap<>();
su.getSimple().getSurrogates().forEach((k, v) -> accounts.put(k, StringUtils.commaDelimitedListToSet(v)));
LOGGER.debug("Using accounts [{}] for surrogate authentication", accounts);
return new SimpleSurrogateAuthenticationService(accounts);
} catch (final Exception e) {
throw new BeanCreationException(e.getMessage(), e);
}
}
示例6: failedStepTransitionWithDuplicateTaskNameTest
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Test
public void failedStepTransitionWithDuplicateTaskNameTest() {
try {
setupContextForGraph("failedStep 'FAILED' -> BBB && CCC && BBB && EEE");
}
catch (BeanCreationException bce) {
assertEquals(TaskValidationException.class,
bce.getRootCause().getClass());
assertEquals("Problems found when validating 'failedStep " +
"'FAILED' -> BBB && CCC && BBB && EEE': " +
"[166E:(pos 38): duplicate app name. Use a " +
"label to ensure uniqueness]",
bce.getRootCause().getMessage());
}
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:17,代码来源:ComposedRunnerVisitorTests.java
示例7: successStepTransitionWithDuplicateTaskNameTest
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Test
public void successStepTransitionWithDuplicateTaskNameTest() {
try {
setupContextForGraph("AAA 'FAILED' -> BBB * -> CCC && BBB && EEE");
}
catch (BeanCreationException bce) {
assertEquals(TaskValidationException.class,
bce.getRootCause().getClass());
assertEquals("Problems found when validating 'AAA 'FAILED' -> " +
"BBB * -> CCC && BBB && EEE': [166E:(pos 33): " +
"duplicate app name. Use a label to ensure " +
"uniqueness]",
bce.getRootCause().getMessage());
}
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:17,代码来源:ComposedRunnerVisitorTests.java
示例8: applyMergedBeanDefinitionPostProcessors
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
/**
* Apply MergedBeanDefinitionPostProcessors to the specified bean definition,
* invoking their {@code postProcessMergedBeanDefinition} methods.
* @param mbd the merged bean definition for the bean
* @param beanType the actual type of the managed bean instance
* @param beanName the name of the bean
* @throws BeansException if any post-processing failed
* @see MergedBeanDefinitionPostProcessor#postProcessMergedBeanDefinition
*/
protected void applyMergedBeanDefinitionPostProcessors(RootBeanDefinition mbd, Class<?> beanType, String beanName)
throws BeansException {
try {
for (BeanPostProcessor bp : getBeanPostProcessors()) {
if (bp instanceof MergedBeanDefinitionPostProcessor) {
MergedBeanDefinitionPostProcessor bdp = (MergedBeanDefinitionPostProcessor) bp;
bdp.postProcessMergedBeanDefinition(mbd, beanType, beanName);
}
}
}
catch (Exception ex) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Post-processing failed of bean type [" + beanType + "] failed", ex);
}
}
示例9: getTypeForFactoryBean
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
/**
* Determine the bean type for the given FactoryBean definition, as far as possible.
* Only called if there is no singleton instance registered for the target bean already.
* <p>The default implementation creates the FactoryBean via {@code getBean}
* to call its {@code getObjectType} method. Subclasses are encouraged to optimize
* this, typically by just instantiating the FactoryBean but not populating it yet,
* trying whether its {@code getObjectType} method already returns a type.
* If no type found, a full FactoryBean creation as performed by this implementation
* should be used as fallback.
* @param beanName the name of the bean
* @param mbd the merged bean definition for the bean
* @return the type for the bean if determinable, or {@code null} else
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
* @see #getBean(String)
*/
protected Class<?> getTypeForFactoryBean(String beanName, RootBeanDefinition mbd) {
if (!mbd.isSingleton()) {
return null;
}
try {
FactoryBean<?> factoryBean = doGetBean(FACTORY_BEAN_PREFIX + beanName, FactoryBean.class, null, true);
return getTypeForFactoryBean(factoryBean);
}
catch (BeanCreationException ex) {
// Can only happen when getting a FactoryBean.
if (logger.isDebugEnabled()) {
logger.debug("Ignoring bean creation exception on FactoryBean type check: " + ex);
}
onSuppressedException(ex);
return null;
}
}
示例10: main
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
try {
SpringApplication.exit(new SpringApplicationBuilder(VacuumTool.class)
.properties("spring.config.location:${config:null}")
.properties("spring.profiles.active:" + Modules.REPLICATION)
.properties("instance.home:${user.home}")
.properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
.bannerMode(Mode.OFF)
.registerShutdownHook(true)
.build()
.run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printVacuumToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
}
throw e;
}
}
示例11: main
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// below is output *before* logging is configured so will appear on console
logVersionInfo();
try {
SpringApplication.exit(new SpringApplicationBuilder(FilterTool.class)
.properties("spring.config.location:${config:null}")
.properties("spring.profiles.active:" + Modules.REPLICATION)
.properties("instance.home:${user.home}")
.properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
.bannerMode(Mode.OFF)
.registerShutdownHook(true)
.build()
.run(args));
} catch (BeanCreationException e) {
if (e.getMostSpecificCause() instanceof BindException) {
printFilterToolHelp(((BindException) e.getMostSpecificCause()).getAllErrors());
}
throw e;
}
}
示例12: resolveReference
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
/**
* Resolve a reference to another bean in the factory.
*/
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
try {
String refName = ref.getBeanName();
refName = String.valueOf(evaluate(refName));
if (ref.isToParent()) {
if (this.beanFactory.getParentBeanFactory() == null) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Can't resolve reference to bean '" + refName +
"' in parent factory: no parent factory available");
}
return this.beanFactory.getParentBeanFactory().getBean(refName);
}
else {
Object bean = this.beanFactory.getBean(refName);
this.beanFactory.registerDependentBean(refName, this.beanName);
return bean;
}
}
catch (BeansException ex) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
}
}
示例13: createAndFailWithCause
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
private void createAndFailWithCause(String cause) {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(MediaServicesAutoConfiguration.class);
Exception exception = null;
try {
context.refresh();
} catch (Exception e) {
exception = e;
}
assertThat(exception).isNotNull();
assertThat(exception).isExactlyInstanceOf(BeanCreationException.class);
assertThat(exception.getCause().getCause().toString()).contains(cause);
}
}
示例14: emptySettingNotAllowed
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Test
public void emptySettingNotAllowed() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(Config.class);
Exception exception = null;
try {
context.refresh();
} catch (Exception e) {
exception = e;
}
assertThat(exception).isNotNull();
assertThat(exception).isExactlyInstanceOf(BeanCreationException.class);
assertThat(exception.getCause().getMessage()).contains(
"Field error in object 'azure.documentdb' on field 'uri': rejected value [null];");
assertThat(exception.getCause().getMessage()).contains(
"Field error in object 'azure.documentdb' on field 'key': rejected value [null];");
}
}
示例15: connectionStringIsNull
import org.springframework.beans.factory.BeanCreationException; //导入依赖的package包/类
@Test
public void connectionStringIsNull() {
try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext()) {
context.register(Config.class);
Exception exception = null;
try {
context.refresh();
} catch (Exception e) {
exception = e;
}
assertThat(exception).isNotNull();
assertThat(exception).isExactlyInstanceOf(BeanCreationException.class);
assertThat(exception.getCause().getMessage()).contains(
"Field error in object 'azure.servicebus' on field 'connectionString': "
+ "rejected value [null];");
}
}