当前位置: 首页>>代码示例>>Java>>正文


Java CompilerFactoryFactory.getDefaultCompilerFactory方法代码示例

本文整理汇总了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));
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:EnumerableInterpretable.java

示例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));
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:JaninoRexCompiler.java

示例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));
}
 
开发者ID:apache,项目名称:samza,代码行数:24,代码来源:RexToJavaCompiler.java

示例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);
    }
}
 
开发者ID:vlsi,项目名称:mat-calcite-plugin,代码行数:23,代码来源:CalciteDataSource.java


注:本文中的org.codehaus.commons.compiler.CompilerFactoryFactory.getDefaultCompilerFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。