本文整理汇总了Java中org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerFactoryFactory.getDefaultCompilerFactory方法的具体用法?Java CompilerFactoryFactory.getDefaultCompilerFactory怎么用?Java CompilerFactoryFactory.getDefaultCompilerFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.commons.compiler.CompilerFactoryFactory
的用法示例。
在下文中一共展示了CompilerFactoryFactory.getDefaultCompilerFactory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBindable
import org.codehaus.commons.compiler.CompilerFactoryFactory; //导入方法依赖的package包/类
static Bindable getBindable(ClassDeclaration expr, String s, int fieldCount)
throws CompileException, IOException {
ICompilerFactory compilerFactory;
try {
compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
} catch (Exception e) {
throw new IllegalStateException(
"Unable to instantiate java compiler", e);
}
IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator();
cbe.setClassName(expr.name);
cbe.setExtendedClass(Utilities.class);
cbe.setImplementedInterfaces(
fieldCount == 1
? new Class[] {Bindable.class, Typed.class}
: new Class[] {ArrayBindable.class});
cbe.setParentClassLoader(EnumerableInterpretable.class.getClassLoader());
if (CalcitePrepareImpl.DEBUG) {
// Add line numbers to the generated janino class
cbe.setDebuggingInformation(true, true, true);
}
return (Bindable) cbe.createInstance(new StringReader(s));
}
示例2: getScalar
import org.codehaus.commons.compiler.CompilerFactoryFactory; //导入方法依赖的package包/类
static Scalar getScalar(ClassDeclaration expr, String s)
throws CompileException, IOException {
ICompilerFactory compilerFactory;
try {
compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
} catch (Exception e) {
throw new IllegalStateException(
"Unable to instantiate java compiler", e);
}
IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator();
cbe.setClassName(expr.name);
cbe.setImplementedInterfaces(new Class[]{Scalar.class});
cbe.setParentClassLoader(JaninoRexCompiler.class.getClassLoader());
if (CalcitePrepareImpl.DEBUG) {
// Add line numbers to the generated janino class
cbe.setDebuggingInformation(true, true, true);
}
return (Scalar) cbe.createInstance(new StringReader(s));
}
示例3: getExpression
import org.codehaus.commons.compiler.CompilerFactoryFactory; //导入方法依赖的package包/类
/**
* Creates the instance of the class defined in {@link ClassDeclaration}
* @param expr Interface whose instance needs to be created.
* @param s The java code that implements the interface which should be used to create the instance.
* @return The object of the class which implements the interface {@link Expression} with the code that is passed as input.
* @throws CompileException
* @throws IOException
*/
static Expression getExpression(ClassDeclaration expr, String s) throws CompileException, IOException {
ICompilerFactory compilerFactory;
try {
compilerFactory = CompilerFactoryFactory.getDefaultCompilerFactory();
} catch (Exception e) {
throw new IllegalStateException("Unable to instantiate java compiler", e);
}
IClassBodyEvaluator cbe = compilerFactory.newClassBodyEvaluator();
cbe.setClassName(expr.name);
cbe.setImplementedInterfaces(expr.implemented.toArray(new Class[expr.implemented.size()]));
cbe.setParentClassLoader(RexToJavaCompiler.class.getClassLoader());
cbe.setDebuggingInformation(true, true, true);
return (org.apache.samza.sql.data.Expression) cbe.createInstance(new StringReader(s));
}
示例4: initJanino
import org.codehaus.commons.compiler.CompilerFactoryFactory; //导入方法依赖的package包/类
private static void initJanino() throws SQLException {
// For unknown reason, threadContextClassLoader.getResource("org.codehaus.commons.compiler.properties")
// returns null when accessed via BundleClassLoader
// We make a shortcut
// Some OSGi WA might probably exist
if (initCompilerDone) {
return;
}
initCompilerDone = true;
Thread currentThread = Thread.currentThread();
ClassLoader cl = currentThread.getContextClassLoader();
try{
currentThread.setContextClassLoader(CompilerFactoryFactory.class.getClassLoader());
if (CompilerFactoryFactory.getDefaultCompilerFactory() == null) {
throw new SQLException("Janino compiler is not initialized: CompilerFactoryFactory.getDefaultCompilerFactory() == null");
};
} catch (Exception e) {
throw new SQLException("Unable to load Janino compiler", e);
} finally {
currentThread.setContextClassLoader(cl);
}
}