示例#1
0
  protected void createSpringParentRegistry(
      MuleContext muleContext, Registry registry, ConfigResource[] all) {
    Resource[] servletContextResources = new Resource[all.length];
    for (int i = 0; i < all.length; i++) {
      servletContextResources[i] =
          new ServletContextOrClassPathResource(context, all[i].getResourceName());
    }

    parentContext = loadParentContext(context);

    try {
      if (parentContext != null) {
        new MuleApplicationContext(muleContext, registry, servletContextResources, parentContext);
      } else {
        new MuleApplicationContext(muleContext, registry, servletContextResources);
      }
    } catch (BeansException e) {
      // If creation of MuleApplicationContext fails, remove
      // TransientRegistry->SpringRegistry parent relationship
      registry.setParent(null);
      throw e;
    } catch (IOException e) {
      registry.setParent(null);
      throw new ApplicationContextException("Failed to load config resource", e);
    }
  }