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


Java ImportCustomizer类代码示例

本文整理汇总了Java中org.codehaus.groovy.control.customizers.ImportCustomizer的典型用法代码示例。如果您正苦于以下问题:Java ImportCustomizer类的具体用法?Java ImportCustomizer怎么用?Java ImportCustomizer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ImportCustomizer类属于org.codehaus.groovy.control.customizers包,在下文中一共展示了ImportCustomizer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyConfigurationScript

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private void applyConfigurationScript(File configScript, CompilerConfiguration configuration) {
    VersionNumber version = parseGroovyVersion();
    if (version.compareTo(VersionNumber.parse("2.1")) < 0) {
        throw new GradleException("Using a Groovy compiler configuration script requires Groovy 2.1+ but found Groovy " + version + "");
    }
    Binding binding = new Binding();
    binding.setVariable("configuration", configuration);

    CompilerConfiguration configuratorConfig = new CompilerConfiguration();
    ImportCustomizer customizer = new ImportCustomizer();
    customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
    configuratorConfig.addCompilationCustomizers(customizer);

    GroovyShell shell = new GroovyShell(binding, configuratorConfig);
    try {
        shell.evaluate(configScript);
    } catch (Exception e) {
        throw new GradleException("Could not execute Groovy compiler configuration script: " + configScript.getAbsolutePath(), e);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:21,代码来源:ApiGroovyCompiler.java

示例2: prepareInterpreter

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
@Override
protected void prepareInterpreter() {
    ImportCustomizer importCustomizer = new ImportCustomizer();

    PROCESSOR_CLASSES
            .forEach((interfaceClass, scriptClass) -> addImport(importCustomizer, scriptClass, interfaceClass.getSimpleName()));
    addImport(importCustomizer, GroovyPlugin.class, Plugin.class.getSimpleName());

    getStandardImportClasses().forEach(cls -> addImport(importCustomizer, cls));

    CompilerConfiguration configuration = new CompilerConfiguration();
    configuration.addCompilationCustomizers(importCustomizer);

    binding = createBinding();
    shell = new GroovyShell(binding, configuration);
    scripts = Collections.synchronizedList(new ArrayList<>());

    setVariable(KnowledgeBaseConstants.VAR_ENGINE_OPERATIONS, getEngineOperations());

    setClasspath(getEngineOperations() != null ? getEngineOperations().getEngine() : null);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:22,代码来源:GroovyKnowledgeBaseInterpreter.java

示例3: getGroovyShell

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private GroovyShell getGroovyShell() {
  if (this.groovySh == null) {
    // add some default imports to the script
    ImportCustomizer defaultImports = new ImportCustomizer();
    defaultImports
        .addStarImports("fr.ign.cogit.geoxygene.appli.render.primitive");
    defaultImports
        .addStarImports("fr.ign.cogit.geoxygene.appli.render.operator");
    defaultImports.addStarImports("fr.ign.cogit.geoxygene.appli.render.gl");
    defaultImports.addStarImports("fr.ign.cogit.geoxygene.appli.render");
    defaultImports.addStarImports("fr.ign.cogit.geoxygene.function");
    defaultImports.addStaticStars("org.lwjgl.opengl.GL11");
    defaultImports.addStaticStars("java.lang.Math");
    defaultImports.addStarImports("javax.vecmath");
    defaultImports.addStarImports("java.awt");
    final CompilerConfiguration config = new CompilerConfiguration();
    config.addCompilationCustomizers(defaultImports);
    final Binding binding = this.getBinding();

    this.groovySh = new GroovyShell(binding, config);
  }
  return this.groovySh;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:24,代码来源:ScriptingPrimitiveRenderer.java

示例4: applyImports

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
@Override
public void applyImports(ImportCustomizer imports) {
	imports.addImports("org.springframework.batch.repeat.RepeatStatus",
			"org.springframework.batch.core.scope.context.ChunkContext",
			"org.springframework.batch.core.step.tasklet.Tasklet",
			"org.springframework.batch.core.configuration.annotation.StepScope",
			"org.springframework.batch.core.configuration.annotation.JobBuilderFactory",
			"org.springframework.batch.core.configuration.annotation.StepBuilderFactory",
			"org.springframework.batch.core.configuration.annotation.EnableBatchProcessing",
			"org.springframework.batch.core.Step",
			"org.springframework.batch.core.StepExecution",
			"org.springframework.batch.core.StepContribution",
			"org.springframework.batch.core.Job",
			"org.springframework.batch.core.JobExecution",
			"org.springframework.batch.core.JobParameter",
			"org.springframework.batch.core.JobParameters",
			"org.springframework.batch.core.launch.JobLauncher",
			"org.springframework.batch.core.converter.JobParametersConverter",
			"org.springframework.batch.core.converter.DefaultJobParametersConverter");
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:21,代码来源:SpringBatchCompilerAutoConfiguration.java

示例5: call

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode)
		throws CompilationFailedException {

	ImportCustomizer importCustomizer = new SmartImportCustomizer(source, context,
			classNode);
	ClassNode mainClassNode = MainClass.get(source.getAST().getClasses());

	// Additional auto configuration
	for (CompilerAutoConfiguration autoConfiguration : GroovyCompiler.this.compilerAutoConfigurations) {
		if (autoConfiguration.matches(classNode)) {
			if (GroovyCompiler.this.configuration.isGuessImports()) {
				autoConfiguration.applyImports(importCustomizer);
				importCustomizer.call(source, context, classNode);
			}
			if (classNode.equals(mainClassNode)) {
				autoConfiguration.applyToMainClass(GroovyCompiler.this.loader,
						GroovyCompiler.this.configuration, context, source,
						classNode);
			}
			autoConfiguration.apply(GroovyCompiler.this.loader,
					GroovyCompiler.this.configuration, context, source,
					classNode);
		}
	}
	importCustomizer.call(source, context, classNode);
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:28,代码来源:GroovyCompiler.java

示例6: applyConfigurationScript

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private static void applyConfigurationScript(File configScript, CompilerConfiguration configuration) {
  Binding binding = new Binding();
  binding.setVariable("configuration", configuration);

  CompilerConfiguration configuratorConfig = new CompilerConfiguration();
  ImportCustomizer customizer = new ImportCustomizer();
  customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
  configuratorConfig.addCompilationCustomizers(customizer);

  try {
    new GroovyShell(binding, configuratorConfig).evaluate(configScript);
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:DependentGroovycRunner.java

示例7: configureCompiler

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private void configureCompiler() {
    if (scriptBaseClass!=null) {
        configuration.setScriptBaseClass(scriptBaseClass);
    }
    if (indy) {
        configuration.getOptimizationOptions().put("indy", Boolean.TRUE);
        configuration.getOptimizationOptions().put("int", Boolean.FALSE);
    }
    if (configscript!=null) {
        Binding binding = new Binding();
        binding.setVariable("configuration", configuration);

        CompilerConfiguration configuratorConfig = new CompilerConfiguration();
        ImportCustomizer customizer = new ImportCustomizer();
        customizer.addStaticStars("org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder");
        configuratorConfig.addCompilationCustomizers(customizer);

        GroovyShell shell = new GroovyShell(binding, configuratorConfig);
        File confSrc = new File(configscript);
        try {
            shell.evaluate(confSrc);
        } catch (IOException e) {
            throw new BuildException("Unable to configure compiler using configuration file: "+confSrc, e);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:Groovy.java

示例8: addImport

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private void addImport(final ImportCustomizer customizer, final Object value) {
    if (value==null) return;
    if (value instanceof Collection) {
        for (Object e : (Collection)value) {
            addImport(customizer, e);
        }
    } else if (value instanceof String) {
        customizer.addImports((String)value);
    } else if (value instanceof Class) {
        customizer.addImports(((Class) value).getName());
    } else if (value instanceof GString) {
        customizer.addImports(value.toString());
    } else {
        throw new RuntimeException("Unsupported import value type ["+value+"]");
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:ImportCustomizerFactory.java

示例9: createFromScript

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
public static GroovyFieldDelegate createFromScript(String script, ClassLoader classLoader) {
    CompilerConfiguration config = new CompilerConfiguration();

    SecureASTCustomizer secureAst = new SecureASTCustomizer();
    secureAst.setIndirectImportCheckEnabled(true);
    // TODO: Determine which classes should be accessible.
    secureAst.setImportsBlacklist(Arrays.asList("java.lang.Process"));
    secureAst.setReceiversClassesBlackList(Arrays.asList(String.class));

    ImportCustomizer imports = new ImportCustomizer();
    imports.addImport("Color", "com.dozingcatsoftware.vectorpinball.model.Color");

    config.addCompilationCustomizers(secureAst, imports);

    try (GroovyClassLoader gcl = new GroovyClassLoader(classLoader, config)) {
        @SuppressWarnings("unchecked")
        Class<? extends Script> groovyScriptClass = gcl.parseClass(script);
        return (new GroovyFieldDelegate()).initWithScript(groovyScriptClass.newInstance());
    }
    catch (IOException | InstantiationException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }

}
 
开发者ID:dozingcat,项目名称:Vector-Pinball-Editor,代码行数:25,代码来源:GroovyFieldDelegateBuilder.java

示例10: getShell

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private GroovyShell getShell(Binding binding, GroovyInterceptor sandbox, GenericUserMessageEvent event) {
	binding.setVariable("eval", getEvalFunction(binding, sandbox, event));
	binding.setVariable("commands", new DynamicCommandHandler(this, event));
	CompilerConfiguration cc = new CompilerConfiguration();
	cc.addCompilationCustomizers(
			new SandboxTransformer(),
			new ASTTransformationCustomizer(ImmutableMap.of("value", TIMEOUT), TimedInterrupt.class),
			new ImportCustomizer()
				.addStarImports("java.lang.reflect")
				.addImports(HttpRequest.class.getName())
				.addImports(CommandCall.class.getName())
	);
	GroovyShell shell = new GroovyShell(manager.pluginClassLoader, binding, cc);
	sandbox.register();
	return shell;
}
 
开发者ID:Shockah,项目名称:Skylark,代码行数:17,代码来源:GroovyPlugin.java

示例11: newEvaluator

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
public static GroovyClassLoader newEvaluator(Imports imports, Classpath classpath, String outDir, ImportCustomizer icz,ClassLoader parent) {

    try {
      Class.forName("org.codehaus.groovy.control.customizers.ImportCustomizer");
    } catch (ClassNotFoundException e1) {
      String gjp = System.getenv(GROOVY_JAR_PATH);
      String errorMsg = null;
      if (gjp != null && !gjp.isEmpty()) {
        errorMsg = "Groovy libary not found, GROOVY_JAR_PATH = " + gjp;
      } else {
        errorMsg = "Default groovy libary not found. No GROOVY_JAR_PATH variable set.";
      }
      throw new GroovyNotFoundException(errorMsg);
    }

    icz = addImportsCustomizer(icz, imports);
    CompilerConfiguration config = new CompilerConfiguration().addCompilationCustomizers(icz);
    String acloader_cp = Joiner.on(File.pathSeparatorChar).join(classpath.getPathsAsStrings());
    config.setClasspath(acloader_cp);
    return new GroovyClassLoader(parent, config);
  }
 
开发者ID:twosigma,项目名称:beakerx,代码行数:22,代码来源:GroovyClassLoaderFactory.java

示例12: GroovyConditionShell

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
public GroovyConditionShell() {

        SecureASTCustomizer secureASTCustomizer = createSecureASTCustomizer();
        ImportCustomizer importCustomizer = createImportCustomizer();
        ASTTransformationCustomizer astTransformationCustomizer = createASTTransformationCustomizer();

        CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
        compilerConfiguration.addCompilationCustomizers(secureASTCustomizer);
        compilerConfiguration.addCompilationCustomizers(importCustomizer);
        compilerConfiguration.addCompilationCustomizers(astTransformationCustomizer);

        this.shell = new GroovyShell(compilerConfiguration);
    }
 
开发者ID:eclipse,项目名称:keti,代码行数:14,代码来源:GroovyConditionShell.java

示例13: createImportCustomizer

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private static ImportCustomizer createImportCustomizer() {
    ImportCustomizer importCustomizer = new ImportCustomizer();
    importCustomizer.addImports(ResourceHandler.class.getCanonicalName());
    importCustomizer.addImports(SubjectHandler.class.getCanonicalName());
    importCustomizer.addImports(AbstractHandler.class.getCanonicalName());
    return importCustomizer;
}
 
开发者ID:eclipse,项目名称:keti,代码行数:8,代码来源:GroovyConditionShell.java

示例14: init

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
@PostConstruct
public void init() {
    ImportCustomizer importCustomizer = new ImportCustomizer();
    importCustomizer.addStarImports("net.dv8tion.jda.core.entities");

    configuration = new CompilerConfiguration();
    configuration.addCompilationCustomizers(importCustomizer);

    sharedData = new Binding();
    sharedData.setProperty("ctx", context);
    sharedData.setProperty("jda", discordService.getJda());
}
 
开发者ID:GoldRenard,项目名称:JuniperBotJ,代码行数:13,代码来源:GroovyService.java

示例15: ConfigManager

import org.codehaus.groovy.control.customizers.ImportCustomizer; //导入依赖的package包/类
private ConfigManager()
{
    CompilerConfiguration compilerConfiguration = new CompilerConfiguration();
    ImportCustomizer importCustomizer = new ImportCustomizer();
    importCustomizer.addStarImports("org.diorite.config", "org.diorite.config.serialization", "org.diorite", "org.diorite.config.exceptions");
    compilerConfiguration.addCompilationCustomizers(importCustomizer);
    GroovyClassLoader groovyClassLoader = new GroovyClassLoader(this.getClass().getClassLoader(), compilerConfiguration);
    this.groovy = new GroovyScriptEngineImpl(groovyClassLoader);
    DynamicClassLoader classLoader = DynamicClassLoader.injectAsSystemClassLoader();
    classLoader.addClassLoader(groovyClassLoader, 0);
    this.setImplementationProvider(GroovyImplementationProvider.getInstance());
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:13,代码来源:ConfigManager.java


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