Java Code Examples for org.springframework.beans.factory.BeanCreationNotAllowedException

The following examples show how to use org.springframework.beans.factory.BeanCreationNotAllowedException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: iotplatform   Source File: PluginWebSocketHandler.java    License: Apache License 2.0 5 votes vote down vote up
private void processInActorService(SessionEventPluginWebSocketMsg msg) {
    try {
        actorService.process(msg);
    } catch (BeanCreationNotAllowedException e) {
        log.warn("[{}] Failed to close session due to possible shutdown state", msg.getSessionRef().getSessionId());
    }
}
 
Example 2
Source Project: blog_demos   Source File: DefaultSingletonBeanRegistry.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Return the (raw) singleton object registered under the given name,
 * creating and registering a new one if none registered yet.
 * @param beanName the name of the bean
 * @param singletonFactory the ObjectFactory to lazily create the singleton
 * with, if necessary
 * @return the registered singleton object
 */
public Object getSingleton(String beanName, ObjectFactory<?> singletonFactory) {
	Assert.notNull(beanName, "'beanName' must not be null");
	synchronized (this.singletonObjects) {
		Object singletonObject = this.singletonObjects.get(beanName);
		if (singletonObject == null) {
			if (this.singletonsCurrentlyInDestruction) {
				throw new BeanCreationNotAllowedException(beanName,
						"Singleton bean creation not allowed while the singletons of this factory are in destruction " +
						"(Do not request a bean from a BeanFactory in a destroy method implementation!)");
			}
			if (logger.isDebugEnabled()) {
				logger.debug("Creating shared instance of singleton bean '" + beanName + "'");
			}
			beforeSingletonCreation(beanName);
			boolean recordSuppressedExceptions = (this.suppressedExceptions == null);
			if (recordSuppressedExceptions) {
				this.suppressedExceptions = new LinkedHashSet<Exception>();
			}
			try {
				singletonObject = singletonFactory.getObject();
			}
			catch (BeanCreationException ex) {
				if (recordSuppressedExceptions) {
					for (Exception suppressedException : this.suppressedExceptions) {
						ex.addRelatedCause(suppressedException);
					}
				}
				throw ex;
			}
			finally {
				if (recordSuppressedExceptions) {
					this.suppressedExceptions = null;
				}
				afterSingletonCreation(beanName);
			}
			addSingleton(beanName, singletonObject);
		}
		return (singletonObject != NULL_OBJECT ? singletonObject : null);
	}
}
 
Example 3
Source Project: rice   Source File: RiceTestCase.java    License: Educational Community License v2.0 4 votes vote down vote up
@Override
@After
   public void tearDown() throws Exception {
   	// wait for outstanding threads to complete for 1 minute
   	ThreadMonitor.tearDown(60000);
       try {
           stopLifecycles(this.perTestLifeCycles);
       // Avoid failing test for creation of bean in destroy.
       } catch (BeanCreationNotAllowedException bcnae) {
           LOG.warn("BeanCreationNotAllowedException during stopLifecycles during tearDown " + bcnae.getMessage());
       }
       testEnd = System.currentTimeMillis();
       report("Total time to run test: " + (testEnd - testStart));
       logAfterRun();
   }