001: /*
002: *
003: * Hook.java -
004: * Copyright (C) 2003 Ecoo Team
005: * charoy@loria.fr
006: *
007: *
008: * This program is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public License
010: * as published by the Free Software Foundation; either version 2
011: * of the License, or (at your option) any later version.
012: *
013: * This program is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021: */
022:
023: package hero.hook;
024:
025: import hero.interfaces.BnProjectLocal;
026: import hero.util.HeroException;
027: import hero.util.HeroHookException;
028: import java.io.Serializable;
029: import hero.interfaces.Constants;
030:
031: public abstract class ProcessHook implements Serializable {
032:
033: private String name;
034: private String event;
035: private int type;
036: private String script;
037:
038: public static ProcessHook make(String name, String event, int type)
039: throws HeroException {
040: if (type == Constants.Hook.JAVA) {
041: return new JavaProcessHook(name, event, type);
042: }
043: throw new HeroException("Wrong Process Hook Type " + type);
044: }
045:
046: /* To be completed in future
047: public static ProcessHook make(String name, String event, int type, String script) throws HeroException {
048: if (type==Constants.Hook.BSINTERACTIVE) {return new InteractiveBSProcessHook(name,event,type,script);}
049: throw new HeroException("Wrong Hook Type "+type);
050: }
051: */
052:
053: protected ProcessHook(String name, String event, int type) {
054: this .name = name;
055: this .event = event;
056: this .type = type;
057: }
058:
059: protected ProcessHook(String name, String event, int type,
060: String script) {
061: this .name = name;
062: this .event = event;
063: this .type = type;
064: this .script = script;
065: }
066:
067: public String getName() {
068: return this .name;
069: }
070:
071: public void setName(String name) {
072: this .name = name;
073: }
074:
075: public int getType() {
076: return this .type;
077: }
078:
079: public void setType(int type) {
080: this .type = type;
081: }
082:
083: public String getEvent() {
084: return this .event;
085: }
086:
087: public void setEvent(String event) {
088: this .event = event;
089: }
090:
091: public String getScript() {
092: return this .script;
093: }
094:
095: public void setScript(String script) {
096: this .script = script;
097: }
098:
099: public String toXML() {
100: String result = new String();
101: result = "<Process hook name=\"" + this .getName()
102: + "\" type=\"" + this .getType() + "\" event=\""
103: + this .getEvent() + "\"/>";
104: return result;
105: }
106:
107: public abstract void execute(Object bean, String eventName,
108: BnProjectLocal project) throws HeroHookException;
109:
110: }
|