001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.catalina.ha;
019:
020: import org.apache.tomcat.util.digester.Digester;
021: import org.apache.tomcat.util.digester.RuleSetBase;
022:
023: /**
024: * <p><strong>RuleSet</strong> for processing the contents of a
025: * Cluster definition element. </p>
026: *
027: * @author Filip Hanik
028: * @author Peter Rossbach
029: * @version $Revision: 467222 $ $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
030: */
031:
032: public class ClusterRuleSet extends RuleSetBase {
033:
034: // ----------------------------------------------------- Instance Variables
035:
036: /**
037: * The matching pattern prefix to use for recognizing our elements.
038: */
039: protected String prefix = null;
040:
041: // ------------------------------------------------------------ Constructor
042:
043: /**
044: * Construct an instance of this <code>RuleSet</code> with the default
045: * matching pattern prefix.
046: */
047: public ClusterRuleSet() {
048:
049: this ("");
050:
051: }
052:
053: /**
054: * Construct an instance of this <code>RuleSet</code> with the specified
055: * matching pattern prefix.
056: *
057: * @param prefix Prefix for matching pattern rules (including the
058: * trailing slash character)
059: */
060: public ClusterRuleSet(String prefix) {
061: super ();
062: this .namespaceURI = null;
063: this .prefix = prefix;
064: }
065:
066: // --------------------------------------------------------- Public Methods
067:
068: /**
069: * <p>Add the set of Rule instances defined in this RuleSet to the
070: * specified <code>Digester</code> instance, associating them with
071: * our namespace URI (if any). This method should only be called
072: * by a Digester instance.</p>
073: *
074: * @param digester Digester instance to which the new Rule instances
075: * should be added.
076: */
077: public void addRuleInstances(Digester digester) {
078: //Cluster configuration start
079: digester.addObjectCreate(prefix + "Manager", null, // MUST be specified in the element
080: "className");
081: digester.addSetProperties(prefix + "Manager");
082: digester.addSetNext(prefix + "Manager", "setManagerTemplate",
083: "org.apache.catalina.ha.ClusterManager");
084:
085: digester.addObjectCreate(prefix + "Channel", null, // MUST be specified in the element
086: "className");
087: digester.addSetProperties(prefix + "Channel");
088: digester.addSetNext(prefix + "Channel", "setChannel",
089: "org.apache.catalina.tribes.Channel");
090:
091: String channelPrefix = prefix + "Channel/";
092: { //channel properties
093: digester.addObjectCreate(channelPrefix + "Membership",
094: null, // MUST be specified in the element
095: "className");
096: digester.addSetProperties(channelPrefix + "Membership");
097: digester.addSetNext(channelPrefix + "Membership",
098: "setMembershipService",
099: "org.apache.catalina.tribes.MembershipService");
100:
101: digester.addObjectCreate(channelPrefix + "Sender", null, // MUST be specified in the element
102: "className");
103: digester.addSetProperties(channelPrefix + "Sender");
104: digester.addSetNext(channelPrefix + "Sender",
105: "setChannelSender",
106: "org.apache.catalina.tribes.ChannelSender");
107:
108: digester.addObjectCreate(
109: channelPrefix + "Sender/Transport", null, // MUST be specified in the element
110: "className");
111: digester.addSetProperties(channelPrefix
112: + "Sender/Transport");
113: digester
114: .addSetNext(channelPrefix + "Sender/Transport",
115: "setTransport",
116: "org.apache.catalina.tribes.transport.MultiPointSender");
117:
118: digester.addObjectCreate(channelPrefix + "Receiver", null, // MUST be specified in the element
119: "className");
120: digester.addSetProperties(channelPrefix + "Receiver");
121: digester.addSetNext(channelPrefix + "Receiver",
122: "setChannelReceiver",
123: "org.apache.catalina.tribes.ChannelReceiver");
124:
125: digester.addObjectCreate(channelPrefix + "Interceptor",
126: null, // MUST be specified in the element
127: "className");
128: digester.addSetProperties(channelPrefix + "Interceptor");
129: digester.addSetNext(channelPrefix + "Interceptor",
130: "addInterceptor",
131: "org.apache.catalina.tribes.ChannelInterceptor");
132:
133: digester.addObjectCreate(channelPrefix
134: + "Interceptor/Member", null, // MUST be specified in the element
135: "className");
136: digester.addSetProperties(channelPrefix
137: + "Interceptor/Member");
138: digester.addSetNext(channelPrefix + "Interceptor/Member",
139: "addStaticMember",
140: "org.apache.catalina.tribes.Member");
141: }
142:
143: digester.addObjectCreate(prefix + "Valve", null, // MUST be specified in the element
144: "className");
145: digester.addSetProperties(prefix + "Valve");
146: digester.addSetNext(prefix + "Valve", "addValve",
147: "org.apache.catalina.Valve");
148:
149: digester.addObjectCreate(prefix + "Deployer", null, // MUST be specified in the element
150: "className");
151: digester.addSetProperties(prefix + "Deployer");
152: digester.addSetNext(prefix + "Deployer", "setClusterDeployer",
153: "org.apache.catalina.ha.ClusterDeployer");
154:
155: digester.addObjectCreate(prefix + "Listener", null, // MUST be specified in the element
156: "className");
157: digester.addSetProperties(prefix + "Listener");
158: digester.addSetNext(prefix + "Listener",
159: "addLifecycleListener",
160: "org.apache.catalina.LifecycleListener");
161:
162: digester.addObjectCreate(prefix + "ClusterListener", null, // MUST be specified in the element
163: "className");
164: digester.addSetProperties(prefix + "ClusterListener");
165: digester.addSetNext(prefix + "ClusterListener",
166: "addClusterListener",
167: "org.apache.catalina.ha.ClusterListener");
168: //Cluster configuration end
169: }
170:
171: }
|