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

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

Introduction

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

Prototype

@Override
public void setParent(@Nullable ApplicationContext parent) 

Source Link

Document

Set the parent of this application context.

Usage

From source file:org.openspaces.esb.mule.pu.OpenSpacesMuleContextLoader.java

public void onApplicationEvent(ApplicationEvent event) {
    if (event instanceof ContextRefreshedEvent) {
        if (!contextCreated) {
            contextCreated = true;/*from w  w w.jav a 2  s .  co  m*/
            try {
                muleContextFactory = new DefaultMuleContextFactory();
                SpringXmlConfigurationBuilder muleXmlConfigurationBuilder = new SpringXmlConfigurationBuilder(
                        location) {
                    @Override
                    protected ApplicationContext createApplicationContext(MuleContext muleContext,
                            ConfigResource[] configResources) throws Exception {
                        AbstractApplicationContext context = (AbstractApplicationContext) super.createApplicationContext(
                                muleContext, configResources);
                        context.setParent(applicationContext);
                        muleApplicationContext = context;
                        return context;
                    }
                };
                muleXmlConfigurationBuilder.setParentContext(this.applicationContext);
                muleContext = muleContextFactory.createMuleContext(muleXmlConfigurationBuilder);
                muleContext.start();
            } catch (Exception e) {
                throw new RuntimeException("Failed to start mule [" + location + "]", e);
            }
        }
    }
}