public void close() { log.trace("closing " + this); Environment popped = Environment.popEnvironment(); if (this != popped) { throw new PvmException("environment nesting problem"); } }
public Environment openEnvironment() { PvmEnvironment environment = new PvmEnvironment(this); log.debug("opening " + environment); // set the classloader ClassLoader classLoader = environmentFactoryCtxWireContext.getClassLoader(); if (classLoader != null) { environment.setClassLoader(classLoader); } // add the environment-factory context environment.addContext(environmentFactoryCtxWireContext); // add the environment block context WireContext environmentContext = new WireContext( environmentCtxWireDefinition, Context.CONTEXTNAME_ENVIRONMENT, environment, true); // add the environment block context to the environment environment.addContext(environmentContext); try { // finish the creation of the environment wire context environmentContext.create(); } catch (RuntimeException e) { // On exception, pop environment Environment.popEnvironment(); throw e; } // if all went well, return the created environment return environment; }