KickJava   Java API By Example, From Geeks To Geeks.

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


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.Cluster;
22 import org.apache.catalina.Container;
23 import org.apache.catalina.Lifecycle;
24 import org.apache.catalina.LifecycleListener;
25 import org.apache.catalina.Pipeline;
26 import org.apache.catalina.Realm;
27 import org.apache.catalina.Valve;
28 import org.apache.catalina.core.StandardHost;
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 /**
33  * Store server.xml Element Host
34  *
35  * @author Peter Rossbach
36  */

37 public class StandardHostSF extends StoreFactoryBase {
38
39     private static Log log = LogFactory.getLog(StandardHostSF.class);
40
41     /**
42      * Store the specified Host properties and childs
43      * (Listener,Alias,Realm,Valve,Cluster, Context)
44      *
45      * @param aWriter
46      * PrintWriter to which we are storing
47      * @param indent
48      * Number of spaces to indent this element
49      * @param aHost
50      * Host whose properties are being stored
51      *
52      * @exception Exception
53      * if an exception occurs while storing
54      */

55     public void storeChilds(PrintWriter JavaDoc aWriter, int indent, Object JavaDoc aHost,
56             StoreDescription parentDesc) throws Exception JavaDoc {
57         if (aHost instanceof StandardHost) {
58             StandardHost host = (StandardHost) aHost;
59             // Store nested <Listener> elements
60
if (host instanceof Lifecycle) {
61                 LifecycleListener listeners[] = ((Lifecycle) host)
62                         .findLifecycleListeners();
63                 storeElementArray(aWriter, indent, listeners);
64             }
65
66             // Store nested <Alias> elements
67
String JavaDoc aliases[] = host.findAliases();
68             getStoreAppender().printTagArray(aWriter, "Alias", indent + 2,
69                     aliases);
70
71             // Store nested <Realm> element
72
Realm realm = host.getRealm();
73             if (realm != null) {
74                 Realm parentRealm = null;
75                 if (host.getParent() != null) {
76                     parentRealm = host.getParent().getRealm();
77                 }
78                 if (realm != parentRealm) {
79                     storeElement(aWriter, indent, realm);
80                 }
81             }
82
83             // Store nested <Valve> elements
84
if (host instanceof Pipeline) {
85                 Valve valves[] = ((Pipeline) host).getValves();
86                 storeElementArray(aWriter, indent, valves);
87             }
88
89             // store all <Cluster> elements
90
Cluster cluster = host.getCluster();
91             if (cluster != null) {
92                 storeElement(aWriter, indent, cluster);
93             }
94
95             // store all <Context> elements
96
Container children[] = host.findChildren();
97             storeElementArray(aWriter, indent, children);
98         }
99     }
100
101 }
Popular Tags