KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.apache.catalina.storeconfig;
17
18 import java.io.PrintWriter JavaDoc;
19
20 import org.apache.catalina.deploy.NamingResources;
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 /**
25  * store server.xml GlobalNamingResource.
26  *
27  * @author Peter Rossbach
28  *
29  */

30 public class GlobalNamingResourcesSF extends StoreFactoryBase {
31     private static Log log = LogFactory.getLog(GlobalNamingResourcesSF.class);
32
33     /*
34      * Store with NamingResource Factory
35      *
36      * @see org.apache.catalina.storeconfig.IStoreFactory#store(java.io.PrintWriter,
37      * int, java.lang.Object)
38      */

39     public void store(PrintWriter JavaDoc aWriter, int indent, Object JavaDoc aElement)
40             throws Exception JavaDoc {
41
42         if (aElement instanceof NamingResources) {
43
44             StoreDescription elementDesc = getRegistry().findDescription(
45                     NamingResources.class.getName()
46                             + ".[GlobalNamingResources]");
47
48             if (elementDesc != null) {
49                 getStoreAppender().printIndent(aWriter, indent + 2);
50                 getStoreAppender().printOpenTag(aWriter, indent + 2, aElement,
51                         elementDesc);
52                 NamingResources resources = (NamingResources) aElement;
53                 StoreDescription resourcesdesc = getRegistry().findDescription(
54                         NamingResources.class.getName());
55                 if (resourcesdesc != null) {
56                     resourcesdesc.getStoreFactory().store(aWriter, indent + 2,
57                             resources);
58                 } else {
59                     if(log.isWarnEnabled())
60                         log.warn("Can't find NamingRsources Store Factory!");
61                 }
62                     
63                 getStoreAppender().printIndent(aWriter, indent + 2);
64                 getStoreAppender().printCloseTag(aWriter, elementDesc);
65             } else {
66                 if (log.isWarnEnabled())
67                     log.warn("Descriptor for element" + aElement.getClass()
68                             + " not configured!");
69             }
70         } else {
71             if (log.isWarnEnabled())
72                 log.warn("wrong element " + aElement.getClass());
73
74         }
75     }
76 }
77
78
Popular Tags