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.test.manual;
027:
028: import org.apache.avalon.framework.container.ContainerUtil;
029: import org.apache.avalon.framework.service.DefaultServiceManager;
030: import org.jicarilla.container.tck.components.interfaces.Bart;
031: import org.jicarilla.container.tck.components.interfaces.Homer;
032: import org.jicarilla.container.tck.components.interfaces.Lisa;
033: import org.jicarilla.container.tck.components.interfaces.Maggie;
034: import org.jicarilla.container.tck.components.interfaces.Marge;
035: import org.jicarilla.container.tck.components.interfaces.Script;
036: import org.jicarilla.container.tck.components.type1.avalon.AvalonAllInTheFamilyScript;
037: import org.jicarilla.container.tck.components.type1.avalon.AvalonBart;
038: import org.jicarilla.container.tck.components.type1.avalon.AvalonHomer;
039: import org.jicarilla.container.tck.components.type1.avalon.AvalonLisa;
040: import org.jicarilla.container.tck.components.type1.avalon.AvalonMaggie;
041: import org.jicarilla.container.tck.components.type1.avalon.AvalonMarge;
042:
043: /**
044: * Demonstrates a way to manually compose the provided classes
045: * to correctly run all provided scripts.
046: *
047: * @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
048: * @version $Id: ManualSimpsonAvalonContainer.java,v 1.3 2004/01/14 22:57:05 lsimons Exp $
049: */
050: public class ManualSimpsonAvalonContainer {
051: Script m_script;
052:
053: public ManualSimpsonAvalonContainer() throws Exception {
054: Marge marge = new AvalonMarge();
055: Homer homer = new AvalonHomer();
056: Bart bart = new AvalonBart();
057: Lisa lisa = new AvalonLisa();
058: Maggie maggie = new AvalonMaggie();
059: Script script = new AvalonAllInTheFamilyScript();
060:
061: DefaultServiceManager sm = new DefaultServiceManager();
062: sm.put(Marge.class.getName(), marge);
063: sm.put(Homer.class.getName(), homer);
064: sm.put(Bart.class.getName(), bart);
065: sm.put(Lisa.class.getName(), lisa);
066: sm.put(Maggie.class.getName(), maggie);
067: sm.put(Script.class.getName(), script);
068: sm.makeReadOnly();
069:
070: ContainerUtil.service(marge, sm);
071: ContainerUtil.initialize(marge);
072: ContainerUtil.service(homer, sm);
073: ContainerUtil.initialize(homer);
074: ContainerUtil.service(bart, sm);
075: ContainerUtil.initialize(bart);
076: ContainerUtil.service(lisa, sm);
077: ContainerUtil.initialize(lisa);
078: ContainerUtil.service(maggie, sm);
079: ContainerUtil.initialize(maggie);
080: ContainerUtil.service(script, sm);
081: ContainerUtil.initialize(script);
082:
083: setScript(script);
084: }
085:
086: public void run() {
087: getScript().runEpisode();
088: }
089:
090: public static void main(String[] args) {
091: (new Thread(new ManualSimpsonType3RichContainer())).run();
092: }
093:
094: protected Script getScript() {
095: return m_script;
096: }
097:
098: protected void setScript(Script script) {
099: m_script = script;
100: }
101: }
|