/** The method is used only to implement Context.disableStaticContextListening() */ final void disableContextListening() { checkNotSealed(); synchronized (listenersLock) { disabledListening = true; listeners = null; } }
public final void removeListener(Listener listener) { checkNotSealed(); synchronized (listenersLock) { if (disabledListening) { throw new IllegalStateException(); } listeners = Kit.removeListener(listeners, listener); } }
/** * Set explicit class loader to use when searching for Java classes. * * @see #getApplicationClassLoader() */ public final void initApplicationClassLoader(ClassLoader loader) { if (loader == null) throw new IllegalArgumentException("loader is null"); if (!Kit.testIfCanLoadRhinoClasses(loader)) throw new IllegalArgumentException("Loader can not resolve Rhino classes"); if (this.applicationClassLoader != null) throw new IllegalStateException("applicationClassLoader can only be set once"); checkNotSealed(); this.applicationClassLoader = loader; }
/** * Seal this ContextFactory so any attempt to modify it like to add or remove its listeners will * throw an exception. * * @see #isSealed() */ public final void seal() { checkNotSealed(); sealed = true; }