001: /*
002: * Project: AMODA - Abstract Modeled Application
003: * Class: de.gulden.framework.amoda.environment.ant.ANTTaskApplicationWrapper
004: * Version: snapshot-beautyj-1.1
005: *
006: * Date: 2004-09-29
007: *
008: * This is a snapshot version of the AMODA 0.2 development branch,
009: * it is not released as a seperate version.
010: * For AMODA, see http://amoda.berlios.de/.
011: *
012: * This is licensed under the GNU Lesser General Public License (LGPL)
013: * and comes with NO WARRANTY.
014: *
015: * Author: Jens Gulden
016: * Email: amoda@jensgulden.de
017: */
018:
019: package de.gulden.framework.amoda.environment.ant;
020:
021: import de.gulden.framework.amoda.environment.commandline.*;
022: import de.gulden.framework.amoda.generic.core.*;
023: import de.gulden.framework.amoda.model.data.*;
024: import java.lang.*;
025: import java.util.*;
026: import org.apache.tools.ant.Task;
027: import org.xml.sax.*;
028:
029: /**
030: * Class ANTTaskApplicationWrapper.
031: *
032: * @author Jens Gulden
033: * @version snapshot-beautyj-1.1
034: */
035: public abstract class ANTTaskApplicationWrapper extends Task {
036:
037: // ------------------------------------------------------------------------
038: // --- fields ---
039: // ------------------------------------------------------------------------
040:
041: protected AttributeList originalAttributes;
042:
043: protected GenericApplication application;
044:
045: protected ANTTaskEnvironment environment;
046:
047: // ------------------------------------------------------------------------
048: // --- constructor ---
049: // ------------------------------------------------------------------------
050:
051: public ANTTaskApplicationWrapper() {
052: super ();
053: }
054:
055: // ------------------------------------------------------------------------
056: // --- methods ---
057: // ------------------------------------------------------------------------
058:
059: public GenericApplication getApplication() {
060: return application;
061: }
062:
063: public void setApplication(GenericApplication genericApplication) {
064: this .application = genericApplication;
065: }
066:
067: public ANTTaskEnvironment getEnvironment() {
068: return environment;
069: }
070:
071: public void setEnvironment(ANTTaskEnvironment aNTTaskEnvironment) {
072: if (this .environment != aNTTaskEnvironment) {
073: this .environment = aNTTaskEnvironment;
074: if (aNTTaskEnvironment != null)
075: aNTTaskEnvironment.setTaskWrapper(this );
076: }
077: }
078:
079: public abstract GenericApplication createWrappedApplication();
080:
081: public void init() {
082: setApplication(createWrappedApplication());
083: ANTTaskEnvironmentFactory f = new ANTTaskEnvironmentFactory(); //,getConfigurationResourceURL()
084: ANTTaskEnvironment env = (ANTTaskEnvironment) f
085: .createApplicationEnvironment();
086: env.setTaskWrapper(this );
087: this .setEnvironment(env);
088: getApplication().init(env);
089: }
090:
091: public void execute() {
092: try {
093: getEnvironment().launch(getApplication());
094: } catch (de.gulden.framework.amoda.model.option.IllegalOptionError ioe) {
095: throw new org.apache.tools.ant.BuildException(ioe);
096: }
097: }
098:
099: public void addSrc(Src src) {
100: getEnvironment().addInput(src);
101: }
102:
103: public void addValue(Value value) {
104: getEnvironment().addInput(value);
105: }
106:
107: protected void setOption(String option, String value) {
108: getApplication()
109: .getOptions()
110: .getOptionEntry(option)
111: .getValue(
112: de.gulden.framework.amoda.model.option.Option.STATE_CURRENT)
113: .set(value);
114: }
115:
116: } // end ANTTaskApplicationWrapper
|