Java 类org.springframework.beans.factory.access.BootstrapException 实例源码

项目:lams    文件:ContextJndiBeanFactoryLocator.java   
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
    try {
        String beanFactoryPath = lookup(factoryKey, String.class);
        if (logger.isTraceEnabled()) {
            logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
                    "] is: " + beanFactoryPath);
        }
        String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
        return createBeanFactory(paths);
    }
    catch (NamingException ex) {
        throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
                "the class path locations of XML bean definition files", ex);
    }
}
项目:spring4-understanding    文件:ContextJndiBeanFactoryLocator.java   
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
    try {
        String beanFactoryPath = lookup(factoryKey, String.class);
        if (logger.isTraceEnabled()) {
            logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
                    "] is: " + beanFactoryPath);
        }
        String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
        return createBeanFactory(paths);
    }
    catch (NamingException ex) {
        throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
                "the class path locations of XML bean definition files", ex);
    }
}
项目:my-spring-cache-redis    文件:ContextJndiBeanFactoryLocator.java   
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
    try {
        String beanFactoryPath = lookup(factoryKey, String.class);
        if (logger.isTraceEnabled()) {
            logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
                    "] is: " + beanFactoryPath);
        }
        String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
        return createBeanFactory(paths);
    }
    catch (NamingException ex) {
        throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
                "the class path locations of XML bean definition files", ex);
    }
}
项目:spring    文件:ContextJndiBeanFactoryLocator.java   
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
    try {
        String beanFactoryPath = lookup(factoryKey, String.class);
        if (logger.isTraceEnabled()) {
            logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
                    "] is: " + beanFactoryPath);
        }
        String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
        return createBeanFactory(paths);
    }
    catch (NamingException ex) {
        throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
                "the class path locations of XML bean definition files", ex);
    }
}
项目:class-guard    文件:ContextJndiBeanFactoryLocator.java   
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
    try {
        String beanFactoryPath = lookup(factoryKey, String.class);
        if (logger.isTraceEnabled()) {
            logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
                    "] is: " + beanFactoryPath);
        }
        String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
        return createBeanFactory(paths);
    }
    catch (NamingException ex) {
        throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
                "the class path locations of XML bean definition files", ex);
    }
}
项目:spring4-understanding    文件:ContextJndiBeanFactoryLocatorTests.java   
@Test
public void beanFactoryPathRequiredFromJndiEnvironment() throws Exception {
    // Set up initial context but don't bind anything
    SimpleNamingContextBuilder.emptyActivatedContextBuilder();

    ContextJndiBeanFactoryLocator jbfl = new ContextJndiBeanFactoryLocator();
    try {
        jbfl.useBeanFactory(BEAN_FACTORY_PATH_ENVIRONMENT_KEY);
        fail();
    }
    catch (BootstrapException ex) {
        // Check for helpful JNDI message
        assertTrue(ex.getMessage().indexOf(BEAN_FACTORY_PATH_ENVIRONMENT_KEY) != -1);
    }
}
项目:communote-server    文件:DispatcherServletInitializer.java   
private String getRequiredInitParameter(String parameterName) {
    String value = servletContext.getInitParameter(parameterName);
    if (value == null) {
        throw new BootstrapException("Required servlet context initialization parameter "
                + parameterName + " is not defined");
    }
    return value;
}
项目:communote-server    文件:PublicAccessProcessingFilterTest.java   
/**
 * Test the filter.
 *
 * @throws Exception
 *             in case the test fails
 */
@Test(groups = { "allowAnonymous" })
public void testDoFilterAllowAccess() throws Exception {
    try {
        // filter.doFilter(request, response, chain);
    } catch (BootstrapException e) {
        // Okay. Method was called, but Service is not available at the moment.
        return;
    }
    Assert.fail("Something went wrong.");
}
项目:class-guard    文件:ContextJndiBeanFactoryLocatorTests.java   
public void testBeanFactoryPathRequiredFromJndiEnvironment() throws Exception {
    // Set up initial context but don't bind anything
    SimpleNamingContextBuilder.emptyActivatedContextBuilder();

    ContextJndiBeanFactoryLocator jbfl = new ContextJndiBeanFactoryLocator();
    try {
        jbfl.useBeanFactory(BEAN_FACTORY_PATH_ENVIRONMENT_KEY);
        fail();
    }
    catch (BootstrapException ex) {
        // Check for helpful JNDI message
        assertTrue(ex.getMessage().indexOf(BEAN_FACTORY_PATH_ENVIRONMENT_KEY) != -1);
    }
}