Source Code Cross Referenced for XmlSelectorResolver.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » selector » 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 » Web Framework » rife 1.6.1 » com.uwyn.rife.selector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: XmlSelectorResolver.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.selector;
009:
010:        import com.uwyn.rife.resources.ResourceFinder;
011:        import java.net.URL;
012:
013:        /**
014:         * Looks up XML configuration file locations based on participant parameters.
015:         *
016:         * @author Geert Bevin (gbevin[remove] at uwyn dot com)
017:         * @author Steven Grimm (koreth[remove] at midwinter dot com)
018:         * @version $Revision: 3634 $
019:         * @since 1.0
020:         */
021:        public abstract class XmlSelectorResolver {
022:            /**
023:             * Returns an XML file location.
024:             * 
025:             * @param parameter
026:             * 	Parameter of the participant for this configuration file. This is a
027:             * 	comma-separated list of path names and XML selector class names;
028:             *  they are tried in order until one of them resolves to a resource
029:             *  that exists.
030:             * @param resourceFinder
031:             * 	Object that looks up resources on the classpath.
032:             * @param prefix
033:             * 	Configuration file prefix; or
034:             * <p><code>null</code> if none is needed
035:             * @since 1.0
036:             */
037:            public static String resolve(String parameter,
038:                    ResourceFinder resourceFinder, String prefix) {
039:                if (null == parameter)
040:                    throw new IllegalArgumentException("xmlPath can't be null.");
041:                if (0 == parameter.length())
042:                    throw new IllegalArgumentException(
043:                            "xmlPath can't be empty.");
044:                if (null == resourceFinder)
045:                    throw new IllegalArgumentException(
046:                            "resourceFinder can't be null.");
047:
048:                String result = null;
049:
050:                URL resource = null;
051:                for (String resourceName : parameter.split(",")) {
052:                    resource = resourceFinder.getResource(resourceName);
053:
054:                    // check if the xml file could be found
055:                    if (resource != null) {
056:                        result = resourceName;
057:                        break;
058:                    } else {
059:                        // it could not be found, try to see if it was a class name of a XmlSelector
060:                        // that is present in the classpath
061:                        Class klass = null;
062:                        try {
063:                            // try a complete classname
064:                            klass = Class.forName(resourceName);
065:                        } catch (ClassNotFoundException e) {
066:                            klass = null;
067:                        }
068:                        // try this package's prefix if the class couldn't be found
069:                        if (null == klass) {
070:                            try {
071:                                klass = Class.forName(XmlSelectorResolver.class
072:                                        .getPackage().getName()
073:                                        + "." + resourceName);
074:                            } catch (ClassNotFoundException e) {
075:                                klass = null;
076:                            }
077:                        }
078:                        // if the class was found, create an instance
079:                        if (klass != null) {
080:                            try {
081:                                Object instance = klass.newInstance();
082:                                if (instance instanceof  XmlSelector) {
083:                                    String path = ((XmlSelector) instance)
084:                                            .getXmlPath(prefix);
085:                                    resource = resourceFinder.getResource(path);
086:                                    if (resource != null) {
087:                                        result = path;
088:                                        break;
089:                                    }
090:                                }
091:                            } catch (InstantiationException e) {
092:                                continue;
093:                            } catch (IllegalAccessException e) {
094:                                continue;
095:                            }
096:                        }
097:                    }
098:                }
099:
100:                return result;
101:            }
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.