本文整理汇总了Java中org.springframework.beans.BeanInstantiationException类的典型用法代码示例。如果您正苦于以下问题:Java BeanInstantiationException类的具体用法?Java BeanInstantiationException怎么用?Java BeanInstantiationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeanInstantiationException类属于org.springframework.beans包,在下文中一共展示了BeanInstantiationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
if (this.serviceTicketsCache == null || this.ticketGrantingTicketsCache == null) {
throw new BeanInstantiationException(this.getClass(),
"Both serviceTicketsCache and ticketGrantingTicketsCache are required properties.");
}
if (logger.isDebugEnabled()) {
CacheConfiguration config = this.serviceTicketsCache.getCacheConfiguration();
logger.debug("serviceTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("serviceTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("serviceTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("serviceTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("serviceTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("serviceTicketsCache.cacheManager={}", this.serviceTicketsCache.getCacheManager().getName());
config = this.ticketGrantingTicketsCache.getCacheConfiguration();
logger.debug("ticketGrantingTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("ticketGrantingTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("ticketGrantingTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("ticketGrantingTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("ticketGrantingTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("ticketGrantingTicketsCache.cacheManager={}", this.ticketGrantingTicketsCache.getCacheManager()
.getName());
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:27,代码来源:EhCacheTicketRegistry.java
示例2: instantiateListeners
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
private List<TestExecutionListener> instantiateListeners(List<Class<? extends TestExecutionListener>> classesList) {
List<TestExecutionListener> listeners = new ArrayList<TestExecutionListener>(classesList.size());
for (Class<? extends TestExecutionListener> listenerClass : classesList) {
NoClassDefFoundError ncdfe = null;
try {
listeners.add(BeanUtils.instantiateClass(listenerClass));
}
catch (NoClassDefFoundError err) {
ncdfe = err;
}
catch (BeanInstantiationException ex) {
if (ex.getCause() instanceof NoClassDefFoundError) {
ncdfe = (NoClassDefFoundError) ex.getCause();
}
}
if (ncdfe != null) {
if (logger.isInfoEnabled()) {
logger.info(String.format("Could not instantiate TestExecutionListener [%s]. "
+ "Specify custom listener classes or make the default listener classes "
+ "(and their required dependencies) available. Offending class: [%s]",
listenerClass.getName(), ncdfe.getMessage()));
}
}
}
return listeners;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:AbstractTestContextBootstrapper.java
示例3: instantiate
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
/**
* Create a new instance of a dynamically generated subclass implementing the
* required lookups.
* @param ctor constructor to use. If this is {@code null}, use the
* no-arg constructor (no parameterization, or Setter Injection)
* @param args arguments to use for the constructor.
* Ignored if the {@code ctor} parameter is {@code null}.
* @return new instance of the dynamically generated subclass
*/
public Object instantiate(Constructor<?> ctor, Object... args) {
Class<?> subclass = createEnhancedSubclass(this.beanDefinition);
Object instance;
if (ctor == null) {
instance = BeanUtils.instantiate(subclass);
}
else {
try {
Constructor<?> enhancedSubclassConstructor = subclass.getConstructor(ctor.getParameterTypes());
instance = enhancedSubclassConstructor.newInstance(args);
}
catch (Exception ex) {
throw new BeanInstantiationException(this.beanDefinition.getBeanClass(),
"Failed to invoke constructor for CGLIB enhanced subclass [" + subclass.getName() + "]", ex);
}
}
// SPR-10785: set callbacks directly on the instance instead of in the
// enhanced class (via the Enhancer) in order to avoid memory leaks.
Factory factory = (Factory) instance;
factory.setCallbacks(new Callback[] {NoOp.INSTANCE,
new LookupOverrideMethodInterceptor(this.beanDefinition, this.owner),
new ReplaceOverrideMethodInterceptor(this.beanDefinition, this.owner)});
return instance;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:34,代码来源:CglibSubclassingInstantiationStrategy.java
示例4: postProcessAfterInitialization
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
Class targetClass = bean.getClass();
while(targetClass.getName().contains(CGLIB_SIGNATURE)) {
for(Class interf: targetClass.getInterfaces()) {
if(interf == TransactionalIntercepted.class)
return bean;
}
targetClass = targetClass.getSuperclass();
}
Method[] methods = targetClass.getDeclaredMethods();
for (Method method : methods) {
Transactional txAnnotation = method.getAnnotation(Transactional.class);
if (txAnnotation != null) {
throw new BeanInstantiationException(targetClass, "Bean annotated by @Transactional must be created through DalTransactionManager.create()");
}
}
return bean;
}
开发者ID:ctripcorp,项目名称:dal,代码行数:25,代码来源:DalAnnotationValidator.java
示例5: cloneLBHttpSolrClient
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
private static LBHttpSolrClient cloneLBHttpSolrClient(SolrClient solrClient, String core) {
if (solrClient == null) {
return null;
}
LBHttpSolrClient clone = null;
try {
if (VersionUtil.isSolr3XAvailable()) {
clone = cloneSolr3LBHttpServer(solrClient, core);
} else if (VersionUtil.isSolr4XAvailable()) {
clone = cloneSolr4LBHttpServer(solrClient, core);
}
} catch (Exception e) {
throw new BeanInstantiationException(solrClient.getClass(), "Cannot create instace of " + solrClient.getClass()
+ ". ", e);
}
Object o = readField(solrClient, "interval");
if (o != null) {
clone.setAliveCheckInterval(Integer.valueOf(o.toString()).intValue());
}
return clone;
}
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:23,代码来源:SolrClientUtils.java
示例6: postProcessBeanFactory
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
SimpleStorageResourceLoader simpleStorageResourceLoader = new SimpleStorageResourceLoader(this.amazonS3, this.resourceLoader);
if (this.executor != null) {
simpleStorageResourceLoader.setTaskExecutor(this.executor);
}
try {
simpleStorageResourceLoader.afterPropertiesSet();
} catch (Exception e) {
throw new BeanInstantiationException(SimpleStorageResourceLoader.class, "Error instantiating class", e);
}
this.resourceLoader = new PathMatchingSimpleStorageResourcePatternResolver(this.amazonS3,
simpleStorageResourceLoader, (ResourcePatternResolver) this.resourceLoader);
beanFactory.registerResolvableDependency(ResourceLoader.class, this.resourceLoader);
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:ResourceLoaderBeanPostProcessor.java
示例7: cloneLBHttpSolrServer
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
private static LBHttpSolrServer cloneLBHttpSolrServer(SolrServer solrServer, String core) {
if (solrServer == null) {
return null;
}
LBHttpSolrServer clone = null;
try {
if (VersionUtil.isSolr3XAvailable()) {
clone = cloneSolr3LBHttpServer(solrServer, core);
} else if (VersionUtil.isSolr4XAvailable()) {
clone = cloneSolr4LBHttpServer(solrServer, core);
}
} catch (MalformedURLException e) {
throw new BeanInstantiationException(solrServer.getClass(), "Cannot create instace of " + solrServer.getClass()
+ ". ", e);
}
Object o = readField(solrServer, "interval");
if (o != null) {
clone.setAliveCheckInterval(Integer.valueOf(o.toString()).intValue());
}
return clone;
}
开发者ID:ramaava,项目名称:spring-data-solr,代码行数:23,代码来源:SolrServerUtils.java
示例8: afterPropertiesSet
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() {
logger.info("Setting up Ehcache Ticket Registry...");
if (this.serviceTicketsCache == null || this.ticketGrantingTicketsCache == null) {
throw new BeanInstantiationException(this.getClass(),
"Both serviceTicketsCache and ticketGrantingTicketsCache are required properties.");
}
if (logger.isDebugEnabled()) {
CacheConfiguration config = this.serviceTicketsCache.getCacheConfiguration();
logger.debug("serviceTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("serviceTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("serviceTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("serviceTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("serviceTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("serviceTicketsCache.cacheManager={}", this.serviceTicketsCache.getCacheManager().getName());
config = this.ticketGrantingTicketsCache.getCacheConfiguration();
logger.debug("ticketGrantingTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("ticketGrantingTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("ticketGrantingTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("ticketGrantingTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("ticketGrantingTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("ticketGrantingTicketsCache.cacheManager={}", this.ticketGrantingTicketsCache.getCacheManager()
.getName());
}
}
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:29,代码来源:EhCacheTicketRegistry.java
示例9: afterPropertiesSet
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
logger.info("Setting up Ehcache Ticket Registry...");
if (this.serviceTicketsCache == null || this.ticketGrantingTicketsCache == null) {
throw new BeanInstantiationException(this.getClass(),
"Both serviceTicketsCache and ticketGrantingTicketsCache are required properties.");
}
if (logger.isDebugEnabled()) {
CacheConfiguration config = this.serviceTicketsCache.getCacheConfiguration();
logger.debug("serviceTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("serviceTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("serviceTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("serviceTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("serviceTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("serviceTicketsCache.cacheManager={}", this.serviceTicketsCache.getCacheManager().getName());
config = this.ticketGrantingTicketsCache.getCacheConfiguration();
logger.debug("ticketGrantingTicketsCache.maxElementsInMemory={}", config.getMaxEntriesLocalHeap());
logger.debug("ticketGrantingTicketsCache.maxElementsOnDisk={}", config.getMaxElementsOnDisk());
logger.debug("ticketGrantingTicketsCache.isOverflowToDisk={}", config.isOverflowToDisk());
logger.debug("ticketGrantingTicketsCache.timeToLive={}", config.getTimeToLiveSeconds());
logger.debug("ticketGrantingTicketsCache.timeToIdle={}", config.getTimeToIdleSeconds());
logger.debug("ticketGrantingTicketsCache.cacheManager={}", this.ticketGrantingTicketsCache.getCacheManager()
.getName());
}
}
开发者ID:yuweijun,项目名称:cas-server-4.2.1,代码行数:29,代码来源:EhCacheTicketRegistry.java
示例10: instantiate
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public Object instantiate(RootBeanDefinition beanDefinition, String beanName, BeanFactory owner) {
// Don't override the class with CGLIB if no overrides.
if (beanDefinition.getMethodOverrides().isEmpty()) {
Constructor<?> constructorToUse;
synchronized (beanDefinition.constructorArgumentLock) {
constructorToUse = (Constructor<?>) beanDefinition.resolvedConstructorOrFactoryMethod;
if (constructorToUse == null) {
final Class<?> clazz = beanDefinition.getBeanClass();
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, "Specified class is an interface");
}
try {
if (System.getSecurityManager() != null) {
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
@Override
public Constructor<?> run() throws Exception {
return clazz.getDeclaredConstructor((Class[]) null);
}
});
}
else {
constructorToUse = clazz.getDeclaredConstructor((Class[]) null);
}
beanDefinition.resolvedConstructorOrFactoryMethod = constructorToUse;
}
catch (Exception ex) {
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
}
}
}
return BeanUtils.instantiateClass(constructorToUse);
}
else {
// Must generate CGLIB subclass.
return instantiateWithMethodInjection(beanDefinition, beanName, owner);
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:SimpleInstantiationStrategy.java
示例11: instantiate
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
/**
* Create a new instance of a dynamically generated subclass implementing the
* required lookups.
* @param ctor constructor to use. If this is {@code null}, use the
* no-arg constructor (no parameterization, or Setter Injection)
* @param args arguments to use for the constructor.
* Ignored if the {@code ctor} parameter is {@code null}.
* @return new instance of the dynamically generated subclass
*/
Object instantiate(Constructor<?> ctor, Object[] args) {
Class<?> subclass = createEnhancedSubclass(this.beanDefinition);
Object instance;
if (ctor == null) {
instance = BeanUtils.instantiate(subclass);
}
else {
try {
Constructor<?> enhancedSubclassConstructor = subclass.getConstructor(ctor.getParameterTypes());
instance = enhancedSubclassConstructor.newInstance(args);
}
catch (Exception e) {
throw new BeanInstantiationException(this.beanDefinition.getBeanClass(), String.format(
"Failed to invoke construcor for CGLIB enhanced subclass [%s]", subclass.getName()), e);
}
}
// SPR-10785: set callbacks directly on the instance instead of in the
// enhanced class (via the Enhancer) in order to avoid memory leaks.
Factory factory = (Factory) instance;
factory.setCallbacks(new Callback[] { NoOp.INSTANCE,//
new LookupOverrideMethodInterceptor(beanDefinition, owner),//
new ReplaceOverrideMethodInterceptor(beanDefinition, owner) });
return instance;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:CglibSubclassingInstantiationStrategy.java
示例12: testProxyingDecoratorNoInstance
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Test
public void testProxyingDecoratorNoInstance() throws Exception {
String[] beanNames = this.beanFactory.getBeanNamesForType(ApplicationListener.class);
assertTrue(Arrays.asList(beanNames).contains("debuggingTestBeanNoInstance"));
assertEquals(ApplicationListener.class, this.beanFactory.getType("debuggingTestBeanNoInstance"));
try {
this.beanFactory.getBean("debuggingTestBeanNoInstance");
fail("Should have thrown BeanCreationException");
}
catch (BeanCreationException ex) {
assertTrue(ex.getRootCause() instanceof BeanInstantiationException);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:CustomNamespaceHandlerTests.java
示例13: getHandlerNoBeanFactory
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Test(expected=BeanInstantiationException.class)
public void getHandlerNoBeanFactory() {
BeanCreatingHandlerProvider<EchoHandler> provider =
new BeanCreatingHandlerProvider<EchoHandler>(EchoHandler.class);
provider.getHandler();
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:BeanCreatingHandlerProviderTests.java
示例14: instantiate
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public Object instantiate(RootBeanDefinition bd, String beanName, BeanFactory owner) {
// Don't override the class with CGLIB if no overrides.
if (bd.getMethodOverrides().isEmpty()) {
Constructor<?> constructorToUse;
synchronized (bd.constructorArgumentLock) {
constructorToUse = (Constructor<?>) bd.resolvedConstructorOrFactoryMethod;
if (constructorToUse == null) {
final Class<?> clazz = bd.getBeanClass();
if (clazz.isInterface()) {
throw new BeanInstantiationException(clazz, "Specified class is an interface");
}
try {
if (System.getSecurityManager() != null) {
constructorToUse = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() {
@Override
public Constructor<?> run() throws Exception {
return clazz.getDeclaredConstructor((Class[]) null);
}
});
}
else {
constructorToUse = clazz.getDeclaredConstructor((Class[]) null);
}
bd.resolvedConstructorOrFactoryMethod = constructorToUse;
}
catch (Exception ex) {
throw new BeanInstantiationException(clazz, "No default constructor found", ex);
}
}
}
return BeanUtils.instantiateClass(constructorToUse);
}
else {
// Must generate CGLIB subclass.
return instantiateWithMethodInjection(bd, beanName, owner);
}
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:39,代码来源:SimpleInstantiationStrategy.java
示例15: postProcessBeforeInitialization
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
// System.err.println("postProcessBeforeInitialization:" + beanName);
Class<?> clazz = bean.getClass();
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
Value annotation = field.getAnnotation(Value.class);
if (annotation == null) {
continue;
}
field.setAccessible(true);
Object value = resolveValue(annotation, field);
if (value == null) {
continue;
}
try {
field.set(bean, value);
FieldInfo fieldInfo = new FieldInfo();
fieldInfo.setBean(bean);
fieldInfo.setField(field);
fieldList.add(fieldInfo);
}
catch (IllegalAccessException e) {
throw new BeanInstantiationException(clazz, e.getMessage(), e);
}
}
return bean;
}
开发者ID:tanhaichao,项目名称:leopard,代码行数:31,代码来源:SysconfigBeanPostProcessor.java
示例16: getConsumerDescription
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
private String getConsumerDescription(Throwable ex) {
UnsatisfiedDependencyException unsatisfiedDependency = findUnsatisfiedDependencyException(
ex);
if (unsatisfiedDependency != null) {
return getConsumerDescription(unsatisfiedDependency);
}
BeanInstantiationException beanInstantiationException = findBeanInstantiationException(
ex);
if (beanInstantiationException != null) {
return getConsumerDescription(beanInstantiationException);
}
return null;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:NoUniqueBeanDefinitionFailureAnalyzer.java
示例17: whenDynamicModeAndMultipleServerListThenMemcachedNotLoaded
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Test
public void whenDynamicModeAndMultipleServerListThenMemcachedNotLoaded() {
thrown.expect(BeanCreationException.class);
thrown.expectMessage("Only one configuration endpoint is valid with dynamic client mode.");
thrown.expectCause(isA(BeanInstantiationException.class));
loadContext(CacheConfiguration.class, "memcached.cache.servers=192.168.99.100:11212, 192.168.99.101:11211",
"memcached.cache.mode=dynamic");
}
开发者ID:sixhours-team,项目名称:memcached-spring-boot,代码行数:10,代码来源:MemcachedAutoConfigurationTest.java
示例18: testValidateRawBean
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@Test
public void testValidateRawBean() throws Exception {
DalAnnotationValidator test = new DalAnnotationValidator();
try{
TransactionAnnoClass bean = new TransactionAnnoClass();
test.postProcessAfterInitialization(bean, "beanName");
fail();
}catch(BeanInstantiationException e) {
assertTrue(e.getMessage().contains("Bean annotated by @Transactional must be created through DalTransactionManager.create()"));
}
}
开发者ID:ctripcorp,项目名称:dal,代码行数:12,代码来源:DalAnnotationValidatorTest.java
示例19: instantiateClass
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
private static Object instantiateClass(Class<?> clazz) throws BeanInstantiationException {
try {
return clazz.newInstance();
} catch (Exception ex) {
throw new BeanInstantiationException(clazz, ex.getMessage(), ex);
}
}
开发者ID:xuegongzi,项目名称:rabbitframework,代码行数:8,代码来源:BeanPropertyRowMapper.java
示例20: cloneEmbeddedSolrServer
import org.springframework.beans.BeanInstantiationException; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private static SolrClient cloneEmbeddedSolrServer(SolrClient solrClient, String core) {
CoreContainer coreContainer = ((EmbeddedSolrServer) solrClient).getCoreContainer();
try {
Constructor constructor = ClassUtils.getConstructorIfAvailable(solrClient.getClass(), CoreContainer.class,
String.class);
return (SolrClient) BeanUtils.instantiateClass(constructor, coreContainer, core);
} catch (Exception e) {
throw new BeanInstantiationException(solrClient.getClass(), "Cannot create instace of " + solrClient.getClass()
+ ".", e);
}
}
开发者ID:yiduwangkai,项目名称:dubbox-solr,代码行数:14,代码来源:SolrClientUtils.java
注:本文中的org.springframework.beans.BeanInstantiationException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论