Example usage for org.springframework.context.support FileSystemXmlApplicationContext setParent

List of usage examples for org.springframework.context.support FileSystemXmlApplicationContext setParent

Introduction

In this page you can find the example usage for org.springframework.context.support FileSystemXmlApplicationContext setParent.

Prototype

@Override
public void setParent(@Nullable ApplicationContext parent) 

Source Link

Document

Set the parent of this application context.

Usage

From source file:org.springframework.data.hadoop.admin.workflow.support.FileSystemApplicationContextFactory.java

/**
 * Creates an {@link ApplicationContext} from the provided path.
 * /* w w  w  . j  a v  a  2  s  . c  o m*/
 * @see ApplicationContextFactory#createApplicationContext()
 */
public ConfigurableApplicationContext createApplicationContext() {
    logger.info("resource is:" + resource);
    if (resource == null) {
        return parent;
    }
    try {
        logger.info("create application context, resource:" + resource.getFile().getAbsolutePath()
                + ", classloader:" + this.beanClassLoader + ". Parent is:" + parent);
        FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext();
        context.setClassLoader(this.beanClassLoader);
        context.setParent(parent);
        context.setConfigLocation(HadoopWorkflowUtils.fileURLPrefix + resource.getFile().getAbsolutePath());
        context.refresh();
        return context;
    } catch (Exception e) {
        try {
            logger.error(
                    "create application context fail. with resource:" + resource.getFile().getAbsolutePath(),
                    e);
        } catch (IOException e1) {
            logger.error("log error", e1);
        }
    }
    return parent;
}