public ConfigurableApplicationContext createApplicationContext() {
        try {
            // first try to create annotation config application context
            Class<?>[] annotatedClasses = new Class<?>[resources.length];
            for (int i = 0; i < resources.length; i++) {
                annotatedClasses[i] = this.classLoader.loadClass(resources[i]);
            }
            AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(annotatedClasses);
            context.setParent(parent);
            context.setClassLoader(classLoader);
            return context;
        } catch (ClassNotFoundException e) {
            // create generic application context
            GenericApplicationContext context = new GenericApplicationContext(parent);
            context.setClassLoader(classLoader);
            ResourceLoader resourceLoader = new DefaultResourceLoader(classLoader);
            context.setResourceLoader(resourceLoader);
            BeanDefinitionReader reader = new XmlBeanDefinitionReader(context);
            for (String resource : resources) {
                reader.loadBeanDefinitions(resourceLoader.getResource(resource));
            }
            context.refresh();
            return context;
        }

    }
public ConfigurableApplicationContext createApplicationContext ( ) { try { Class < ? > [ ] annotatedClasses = new Class < ? > [ resources . length ] ; for ( int i = 0 ; i < resources . length ; i ++ ) { annotatedClasses [ i ] = this . classLoader . loadClass ( resources [ i ] ) ; } AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext ( annotatedClasses ) ; context . setParent ( parent ) ; context . setClassLoader ( classLoader ) ; return context ; } catch ( ClassNotFoundException e ) { GenericApplicationContext context = new GenericApplicationContext ( parent ) ; context . setClassLoader ( classLoader ) ; ResourceLoader resourceLoader = new DefaultResourceLoader ( classLoader ) ; context . setResourceLoader ( resourceLoader ) ; BeanDefinitionReader reader = new XmlBeanDefinitionReader ( context ) ; for ( String resource : resources ) { reader . loadBeanDefinitions ( resourceLoader . getResource ( resource ) ) ; } context . refresh ( ) ; return context ; } }
Creates a configurable application context from the resources provided.
The context will be an instance of
{@link AnnotationConfigApplicationContext}, if the resources are
annotated class names, or {@link GenericApplicationContext} otherwise.

@return A ConfigurableApplicationContext