Package groovy.lang

Examples of groovy.lang.Binding


                    childFirstLoader.addPathComponent( new File( path ) );
                }
                loader = childFirstLoader;
            }

            Binding binding = new Binding( globalVariables );

            GroovyShell interpreter = new GroovyShell( loader, binding, config );

            try
            {
View Full Code Here


    /**
     * Parses the bean definition groovy script.
     */
    public void parse(InputStream script) {
        parse(script,new Binding());
    }
View Full Code Here

      @Override
      public Object call(Object[] args) {
        return beans((Closure)args[0]);
      }
    };
    Binding b = new Binding();
    b.setVariable("beans", beans);

    GroovyShell shell = classLoader != null ? new GroovyShell(classLoader,b) : new GroovyShell(b);
        for (Resource resource : resources) {
            shell.evaluate(resource.getInputStream());
        }
View Full Code Here

    protected int run() throws Exception {
        // this allows the caller to manipulate the JVM state, so require the execute script privilege.
        Jenkins.getInstance().checkPermission(Jenkins.RUN_SCRIPTS);

        Binding binding = new Binding();
        binding.setProperty("out",new PrintWriter(stdout,true));
        binding.setProperty("stdin",stdin);
        binding.setProperty("stdout",stdout);
        binding.setProperty("stderr",stderr);
        binding.setProperty("channel",channel);
        String j = getClientEnvironmentVariable("JOB_NAME");
        if (j!=null) {
            Item job = Jenkins.getInstance().getItemByFullName(j);
            binding.setProperty("currentJob", job);
            String b = getClientEnvironmentVariable("BUILD_NUMBER");
            if (b!=null && job instanceof AbstractProject) {
                Run r = ((AbstractProject) job).getBuildByNumber(Integer.parseInt(b));
                binding.setProperty("currentBuild", r);
            }
        }

        GroovyShell groovy = new GroovyShell(Jenkins.getInstance().getPluginManager().uberClassLoader, binding);
        groovy.run(loadScript(),"RemoteClass",remaining.toArray(new String[remaining.size()]));
View Full Code Here

     */
    public boolean evalGroovyExpression(AxisList axes, String expression) {
        if(Util.fixEmptyAndTrim(expression)==null)
            return true;

        Binding binding = new Binding();
        for (Map.Entry<String, String> e : entrySet())
            binding.setVariable(e.getKey(),e.getValue());

        binding.setVariable("index",toModuloIndex(axes));
        binding.setVariable("uniqueId",toIndex(axes));

        GroovyShell shell = new GroovyShell(binding);

        Object result = shell.evaluate("use("+BooleanCategory.class.getName().replace('$','.')+") {"+expression+"}");
        return TRUE.equals(result);
View Full Code Here

     * Filter to run for the LegacySecurityRealm is the
     * ChainServletFilter legacy from /WEB-INF/security/SecurityFilters.groovy.
     */
    @Override
    public Filter createFilter(FilterConfig filterConfig) {
        Binding binding = new Binding();
        SecurityComponents sc = this.createSecurityComponents();
        binding.setVariable("securityComponents", sc);
        binding.setVariable("securityRealm",this);
        BeanBuilder builder = new BeanBuilder();
        builder.parse(filterConfig.getServletContext().getResourceAsStream("/WEB-INF/security/SecurityFilters.groovy"),binding);
       
        WebApplicationContext context = builder.createApplicationContext();
       
View Full Code Here

            cc.addCompilationCustomizers(new ImportCustomizer().addStarImports(
                    "jenkins",
                    "jenkins.model",
                    "hudson",
                    "hudson.model"));
            GroovyShell shell = new GroovyShell(cl,new Binding(),cc);

            StringWriter out = new StringWriter();
            PrintWriter pw = new PrintWriter(out);
            shell.setVariable("out", pw);
            try {
View Full Code Here

    @SuppressWarnings({"unchecked","rawtypes"})
    protected Groovysh createShell(InputStream stdin, PrintStream stdout,
        PrintStream stderr) {

        Binding binding = new Binding();
        // redirect "println" to the CLI
        binding.setProperty("out", new PrintWriter(stdout,true));
        binding.setProperty("hudson", Jenkins.getInstance()); // backward compatibility
        binding.setProperty("jenkins", Jenkins.getInstance());

        IO io = new IO(new BufferedInputStream(stdin),stdout,stderr);

        final ClassLoader cl = Thread.currentThread().getContextClassLoader();
        Closure registrar = new Closure(null, null) {
View Full Code Here

        File scriptDir = scriptLocater.locate(configurationData);
       
        Map<String, Object> bindings = new HashMap<String, Object>();
        bindings.put(BINDING_CONFIGURATION_DATA, configurationData);
        bindings.put(BINDING_CONFIGURATION_DATA_BUILDER, new ConfigurationDataBuilder(configurationData));
        Binding binding = new Binding(bindings);
        GroovyShell shell = new GroovyShell(binding);

        executeScripts(shell, scriptDir, PATTERN_DEPENDENCIES_FILE);
    }
View Full Code Here

        Map<String, Object> bindings = new HashMap<String, Object>();
        bindings.put(BINDING_CONFIGURATION_DATA, configurationData);
        bindings.put(BINDING_GBEAN_DATAS, gbeanDatas);
        bindings.put(BINDING_GBEAN_DATAS_BUILDER, new GBeanDataBuilder(configurationData, gbeanDatas));
        Binding binding = new Binding(bindings);
        GroovyShell shell = new GroovyShell(classLoader, binding);

        executeScripts(shell, scriptDir, PATTERN_GBEANS_FILE);

        return gbeanDatas;
View Full Code Here

TOP

Related Classes of groovy.lang.Binding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.