Source Code Cross Referenced for MbeansDescriptorsDigesterSource.java in  » Sevlet-Container » apache-tomcat-6.0.14 » org » apache » tomcat » util » modeler » modules » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Sevlet Container » apache tomcat 6.0.14 » org.apache.tomcat.util.modeler.modules 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.tomcat.util.modeler.modules;
019:
020:        import java.io.InputStream;
021:        import java.net.URL;
022:        import java.util.ArrayList;
023:        import java.util.List;
024:
025:        import org.apache.tomcat.util.digester.Digester;
026:        import org.apache.tomcat.util.modeler.Registry;
027:        import org.apache.juli.logging.Log;
028:        import org.apache.juli.logging.LogFactory;
029:
030:        public class MbeansDescriptorsDigesterSource extends ModelerSource {
031:            private static Log log = LogFactory
032:                    .getLog(MbeansDescriptorsDigesterSource.class);
033:
034:            Registry registry;
035:            String location;
036:            String type;
037:            Object source;
038:            List mbeans = new ArrayList();
039:            protected static Digester digester = null;
040:
041:            protected static Digester createDigester(Registry registry) {
042:
043:                Digester digester = new Digester();
044:                digester.setNamespaceAware(false);
045:                digester.setValidating(false);
046:                URL url = Registry
047:                        .getRegistry(null, null)
048:                        .getClass()
049:                        .getResource(
050:                                "/org/apache/tomcat/util/modeler/mbeans-descriptors.dtd");
051:                digester
052:                        .register(
053:                                "-//Apache Software Foundation//DTD Model MBeans Configuration File",
054:                                url.toString());
055:
056:                // Configure the parsing rules
057:                digester.addObjectCreate("mbeans-descriptors/mbean",
058:                        "org.apache.tomcat.util.modeler.ManagedBean");
059:                digester.addSetProperties("mbeans-descriptors/mbean");
060:                digester.addSetNext("mbeans-descriptors/mbean", "add",
061:                        "java.lang.Object");
062:
063:                digester.addObjectCreate("mbeans-descriptors/mbean/attribute",
064:                        "org.apache.tomcat.util.modeler.AttributeInfo");
065:                digester.addSetProperties("mbeans-descriptors/mbean/attribute");
066:                digester.addSetNext("mbeans-descriptors/mbean/attribute",
067:                        "addAttribute",
068:                        "org.apache.tomcat.util.modeler.AttributeInfo");
069:
070:                /*digester.addObjectCreate
071:                    ("mbeans-descriptors/mbean/attribute/descriptor/field",
072:                    "org.apache.tomcat.util.modeler.FieldInfo");
073:                digester.addSetProperties
074:                    ("mbeans-descriptors/mbean/attribute/descriptor/field");
075:                digester.addSetNext
076:                    ("mbeans-descriptors/mbean/attribute/descriptor/field",
077:                        "addField",
078:                    "org.apache.tomcat.util.modeler.FieldInfo");
079:                
080:                digester.addObjectCreate
081:                    ("mbeans-descriptors/mbean/constructor",
082:                    "org.apache.tomcat.util.modeler.ConstructorInfo");
083:                digester.addSetProperties
084:                    ("mbeans-descriptors/mbean/constructor");
085:                digester.addSetNext
086:                    ("mbeans-descriptors/mbean/constructor",
087:                        "addConstructor",
088:                    "org.apache.tomcat.util.modeler.ConstructorInfo");
089:                
090:                digester.addObjectCreate
091:                    ("mbeans-descriptors/mbean/constructor/descriptor/field",
092:                    "org.apache.tomcat.util.modeler.FieldInfo");
093:                digester.addSetProperties
094:                    ("mbeans-descriptors/mbean/constructor/descriptor/field");
095:                digester.addSetNext
096:                    ("mbeans-descriptors/mbean/constructor/descriptor/field",
097:                        "addField",
098:                    "org.apache.tomcat.util.modeler.FieldInfo");
099:                
100:                digester.addObjectCreate
101:                    ("mbeans-descriptors/mbean/constructor/parameter",
102:                    "org.apache.tomcat.util.modeler.ParameterInfo");
103:                digester.addSetProperties
104:                    ("mbeans-descriptors/mbean/constructor/parameter");
105:                digester.addSetNext
106:                    ("mbeans-descriptors/mbean/constructor/parameter",
107:                        "addParameter",
108:                    "org.apache.tomcat.util.modeler.ParameterInfo");
109:                
110:                digester.addObjectCreate
111:                    ("mbeans-descriptors/mbean/descriptor/field",
112:                    "org.apache.tomcat.util.modeler.FieldInfo");
113:                digester.addSetProperties
114:                    ("mbeans-descriptors/mbean/descriptor/field");
115:                digester.addSetNext
116:                    ("mbeans-descriptors/mbean/descriptor/field",
117:                        "addField",
118:                    "org.apache.tomcat.util.modeler.FieldInfo");
119:                 */
120:                digester.addObjectCreate(
121:                        "mbeans-descriptors/mbean/notification",
122:                        "org.apache.tomcat.util.modeler.NotificationInfo");
123:                digester
124:                        .addSetProperties("mbeans-descriptors/mbean/notification");
125:                digester.addSetNext("mbeans-descriptors/mbean/notification",
126:                        "addNotification",
127:                        "org.apache.tomcat.util.modeler.NotificationInfo");
128:
129:                digester
130:                        .addObjectCreate(
131:                                "mbeans-descriptors/mbean/notification/descriptor/field",
132:                                "org.apache.tomcat.util.modeler.FieldInfo");
133:                digester
134:                        .addSetProperties("mbeans-descriptors/mbean/notification/descriptor/field");
135:                digester
136:                        .addSetNext(
137:                                "mbeans-descriptors/mbean/notification/descriptor/field",
138:                                "addField",
139:                                "org.apache.tomcat.util.modeler.FieldInfo");
140:
141:                digester
142:                        .addCallMethod(
143:                                "mbeans-descriptors/mbean/notification/notification-type",
144:                                "addNotifType", 0);
145:
146:                digester.addObjectCreate("mbeans-descriptors/mbean/operation",
147:                        "org.apache.tomcat.util.modeler.OperationInfo");
148:                digester.addSetProperties("mbeans-descriptors/mbean/operation");
149:                digester.addSetNext("mbeans-descriptors/mbean/operation",
150:                        "addOperation",
151:                        "org.apache.tomcat.util.modeler.OperationInfo");
152:
153:                digester.addObjectCreate(
154:                        "mbeans-descriptors/mbean/operation/descriptor/field",
155:                        "org.apache.tomcat.util.modeler.FieldInfo");
156:                digester
157:                        .addSetProperties("mbeans-descriptors/mbean/operation/descriptor/field");
158:                digester.addSetNext(
159:                        "mbeans-descriptors/mbean/operation/descriptor/field",
160:                        "addField", "org.apache.tomcat.util.modeler.FieldInfo");
161:
162:                digester.addObjectCreate(
163:                        "mbeans-descriptors/mbean/operation/parameter",
164:                        "org.apache.tomcat.util.modeler.ParameterInfo");
165:                digester
166:                        .addSetProperties("mbeans-descriptors/mbean/operation/parameter");
167:                digester.addSetNext(
168:                        "mbeans-descriptors/mbean/operation/parameter",
169:                        "addParameter",
170:                        "org.apache.tomcat.util.modeler.ParameterInfo");
171:
172:                return digester;
173:
174:            }
175:
176:            public void setRegistry(Registry reg) {
177:                this .registry = reg;
178:            }
179:
180:            public void setLocation(String loc) {
181:                this .location = loc;
182:            }
183:
184:            /** Used if a single component is loaded
185:             *
186:             * @param type
187:             */
188:            public void setType(String type) {
189:                this .type = type;
190:            }
191:
192:            public void setSource(Object source) {
193:                this .source = source;
194:            }
195:
196:            public List loadDescriptors(Registry registry, String location,
197:                    String type, Object source) throws Exception {
198:                setRegistry(registry);
199:                setLocation(location);
200:                setType(type);
201:                setSource(source);
202:                execute();
203:                return mbeans;
204:            }
205:
206:            public void execute() throws Exception {
207:                if (registry == null) {
208:                    registry = Registry.getRegistry(null, null);
209:                }
210:
211:                InputStream stream = (InputStream) source;
212:
213:                if (digester == null) {
214:                    digester = createDigester(registry);
215:                }
216:
217:                synchronized (digester) {
218:
219:                    // Process the input file to configure our registry
220:                    try {
221:                        // Push our registry object onto the stack
222:                        digester.push(mbeans);
223:                        digester.parse(stream);
224:                    } catch (Exception e) {
225:                        log.error("Error digesting Registry data", e);
226:                        throw e;
227:                    } finally {
228:                        digester.reset();
229:                    }
230:
231:                }
232:
233:            }
234:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.