Search in sources :

Example 6 with InputHandler

use of org.apache.tools.ant.input.InputHandler in project ant-ivy by apache.

the class AntCallTriggerTest method addInputHandler.

/**
 * Creates the InputHandler and adds it to the project.
 *
 * @param project
 *            the project instance.
 * @param inputHandlerClassname
 *            String
 * @exception BuildException
 *                if a specified InputHandler implementation could not be loaded.
 */
private void addInputHandler(Project project, String inputHandlerClassname) throws BuildException {
    InputHandler handler = null;
    if (inputHandlerClassname == null) {
        handler = new DefaultInputHandler();
    } else {
        try {
            handler = (InputHandler) Class.forName(inputHandlerClassname).newInstance();
            if (project != null) {
                project.setProjectReference(handler);
            }
        } catch (ClassCastException e) {
            String msg = "The specified input handler class " + inputHandlerClassname + " does not implement the InputHandler interface";
            throw new BuildException(msg);
        } catch (Exception e) {
            String msg = "Unable to instantiate specified input handler " + "class " + inputHandlerClassname + " : " + e.getClass().getName();
            throw new BuildException(msg);
        }
    }
    project.setInputHandler(handler);
}
Also used : InputHandler(org.apache.tools.ant.input.InputHandler) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) BuildException(org.apache.tools.ant.BuildException) DefaultInputHandler(org.apache.tools.ant.input.DefaultInputHandler) BuildException(org.apache.tools.ant.BuildException)

Aggregations

InputHandler (org.apache.tools.ant.input.InputHandler)6 DefaultInputHandler (org.apache.tools.ant.input.DefaultInputHandler)4 PropertyFileInputHandler (org.apache.tools.ant.input.PropertyFileInputHandler)3 InputRequest (org.apache.tools.ant.input.InputRequest)2 MultipleChoiceInputRequest (org.apache.tools.ant.input.MultipleChoiceInputRequest)2 Test (org.junit.Test)2 AssertionFailedError (junit.framework.AssertionFailedError)1 BuildException (org.apache.tools.ant.BuildException)1 GreedyInputHandler (org.apache.tools.ant.input.GreedyInputHandler)1 SecureInputHandler (org.apache.tools.ant.input.SecureInputHandler)1