KickJava   Java API By Example, From Geeks To Geeks.

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


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.connector.Connector;
25 import org.apache.catalina.core.StandardService;
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 /**
30  * Store server.xml Element Service and all childs
31  * @author Peter Rossbach (pero@apache.org)
32  */

33 public class StandardServiceSF extends StoreFactoryBase {
34
35     private static Log log = LogFactory.getLog(StandardServiceSF.class);
36
37     /**
38      * Store Childs from this StandardService description
39      *
40      * @param aWriter
41      * @param indent
42      * @param aService
43      * @throws Exception
44      */

45     public void storeChilds(PrintWriter JavaDoc aWriter, int indent, Object JavaDoc aService,
46             StoreDescription parentDesc) throws Exception JavaDoc {
47         if (aService instanceof StandardService) {
48             StandardService service = (StandardService) aService;
49             // Store nested <Listener> elements
50
if (service instanceof Lifecycle) {
51                 LifecycleListener listeners[] = ((Lifecycle) service)
52                         .findLifecycleListeners();
53                 storeElementArray(aWriter, indent, listeners);
54             }
55
56             Connector connectors[] = service.findConnectors();
57             storeElementArray(aWriter, indent, connectors);
58
59             // Store nested <Engine> element (or other appropriate container)
60
Container container = service.getContainer();
61             if (container != null) {
62                 StoreDescription elementDesc = getRegistry().findDescription(
63                         container.getClass());
64                 if (elementDesc != null) {
65                     IStoreFactory factory = elementDesc.getStoreFactory();
66                     factory.store(aWriter, indent, container);
67                 }
68             }
69         }
70
71     }
72
73 }
Popular Tags