001: /* ====================================================================
002: The Jicarilla Software License
003:
004: Copyright (c) 2003 Leo Simons.
005: All rights reserved.
006:
007: Permission is hereby granted, free of charge, to any person obtaining
008: a copy of this software and associated documentation files (the
009: "Software"), to deal in the Software without restriction, including
010: without limitation the rights to use, copy, modify, merge, publish,
011: distribute, sublicense, and/or sell copies of the Software, and to
012: permit persons to whom the Software is furnished to do so, subject to
013: the following conditions:
014:
015: The above copyright notice and this permission notice shall be
016: included in all copies or substantial portions of the Software.
017:
018: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
019: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
020: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
021: IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
022: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
023: TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
024: SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
025: ==================================================================== */
026: package org.jicarilla.container.tck.components;
027:
028: import org.jicarilla.container.tck.components.interfaces.Bart;
029: import org.jicarilla.container.tck.components.interfaces.Homer;
030: import org.jicarilla.container.tck.components.interfaces.Lisa;
031: import org.jicarilla.container.tck.components.interfaces.Maggie;
032: import org.jicarilla.container.tck.components.interfaces.Marge;
033: import org.jicarilla.container.tck.components.interfaces.Script;
034: import org.jicarilla.lang.CascadingRuntimeException;
035:
036: import java.lang.reflect.Method;
037:
038: /**
039: *
040: *
041: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
042: * @version $Id: AbstractAllInTheFamilyScript.java,v 1.3 2004/03/23 13:37:54 lsimons Exp $
043: */
044: public abstract class AbstractAllInTheFamilyScript extends
045: AbstractComponent implements Script {
046: private Homer m_homer;
047: private Marge m_marge;
048: private Bart m_bart;
049: private Lisa m_lisa;
050: private Maggie m_maggie;
051:
052: // ----------------------------------------------------------------------
053: // Poor-Man's Invocation Logging
054: // ----------------------------------------------------------------------
055: public final static Method setHomer;
056: public final static Method setMarge;
057: public final static Method setBart;
058: public final static Method setLisa;
059: public final static Method setMaggie;
060: public final static Method runEpisode;
061: static {
062: try {
063: setHomer = AbstractAllInTheFamilyScript.class.getMethod(
064: "setHomer", new Class[] { Homer.class });
065: setMarge = AbstractAllInTheFamilyScript.class.getMethod(
066: "setMarge", new Class[] { Marge.class });
067: setBart = AbstractAllInTheFamilyScript.class.getMethod(
068: "setBart", new Class[] { Bart.class });
069: setLisa = AbstractAllInTheFamilyScript.class.getMethod(
070: "setLisa", new Class[] { Lisa.class });
071: setMaggie = AbstractAllInTheFamilyScript.class.getMethod(
072: "setMaggie", new Class[] { Maggie.class });
073: runEpisode = AbstractAllInTheFamilyScript.class.getMethod(
074: "runEpisode", new Class[0]);
075: } catch (NoSuchMethodException e) {
076: throw new CascadingRuntimeException(e.getMessage(), e);
077: }
078: }
079:
080: public void runEpisode() {
081: super .log(runEpisode);
082: getHomer().burp();
083: getMarge().frown();
084: getBart().swear();
085: getLisa().actSmart();
086: }
087:
088: protected Homer getHomer() {
089: return m_homer;
090: }
091:
092: public void setHomer(Homer homer) {
093: super .log(setHomer, new Object[] { homer });
094: m_homer = homer;
095: }
096:
097: protected Marge getMarge() {
098: return m_marge;
099: }
100:
101: public void setMarge(Marge marge) {
102: super .log(setMarge, new Object[] { marge });
103: m_marge = marge;
104: }
105:
106: protected Bart getBart() {
107: return m_bart;
108: }
109:
110: public void setBart(Bart bart) {
111: super .log(setBart, new Object[] { bart });
112: m_bart = bart;
113: }
114:
115: protected Lisa getLisa() {
116: return m_lisa;
117: }
118:
119: public void setLisa(Lisa lisa) {
120: super .log(setLisa, new Object[] { lisa });
121: m_lisa = lisa;
122: }
123:
124: protected Maggie getMaggie() {
125: return m_maggie;
126: }
127:
128: public void setMaggie(Maggie maggie) {
129: super .log(setMaggie, new Object[] { maggie });
130: m_maggie = maggie;
131: }
132: }
|