Source Code Cross Referenced for CoadunationParser.java in  » Net » Coadunation_1.0.1 » com » rift » coad » lib » deployment » 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 » Net » Coadunation_1.0.1 » com.rift.coad.lib.deployment 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * CoadunationLib: The coaduntion implementation library.
003:         * Copyright (C) 2006  Rift IT Contracting
004:         * 
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation; either
008:         * version 2.1 of the License, or (at your option) any later version.
009:         * 
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         * 
015:         * You should have received a copy of the GNU Lesser General Public
016:         * License along with this library; if not, write to the Free Software
017:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
018:         *
019:         * XMLConfigurationException.java
020:         *
021:         * CoadunationParser.java
022:         *
023:         * This object is responsible for parsing the contents of the of the Coadunation
024:         * xml file.
025:         */
026:
027:        package com.rift.coad.lib.deployment;
028:
029:        // java imports
030:        import javax.xml.parsers.SAXParserFactory;
031:        import javax.xml.parsers.SAXParser;
032:        import org.xml.sax.InputSource;
033:        import org.xml.sax.helpers.DefaultHandler;
034:        import java.io.StringReader;
035:        import org.xml.sax.SAXException;
036:        import org.xml.sax.Attributes;
037:
038:        /**
039:         * The parser is responsible for parsing the Coadunation xml file so that it can
040:         * be deployed within the coadunation server.
041:         *
042:         * @author Brett Chaldecott
043:         */
044:        public class CoadunationParser {
045:
046:            /**
047:             * The inner class responsible for handling the contents of the Coadunation
048:             * xml source document.
049:             */
050:            public class CoadunationHandler extends DefaultHandler {
051:
052:                // the class static member variables
053:                private static final String COADUNATION = "coadunation";
054:                private static final String COADUNATION_VERSION = "version";
055:                private static final String COADUNATION_NAME = "name";
056:                private static final String DESCRIPTION = "description";
057:                private static final String WEB_SERVICES = "webservices";
058:                private static final String WEB_SERVICE = "webservice";
059:                private static final String PATH = "path";
060:                private static final String CLASSES = "classes";
061:                private static final String CACHE = "cache_by_key";
062:                private static final String CACHE_TIMEOUT = "cache_timeout";
063:                private static final String CLASS_NAME = "class";
064:                private static final String WSDL_PATH = "wsdl";
065:                private static final String ROLE = "role";
066:                private static final String USERNAME = "username";
067:                private static final String JMX_BEANS = "jmxbeans";
068:                private static final String BEAN = "bean";
069:                private static final String OBJECT_NAME = "objectName";
070:                private static final String BEANS = "beans";
071:                private static final String INTERFACE_NAME = "interface";
072:                private static final String BIND_NAME = "bindName";
073:                private static final String THREAD = "thread";
074:                private static final String THREAD_NUMBER = "number";
075:                private static final String TRANSACTION = "transaction";
076:
077:                // the xpdl information object
078:                private DeploymentInfo deploymentInfo = null;
079:
080:                // the processing variables
081:                private boolean inCoadunation = false;
082:                private boolean inDescription = false;
083:                private boolean inWebServices = false;
084:                private boolean inWebService = false;
085:                private boolean inPath = false;
086:                private boolean inInterface = false;
087:                private boolean inClassName = false;
088:                private boolean inClasses = false;
089:                private boolean inCache = false;
090:                private boolean inCacheTimeout = false;
091:                private boolean inWSDL = false;
092:                private boolean inRole = false;
093:                private boolean inUsername = false;
094:                private boolean inJMXBeans = false;
095:                private boolean inBean = false;
096:                private boolean inObjectName = false;
097:                private boolean inBeans = false;
098:                private boolean inBindName = false;
099:                private boolean inThread = false;
100:                private boolean inThreadNumber = false;
101:                private boolean inTransaction = false;
102:                private String inData = null;
103:
104:                // the temporary objects
105:                private WebServiceInfo webServiceInfo = null;
106:                private JMXBeanInfo jmxBeanInfo = null;
107:                private BeanInfo beanInfo = null;
108:                private DeploymentThreadInfo threadInfo = null;
109:
110:                /**
111:                 * The constructor of the XPDL Handler
112:                 */
113:                public CoadunationHandler(DeploymentInfo deploymentInfo) {
114:                    this .deploymentInfo = deploymentInfo;
115:                }
116:
117:                /**
118:                 * Parse the start of an element 
119:                 */
120:                public void startElement(String uri, String localName,
121:                        String qName, Attributes attributes)
122:                        throws SAXException {
123:                    // handle a package and retrieve the value information
124:                    if (qName.compareToIgnoreCase(COADUNATION) == 0) {
125:                        String version = (String) attributes
126:                                .getValue(COADUNATION_VERSION);
127:                        String name = (String) attributes
128:                                .getValue(COADUNATION_NAME);
129:                        if ((version == null) || (name == null)) {
130:                            throw new SAXException(
131:                                    "Failed to retrieve either the name or the version");
132:                        }
133:                        deploymentInfo.setVersion(version);
134:                        deploymentInfo.setName(name);
135:                        inCoadunation = true;
136:                    } else if (inCoadunation
137:                            && qName.compareToIgnoreCase(DESCRIPTION) == 0) {
138:                        inDescription = true;
139:                        inData = "";
140:                    }
141:                    // the web services section
142:                    else if (inCoadunation
143:                            && qName.compareToIgnoreCase(WEB_SERVICES) == 0) {
144:                        inWebServices = true;
145:                    } else if (inWebServices
146:                            && qName.compareToIgnoreCase(WEB_SERVICE) == 0) {
147:                        inWebService = true;
148:                        webServiceInfo = new WebServiceInfo();
149:                    } else if (inWebService
150:                            && qName.compareToIgnoreCase(PATH) == 0) {
151:                        inPath = true;
152:                        inData = new String();
153:                    } else if (inWebService
154:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
155:                        inClassName = true;
156:                        inData = new String();
157:                    } else if (inWebService
158:                            && qName.compareToIgnoreCase(WSDL_PATH) == 0) {
159:                        inWSDL = true;
160:                        inData = new String();
161:                    } else if (inWebService
162:                            && qName.compareToIgnoreCase(ROLE) == 0) {
163:                        inRole = true;
164:                        inData = new String();
165:                    } else if (inWebService
166:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
167:                        inTransaction = true;
168:                        inData = new String();
169:                    } else if (inWebService
170:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
171:                        inClasses = true;
172:                        inData = new String();
173:                    }
174:                    // the jmx section
175:                    else if (inCoadunation
176:                            && qName.compareToIgnoreCase(JMX_BEANS) == 0) {
177:                        inJMXBeans = true;
178:                    } else if (inJMXBeans
179:                            && qName.compareToIgnoreCase(BEAN) == 0) {
180:                        jmxBeanInfo = new JMXBeanInfo();
181:                        inBean = true;
182:                    } else if (inJMXBeans && inBean
183:                            && qName.compareToIgnoreCase(INTERFACE_NAME) == 0) {
184:                        inInterface = true;
185:                        inData = new String();
186:                    } else if (inJMXBeans && inBean
187:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
188:                        inClassName = true;
189:                        inData = new String();
190:                    } else if (inJMXBeans && inBean
191:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
192:                        inClasses = true;
193:                        inData = new String();
194:                    } else if (inJMXBeans && inBean
195:                            && qName.compareToIgnoreCase(CACHE) == 0) {
196:                        inCache = true;
197:                        inData = new String();
198:                    } else if (inJMXBeans && inBean
199:                            && qName.compareToIgnoreCase(CACHE_TIMEOUT) == 0) {
200:                        inCacheTimeout = true;
201:                        inData = new String();
202:                    } else if (inJMXBeans && inBean
203:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
204:                        inTransaction = true;
205:                        inData = new String();
206:                    } else if (inJMXBeans && inBean
207:                            && qName.compareToIgnoreCase(OBJECT_NAME) == 0) {
208:                        inObjectName = true;
209:                        inData = new String();
210:                    } else if (inJMXBeans && inBean
211:                            && qName.compareToIgnoreCase(BIND_NAME) == 0) {
212:                        inBindName = true;
213:                        inData = new String();
214:                    } else if (inJMXBeans && inBean
215:                            && qName.compareToIgnoreCase(ROLE) == 0) {
216:                        inRole = true;
217:                        inData = new String();
218:                    } else if (inJMXBeans && inBean
219:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
220:                        inUsername = true;
221:                        inData = new String();
222:                    } else if (inJMXBeans && inBean
223:                            && qName.compareToIgnoreCase(THREAD) == 0) {
224:                        inThread = true;
225:                        threadInfo = new DeploymentThreadInfo();
226:                    }
227:                    // coadunation beans
228:                    else if (inCoadunation
229:                            && qName.compareToIgnoreCase(BEANS) == 0) {
230:                        inBeans = true;
231:                    } else if (inBeans && qName.compareToIgnoreCase(BEAN) == 0) {
232:                        beanInfo = new BeanInfo();
233:                        inBean = true;
234:                    } else if (inBeans && inBean
235:                            && qName.compareToIgnoreCase(INTERFACE_NAME) == 0) {
236:                        inInterface = true;
237:                        inData = new String();
238:                    } else if (inBeans && inBean
239:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
240:                        inClassName = true;
241:                        inData = new String();
242:                    } else if (inBeans && inBean
243:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
244:                        inClasses = true;
245:                        inData = new String();
246:                    } else if (inBeans && inBean
247:                            && qName.compareToIgnoreCase(CACHE) == 0) {
248:                        inCache = true;
249:                        inData = new String();
250:                    } else if (inBeans && inBean
251:                            && qName.compareToIgnoreCase(CACHE_TIMEOUT) == 0) {
252:                        inCacheTimeout = true;
253:                        inData = new String();
254:                    } else if (inBeans && inBean
255:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
256:                        inTransaction = true;
257:                        inData = new String();
258:                    } else if (inBeans && inBean
259:                            && qName.compareToIgnoreCase(BIND_NAME) == 0) {
260:                        inBindName = true;
261:                        inData = new String();
262:                    } else if (inBeans && inBean
263:                            && qName.compareToIgnoreCase(ROLE) == 0) {
264:                        inRole = true;
265:                        inData = new String();
266:                    } else if (inBeans && inBean
267:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
268:                        inUsername = true;
269:                        inData = new String();
270:                    } else if (inBeans && inBean
271:                            && qName.compareToIgnoreCase(THREAD) == 0) {
272:                        inThread = true;
273:                        threadInfo = new DeploymentThreadInfo();
274:                    }
275:                    // setup the thread information
276:                    else if (((inBeans && inBean && inThread) || (inJMXBeans
277:                            && inBean && inThread))
278:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
279:                        inClassName = true;
280:                        inData = new String();
281:                    } else if (((inBeans && inBean && inThread) || (inJMXBeans
282:                            && inBean && inThread))
283:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
284:                        inUsername = true;
285:                        inData = new String();
286:                    } else if (((inBeans && inBean && inThread) || (inJMXBeans
287:                            && inBean && inThread))
288:                            && qName.compareToIgnoreCase(THREAD_NUMBER) == 0) {
289:                        inThreadNumber = true;
290:                        inData = new String();
291:                    }
292:
293:                }
294:
295:                /**
296:                 * Read in the characters
297:                 */
298:                public void characters(char[] ch, int start, int length) {
299:                    if (inDescription || inPath || inClassName || inClasses
300:                            || inWSDL || inRole || inObjectName || inInterface
301:                            || inBindName || inUsername || inThreadNumber
302:                            || inCache || inCacheTimeout || inTransaction) {
303:                        inData += new String(ch, start, length);
304:                    }
305:                }
306:
307:                /**
308:                 * Handle the end of an element
309:                 */
310:                public void endElement(String uri, String localName,
311:                        String qName) throws SAXException {
312:                    // handle a package and retrieve the value information
313:                    if (qName.compareToIgnoreCase(COADUNATION) == 0) {
314:                        inCoadunation = false;
315:                    } else if (inCoadunation
316:                            && qName.compareToIgnoreCase(DESCRIPTION) == 0) {
317:                        inDescription = false;
318:                        deploymentInfo.setDescription(inData.trim());
319:                        inData = "";
320:                    }
321:                    // the web services section
322:                    else if (inCoadunation
323:                            && qName.compareToIgnoreCase(WEB_SERVICES) == 0) {
324:                        inWebServices = false;
325:                    } else if (inWebServices
326:                            && qName.compareToIgnoreCase(WEB_SERVICE) == 0) {
327:                        if (webServiceInfo.isInitialized() == false) {
328:                            throw new SAXException(
329:                                    "The web service information has not been setup "
330:                                            + "correctly. Must contain [path][class][WSDL]"
331:                                            + "[role]");
332:                        }
333:                        deploymentInfo.addWebService(webServiceInfo);
334:                        inWebService = false;
335:                        inData = new String();
336:                    } else if (inWebService
337:                            && qName.compareToIgnoreCase(PATH) == 0) {
338:                        inPath = false;
339:                        webServiceInfo.setPath(inData.trim());
340:                        inData = new String();
341:                    } else if (inWebService
342:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
343:                        inClassName = false;
344:                        webServiceInfo.setClassName(inData.trim());
345:                        inData = new String();
346:                    } else if (inWebService
347:                            && qName.compareToIgnoreCase(WSDL_PATH) == 0) {
348:                        inWSDL = false;
349:                        webServiceInfo.setWSDLPath(inData.trim());
350:                        inData = new String();
351:                    } else if (inWebService
352:                            && qName.compareToIgnoreCase(ROLE) == 0) {
353:                        inRole = false;
354:                        webServiceInfo.setRole(inData.trim());
355:                        inData = new String();
356:                    } else if (inWebService
357:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
358:                        String transactionResult = inData.trim();
359:                        if (transactionResult.equalsIgnoreCase("yes")
360:                                || transactionResult.equalsIgnoreCase("true")) {
361:                            webServiceInfo.setTransaction(true);
362:                        }
363:                        inTransaction = false;
364:                        inData = new String();
365:                    } else if (inWebService
366:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
367:                        inClasses = false;
368:                        webServiceInfo.addToClasses(inData.trim());
369:                        inData = new String();
370:                    }
371:                    // the jmx section
372:                    else if (inCoadunation
373:                            && qName.compareToIgnoreCase(JMX_BEANS) == 0) {
374:                        inJMXBeans = false;
375:                    } else if (inJMXBeans
376:                            && qName.compareToIgnoreCase(BEAN) == 0) {
377:                        if (jmxBeanInfo.isInitialized() == false) {
378:                            throw new SAXException(
379:                                    "The JMX Bean information has not been setup "
380:                                            + "correctly. Must contain [class][objectName].");
381:                        }
382:                        deploymentInfo.addJmxBean(jmxBeanInfo);
383:                        inBean = false;
384:                    } else if (inJMXBeans && inBean && !inThread
385:                            && qName.compareToIgnoreCase(INTERFACE_NAME) == 0) {
386:                        jmxBeanInfo.setInterfaceName(inData.trim());
387:                        inInterface = false;
388:                    } else if (inJMXBeans && inBean && !inThread
389:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
390:                        jmxBeanInfo.setClassName(inData.trim());
391:                        inClassName = false;
392:                    } else if (inJMXBeans && inBean && !inThread
393:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
394:                        jmxBeanInfo.addClass(inData.trim());
395:                        inClasses = false;
396:                    } else if (inJMXBeans && inBean && !inThread
397:                            && qName.compareToIgnoreCase(CACHE) == 0) {
398:                        String cacheResult = inData.trim();
399:                        if (cacheResult.equalsIgnoreCase("yes")
400:                                || cacheResult.equalsIgnoreCase("true")) {
401:                            jmxBeanInfo.setCacheResults(true);
402:                        }
403:                        inCache = false;
404:                    } else if (inJMXBeans && inBean && !inThread
405:                            && qName.compareToIgnoreCase(CACHE_TIMEOUT) == 0) {
406:                        inCacheTimeout = false;
407:                        jmxBeanInfo.setCacheTimeout(Long.parseLong(inData
408:                                .trim()));
409:                    } else if (inJMXBeans && inBean && !inThread
410:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
411:                        String transactionResult = inData.trim();
412:                        if (transactionResult.equalsIgnoreCase("yes")
413:                                || transactionResult.equalsIgnoreCase("true")) {
414:                            jmxBeanInfo.setTransaction(true);
415:                        }
416:                        inTransaction = false;
417:                    } else if (inJMXBeans && inBean && !inThread
418:                            && qName.compareToIgnoreCase(OBJECT_NAME) == 0) {
419:                        jmxBeanInfo.setObjectName(inData.trim());
420:                        inObjectName = false;
421:                    } else if (inJMXBeans && inBean && !inThread
422:                            && qName.compareToIgnoreCase(BIND_NAME) == 0) {
423:                        jmxBeanInfo.setBindName(inData.trim());
424:                        inBindName = false;
425:                    } else if (inJMXBeans && inBean && !inThread
426:                            && qName.compareToIgnoreCase(ROLE) == 0) {
427:                        jmxBeanInfo.setRole(inData.trim());
428:                        inRole = false;
429:                    } else if (inJMXBeans && inBean && !inThread
430:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
431:                        jmxBeanInfo.setUsername(inData.trim());
432:                        inUsername = false;
433:                    } else if (inJMXBeans && inBean
434:                            && qName.compareToIgnoreCase(THREAD) == 0) {
435:                        if (threadInfo.isInitialized() == false) {
436:                            throw new SAXException(
437:                                    "Invalid threading information was supplied [class]"
438:                                            + "[username] and [number] must be supplied.");
439:                        }
440:                        jmxBeanInfo.addThreadInfo(threadInfo);
441:                        inThread = false;
442:                    }
443:                    // coadunation beans
444:                    else if (inCoadunation
445:                            && qName.compareToIgnoreCase(BEANS) == 0) {
446:                        inBeans = false;
447:                    } else if (inBeans && qName.compareToIgnoreCase(BEAN) == 0) {
448:                        if (beanInfo.isInitialized() == false) {
449:                            throw new SAXException(
450:                                    "The Coadunation bean information has not been setup "
451:                                            + "correctly. Must contain [interface][class]"
452:                                            + "[bindName][role].");
453:                        }
454:                        deploymentInfo.addBean(beanInfo);
455:                        inBean = false;
456:                    } else if (inBeans && inBean && !inThread
457:                            && qName.compareToIgnoreCase(INTERFACE_NAME) == 0) {
458:                        inInterface = false;
459:                        beanInfo.setInterfaceName(inData.trim());
460:                    } else if (inBeans && inBean && !inThread
461:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
462:                        inClassName = false;
463:                        beanInfo.setClassName(inData.trim());
464:                    } else if (inBeans && inBean && !inThread
465:                            && qName.compareToIgnoreCase(CLASSES) == 0) {
466:                        inClasses = false;
467:                        beanInfo.addClass(inData.trim());
468:                    } else if (inBeans && inBean && !inThread
469:                            && qName.compareToIgnoreCase(CACHE) == 0) {
470:                        String cacheResult = inData.trim();
471:                        if (cacheResult.equalsIgnoreCase("yes")
472:                                || cacheResult.equalsIgnoreCase("true")) {
473:                            beanInfo.setCacheResults(true);
474:                        }
475:                        inCache = false;
476:                    } else if (inBeans && inBean && !inThread
477:                            && qName.compareToIgnoreCase(CACHE_TIMEOUT) == 0) {
478:                        inCacheTimeout = false;
479:                        beanInfo.setCacheTimeout(Long.parseLong(inData.trim()));
480:                    } else if (inBeans && inBean && !inThread
481:                            && qName.compareToIgnoreCase(TRANSACTION) == 0) {
482:                        String transactionResult = inData.trim();
483:                        if (transactionResult.equalsIgnoreCase("yes")
484:                                || transactionResult.equalsIgnoreCase("true")) {
485:                            beanInfo.setTransaction(true);
486:                        }
487:                        inCache = false;
488:                    } else if (inBeans && inBean && !inThread
489:                            && qName.compareToIgnoreCase(BIND_NAME) == 0) {
490:                        inBindName = false;
491:                        beanInfo.setBindName(inData.trim());
492:                    } else if (inBeans && inBean && !inThread
493:                            && qName.compareToIgnoreCase(ROLE) == 0) {
494:                        inRole = false;
495:                        beanInfo.setRole(inData.trim());
496:                    } else if (inBeans && inBean && !inThread
497:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
498:                        beanInfo.setUsername(inData.trim());
499:                        inUsername = false;
500:                    } else if (inBeans && inBean
501:                            && qName.compareToIgnoreCase(THREAD) == 0) {
502:                        if (threadInfo.isInitialized() == false) {
503:                            throw new SAXException(
504:                                    "Invalid threading information was supplied [class]"
505:                                            + "[username] and [number] must be supplied.");
506:                        }
507:                        beanInfo.addThreadInfo(threadInfo);
508:                        inThread = false;
509:                    }
510:                    // setup the thread information
511:                    else if (((inBeans && inBean && inThread) || (inJMXBeans
512:                            && inBean && inThread))
513:                            && qName.compareToIgnoreCase(CLASS_NAME) == 0) {
514:                        threadInfo.setClassName(inData.trim());
515:                        inClassName = false;
516:                    } else if (((inBeans && inBean && inThread) || (inJMXBeans
517:                            && inBean && inThread))
518:                            && qName.compareToIgnoreCase(USERNAME) == 0) {
519:                        threadInfo.setUsername(inData.trim());
520:                        inUsername = false;
521:                    } else if (((inBeans && inBean && inThread) || (inJMXBeans
522:                            && inBean && inThread))
523:                            && qName.compareToIgnoreCase(THREAD_NUMBER) == 0) {
524:                        threadInfo.setThreadNumber(Integer.parseInt(inData
525:                                .trim()));
526:                        inThreadNumber = false;
527:                    }
528:                }
529:            }
530:
531:            // the class member variables
532:            private CoadunationHandler handler = null;
533:            private DeploymentInfo deploymentInfo = null;
534:
535:            /** 
536:             * Creates a new instance of CoadunationParser 
537:             *
538:             * @param sourceXML The source xml document.
539:             *
540:             * @throws DeploymentException
541:             */
542:            public CoadunationParser(String sourceXML)
543:                    throws DeploymentException {
544:                try {
545:                    deploymentInfo = new DeploymentInfo();
546:                    handler = new CoadunationHandler(deploymentInfo);
547:                    SAXParser parser = SAXParserFactory.newInstance()
548:                            .newSAXParser();
549:                    InputSource source = new InputSource(new StringReader(
550:                            sourceXML));
551:                    parser.parse(source, handler);
552:                } catch (Exception ex) {
553:                    throw new DeploymentException(
554:                            "Failed to parse the source xml document :"
555:                                    + ex.getMessage(), ex);
556:                }
557:            }
558:
559:            /**
560:             * The method to retrieve the deployment information.
561:             *
562:             * @return The object containing the deployment information.
563:             */
564:            public DeploymentInfo getDeploymentInfo() {
565:                return deploymentInfo;
566:            }
567:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.