org.zodiac.script.context.ScriptEngineContextFactory Maven / Gradle / Ivy
package org.zodiac.script.context;
import org.zodiac.script.engine.ScriptEngineException;
import org.zodiac.sdk.toolkit.util.AssertUtil;
import org.zodiac.sdk.toolkit.util.ClassLoaderUtil;
public final class ScriptEngineContextFactory {
private ScriptEngineContextFactory() {
}
// private static final Map CONTEXTS = CollAndMapUtil.concurrentMap();
//
// static {
// CONTEXTS.put("simple", new SimpleMapScriptEngineContext());
// }
public static ScriptEngineContext createSimpleEngineContext() {
return createEngineContext(SimpleMapScriptEngineContext.class);
}
public static ScriptEngineContext createEngineContext(final Class extends ScriptEngineContext> clazz) {
ScriptEngineContext engineContext = null;
try {
engineContext = (ScriptEngineContext)ClassLoaderUtil.newInstance(AssertUtil.notNull(clazz, "clazz"));
} catch (Exception e) {
throw new ScriptEngineException(e);
}
return engineContext;
}
}