Search in sources :

Example 16 with ApplicationContextException

use of org.springframework.context.ApplicationContextException in project spring-framework by spring-projects.

the class LiveBeansView method registerApplicationContext.

static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
    String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
    if (mbeanDomain != null) {
        synchronized (applicationContexts) {
            if (applicationContexts.isEmpty()) {
                try {
                    MBeanServer server = ManagementFactory.getPlatformMBeanServer();
                    applicationName = applicationContext.getApplicationName();
                    server.registerMBean(new LiveBeansView(), new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
                } catch (Throwable ex) {
                    throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex);
                }
            }
            applicationContexts.add(applicationContext);
        }
    }
}
Also used : ApplicationContextException(org.springframework.context.ApplicationContextException) MBeanServer(javax.management.MBeanServer) ObjectName(javax.management.ObjectName)

Example 17 with ApplicationContextException

use of org.springframework.context.ApplicationContextException in project spring-framework by spring-projects.

the class AbstractRefreshableApplicationContext method refreshBeanFactory.

/**
	 * This implementation performs an actual refresh of this context's underlying
	 * bean factory, shutting down the previous bean factory (if any) and
	 * initializing a fresh bean factory for the next phase of the context's lifecycle.
	 */
@Override
protected final void refreshBeanFactory() throws BeansException {
    if (hasBeanFactory()) {
        destroyBeans();
        closeBeanFactory();
    }
    try {
        DefaultListableBeanFactory beanFactory = createBeanFactory();
        beanFactory.setSerializationId(getId());
        customizeBeanFactory(beanFactory);
        loadBeanDefinitions(beanFactory);
        synchronized (this.beanFactoryMonitor) {
            this.beanFactory = beanFactory;
        }
    } catch (IOException ex) {
        throw new ApplicationContextException("I/O error parsing bean definition source for " + getDisplayName(), ex);
    }
}
Also used : DefaultListableBeanFactory(org.springframework.beans.factory.support.DefaultListableBeanFactory) IOException(java.io.IOException) ApplicationContextException(org.springframework.context.ApplicationContextException)

Aggregations

ApplicationContextException (org.springframework.context.ApplicationContextException)17 Test (org.junit.Test)4 MockServletContext (org.springframework.mock.web.test.MockServletContext)3 IOException (java.io.IOException)2 MBeanServer (javax.management.MBeanServer)2 ObjectName (javax.management.ObjectName)2 ServletContextEvent (javax.servlet.ServletContextEvent)2 DirectoryContent (com.github.hakko.musiccabinet.domain.model.aggr.DirectoryContent)1 File (com.github.hakko.musiccabinet.domain.model.library.File)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 DirectoryIteratorException (java.nio.file.DirectoryIteratorException)1 Path (java.nio.file.Path)1 BasicFileAttributeView (java.nio.file.attribute.BasicFileAttributeView)1 BasicFileAttributes (java.nio.file.attribute.BasicFileAttributes)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ServletContext (javax.servlet.ServletContext)1 ServletContextListener (javax.servlet.ServletContextListener)1 ServletException (javax.servlet.ServletException)1