alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Jetty example source code file (BeanShellRunMojo.java)

This example Jetty source code file (BeanShellRunMojo.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Jetty tags/keywords

abstractmojo, beanshellrunmojo, evalerror, evalerror, interpreter, interpreter, mojoexecutionexception, mojofailureexception, string, string, treemap, treemap, util

The Jetty BeanShellRunMojo.java source code

package org.mortbay.jetty.plugin.beanshell;

import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

import bsh.Interpreter;
import bsh.EvalError;


import java.util.TreeMap;

/**
 * Used to run scripts in maven
 * Scripts: Beanshell and etc..
 *
 * @author Leopoldo Lee Agdeppa III
 * @goal run
 * @requiresDependencyResolution runtime
 * @execute phase="test-compile"
 * @description Runs jetty6 directly from a maven project
 */
public class BeanShellRunMojo extends AbstractMojo
{

    /**
     * BeanShell Script
     *
     * @parameter
     * @required
     */
    private String script;

    /**
     * Script parameters params.get("param_name");
     *
     * @parameter
     */
    private TreeMap params;


    public void execute() throws MojoExecutionException, MojoFailureException
    {
        Interpreter i = new Interpreter();
        try
        {
            i.set("params", params);
            i.eval(script);
        }
        catch (EvalError evalError)
        {
            evalError.printStackTrace();
            throw new MojoExecutionException(evalError.getMessage());

        }


    }


    public String getScript()
    {
        return script;
    }

    public void setScript(String script)
    {
        this.script = script;
    }

    public TreeMap getParams()
    {
        return params;
    }

    public void setParams(TreeMap params)
    {
        this.params = params;
    }
}

Other Jetty examples (source code examples)

Here is a short list of links related to this Jetty BeanShellRunMojo.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.