KickJava   Java API By Example, From Geeks To Geeks.

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


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.Valve;
22 import org.apache.catalina.cluster.CatalinaCluster;
23 import org.apache.catalina.cluster.ClusterDeployer;
24 import org.apache.catalina.cluster.ClusterReceiver;
25 import org.apache.catalina.cluster.ClusterSender;
26 import org.apache.catalina.cluster.MembershipService;
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29
30 /**
31  * Generate Cluster Element with Membership,Sender,Receiver,Deployer and
32  * ReplicationValve
33  *
34  * @author Peter Rossbach
35  */

36 public class CatalinaClusterSF extends StoreFactoryBase {
37
38     private static Log log = LogFactory.getLog(CatalinaClusterSF.class);
39
40     /**
41      * Store the specified Cluster childs.
42      *
43      * @param aWriter
44      * PrintWriter to which we are storing
45      * @param indent
46      * Number of spaces to indent this element
47      * @param aCluster
48      * Cluster 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 aCluster,
54             StoreDescription parentDesc) throws Exception JavaDoc {
55         if (aCluster instanceof CatalinaCluster) {
56             CatalinaCluster cluster = (CatalinaCluster) aCluster;
57
58             // Store nested <Membership> element
59
MembershipService service = cluster.getMembershipService();
60             if (service != null) {
61                 storeElement(aWriter, indent, service);
62             }
63             // Store nested <Sender> element
64
ClusterSender sender = cluster.getClusterSender();
65             if (sender != null) {
66                 storeElement(aWriter, indent, sender);
67             }
68             // Store nested <Receiver> element
69
ClusterReceiver receiver = cluster.getClusterReceiver();
70             if (receiver != null) {
71                 storeElement(aWriter, indent, receiver);
72             }
73             // Store nested <Deployer> element
74
ClusterDeployer deployer = cluster.getClusterDeployer();
75             if (deployer != null) {
76                 storeElement(aWriter, indent, deployer);
77             }
78             // Store nested <Valve> element
79
// ReplicationValve are not store at Hosts element, see
80
// Host transient child list!
81
Valve valve = cluster.getValve();
82             if (valve != null) {
83                 IStoreFactory elementFactory = getRegistry().findStoreFactory(
84                         valve.getClass());
85                 if (elementFactory != null) {
86                     StoreDescription desc = getRegistry().findDescription(
87                             valve.getClass());
88                     elementFactory.store(aWriter, indent, valve);
89                 }
90             }
91         }
92     }
93 }
Popular Tags