KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > storeconfig > StandardEngineSF


1 /*
2  * Copyright 1999-2001,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.catalina.storeconfig;
18
19 import java.io.PrintWriter JavaDoc;
20
21 import org.apache.catalina.Container;
22 import org.apache.catalina.Lifecycle;
23 import org.apache.catalina.LifecycleListener;
24 import org.apache.catalina.Pipeline;
25 import org.apache.catalina.Realm;
26 import org.apache.catalina.Valve;
27 import org.apache.catalina.core.StandardEngine;
28 import org.apache.commons.logging.Log;
29 import org.apache.commons.logging.LogFactory;
30
31 /**
32  * Store server.xml Element Engine
33  *
34  * @author Peter Rossbach
35  */

36 public class StandardEngineSF extends StoreFactoryBase {
37
38     private static Log log = LogFactory.getLog(StandardEngineSF.class);
39
40     /**
41      * Store the specified Engine properties.
42      *
43      * @param aWriter
44      * PrintWriter to which we are storing
45      * @param indent
46      * Number of spaces to indent this element
47      * @param aEngine
48      * Object whose properties are being stored
49      *
50      * @exception Exception
51      * if an exception occurs while storing
52      */

53     public void storeChilds(PrintWriter JavaDoc aWriter, int indent, Object JavaDoc aEngine,
54             StoreDescription parentDesc) throws Exception JavaDoc {
55         if (aEngine instanceof StandardEngine) {
56             StandardEngine engine = (StandardEngine) aEngine;
57             // Store nested <Listener> elements
58
if (engine instanceof Lifecycle) {
59                 LifecycleListener listeners[] = ((Lifecycle) engine)
60                         .findLifecycleListeners();
61                 storeElementArray(aWriter, indent, listeners);
62             }
63
64             // Store nested <Realm> element
65
Realm realm = engine.getRealm();
66             if (realm != null) {
67                 Realm parentRealm = null;
68                 // TODO is this case possible? (see it a old Server 5.0 impl)
69
if (engine.getParent() != null) {
70                     parentRealm = engine.getParent().getRealm();
71                 }
72                 if (realm != parentRealm) {
73                     storeElement(aWriter, indent, realm);
74
75                 }
76             }
77
78             // Store nested <Valve> elements
79
if (engine instanceof Pipeline) {
80                 Valve valves[] = ((Pipeline) engine).getValves();
81                 storeElementArray(aWriter, indent, valves);
82
83             }
84             // store all <Host> elements
85
Container children[] = engine.findChildren();
86             storeElementArray(aWriter, indent, children);
87         }
88     }
89 }
Popular Tags