KickJava   Java API By Example, From Geeks To Geeks.

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


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.session.StandardManager;
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24
25 /**
26  * Store server.xml Manager element
27  *
28  * @author Peter Rossbach
29  */

30 public class ManagerSF extends StoreFactoryBase {
31
32     private static Log log = LogFactory.getLog(ManagerSF.class);
33
34     /**
35      * Store the only the Manager elements
36      *
37      * @see NamingResourcesSF#storeChilds(PrintWriter, int, Object,
38      * RegistryDescription)
39      */

40     public void store(PrintWriter JavaDoc aWriter, int indent, Object JavaDoc aElement)
41             throws Exception JavaDoc {
42         StoreDescription elementDesc = getRegistry().findDescription(
43                 aElement.getClass());
44         if (elementDesc != null && aElement instanceof StandardManager) {
45             StandardManager manager = (StandardManager) aElement;
46             if (!isDefaultManager(manager)) {
47                 if (log.isDebugEnabled())
48                     log.debug(sm.getString("factory.storeTag", elementDesc
49                             .getTag(), aElement));
50                 getStoreAppender().printIndent(aWriter, indent + 2);
51                 getStoreAppender().printTag(aWriter, indent + 2, manager,
52                         elementDesc);
53             }
54         } else {
55             if (log.isWarnEnabled())
56                 log.warn(sm.getString("factory.storeNoDescriptor", aElement
57                         .getClass()));
58         }
59     }
60
61     /**
62      * Is this an instance of the default <code>Manager</code> configuration,
63      * with all-default properties?
64      *
65      * @param manager
66      * Manager to be tested
67      */

68     protected boolean isDefaultManager(StandardManager smanager) {
69
70         if (!"SESSIONS.ser".equals(smanager.getPathname())
71                 || !"java.security.SecureRandom".equals(smanager
72                         .getRandomClass())
73                 || (smanager.getMaxActiveSessions() != -1)
74                 || !"MD5".equals(smanager.getAlgorithm())) {
75             return (false);
76         }
77         return (true);
78
79     }
80
81 }
Popular Tags