private void construct(ContainerConfiguration c) throws PlexusContainerException {
    if (c.getParentContainer() != null) {
      this.parentContainer = c.getParentContainer();

      this.loggerManager = parentContainer.getLoggerManager();

      this.containerRealm =
          getChildRealm(getName(), name, c.getParentContainer().getContainerRealm());
    }

    this.name = c.getName();

    // ----------------------------------------------------------------------------
    // ClassWorld
    // ----------------------------------------------------------------------------

    this.classWorld = c.getClassWorld();

    // Make sure we have a valid ClassWorld
    if (this.classWorld == null) {
      this.classWorld =
          new ClassWorld(DEFAULT_REALM_NAME, Thread.currentThread().getContextClassLoader());
    }

    containerRealm = c.getRealm();

    if (containerRealm == null) {
      try {
        containerRealm = this.classWorld.getRealm(DEFAULT_REALM_NAME);
      } catch (NoSuchRealmException e) {
        List realms = new LinkedList(this.classWorld.getRealms());

        containerRealm = (ClassRealm) realms.get(0);

        if (containerRealm == null) {
          System.err.println("No container realm! Expect errors.");

          new Throwable().printStackTrace();
        }
      }
    }

    setLookupRealm(containerRealm);

    // ----------------------------------------------------------------------------
    // Context
    // ----------------------------------------------------------------------------

    this.containerContext = new DefaultContext();

    if (c.getContext() != null) {
      for (Iterator it = c.getContext().entrySet().iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();

        addContextValue(entry.getKey(), entry.getValue());
      }
    }

    // ----------------------------------------------------------------------------
    // Configuration
    // ----------------------------------------------------------------------------

    // TODO: just store reference to the configuration in a String and use that in the configuration
    // initialization

    InputStream in = null;

    if (c.getContainerConfiguration() != null) {
      in = toStream(c.getContainerConfiguration());
    }

    try {
      if (c.getContainerConfigurationURL() != null) {
        in = c.getContainerConfigurationURL().openStream();
      }
    } catch (IOException e) {
      throw new PlexusContainerException("Error reading configuration URL", e);
    }

    try {
      this.configurationReader = in == null ? null : ReaderFactory.newXmlReader(in);
    } catch (IOException e) {
      throw new PlexusContainerException("Error reading configuration file", e);
    }

    try {
      // XXX this will set up the configuration and process it
      initialize();

      // XXX this will wipe out the configuration field - is this needed? If so,
      // why? can we remove the need to have a configuration field then?
      start();
    } finally {
      IOUtil.close(this.configurationReader);
    }
  }