View Javadoc

1   package com.salto.db.ant;
2   
3   import org.apache.tools.ant.BuildException;
4   import org.apache.tools.ant.Project;
5   import org.apache.tools.ant.Task;
6   
7   import com.salto.db.generator.plugin.IGeneratorPlugin;
8   import com.salto.db.generator.plugin.Plugins;
9   
10  /***
11   * Register a plugin
12   * 
13   * @author rflament@salto-consulting.com
14   * 
15   */
16  public class RegisterPluginTask extends Task {
17  
18  	private String className;
19  
20  	public String getClassName() {
21  		return className;
22  	}
23  
24  	public void setClassName(String className) {
25  		this.className = className;
26  	}
27  
28  	public void execute() throws BuildException {
29  		log("Registering plugin from classname '" + className + "'");
30  		
31  		try {
32  			Class c = Class.forName(className);
33  			IGeneratorPlugin plugin = (IGeneratorPlugin) c.newInstance();
34  			Plugins.getInstance().addPlugin(plugin);
35  
36  		} catch (ClassNotFoundException e) {
37  			throw new BuildException("cannot find class '" + className
38  					+ "' in classpath", e);
39  
40  		} catch (Exception e) {
41  			throw new BuildException(e);
42  		}
43  
44  	}
45  
46  }