Source Code Cross Referenced for J2EEVersion.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » j2ee » 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 » EJB Server resin 3.1.5 » resin » com.caucho.j2ee 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * Caucho Technology permits modification and use of this file in
005:         * source and binary form ("the Software") subject to the Caucho
006:         * Developer Source License 1.1 ("the License") which accompanies
007:         * this file.  The License is also available at
008:         *   http://www.caucho.com/download/cdsl1-1.xtp
009:         *
010:         * In addition to the terms of the License, the following conditions
011:         * must be met:
012:         *
013:         * 1. Each copy or derived work of the Software must preserve the copyright
014:         *    notice and this notice unmodified.
015:         *
016:         * 2. Each copy of the Software in source or binary form must include
017:         *    an unmodified copy of the License in a plain ASCII text file named
018:         *    LICENSE.
019:         *
020:         * 3. Caucho reserves all rights to its names, trademarks and logos.
021:         *    In particular, the names "Resin" and "Caucho" are trademarks of
022:         *    Caucho and may not be used to endorse products derived from
023:         *    this software.  "Resin" and "Caucho" may not appear in the names
024:         *    of products derived from this software.
025:         *
026:         * This Software is provided "AS IS," without a warranty of any kind.
027:         * ALL EXPRESS OR IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
028:         * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
029:         * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
030:         *
031:         * CAUCHO TECHNOLOGY AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES
032:         * SUFFERED BY LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR
033:         * DISTRIBUTING SOFTWARE. IN NO EVENT WILL CAUCHO OR ITS LICENSORS BE LIABLE
034:         * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
035:         * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
036:         * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
037:         * INABILITY TO USE SOFTWARE, EVEN IF HE HAS BEEN ADVISED OF THE POSSIBILITY
038:         * OF SUCH DAMAGES.
039:         *
040:         * @author Sam
041:         */
042:
043:        package com.caucho.j2ee;
044:
045:        import com.caucho.config.ConfigException;
046:        import com.caucho.util.L10N;
047:
048:        import org.w3c.dom.DocumentType;
049:        import org.w3c.dom.Element;
050:
051:        /**
052:         * The J2EE version of a configuration file.
053:         */
054:        public enum J2EEVersion {
055:            J2EE12 {
056:                public boolean hasFeaturesOf(J2EEVersion version) {
057:                    return version == J2EE12;
058:                }
059:            },
060:
061:            J2EE13 {
062:                public boolean hasFeaturesOf(J2EEVersion version) {
063:                    return version == J2EE12 || version == J2EE13;
064:                }
065:            },
066:
067:            J2EE14 {
068:                public boolean hasFeaturesOf(J2EEVersion version) {
069:                    return version == J2EE12 || version == J2EE13
070:                            || version == J2EE14;
071:                }
072:            },
073:
074:            JAVAEE5 {
075:                public boolean hasFeaturesOf(J2EEVersion version) {
076:                    return version == J2EE12 || version == J2EE13
077:                            || version == J2EE14 || version == JAVAEE5;
078:                }
079:            },
080:
081:            RESIN {
082:                public boolean hasFeaturesOf(J2EEVersion version) {
083:                    return true;
084:                }
085:            };
086:
087:            private static final L10N L = new L10N(J2EEVersion.class);
088:
089:            public static final String J2EE_NAMESPACE = "http://java.sun.com/xml/ns/j2ee";
090:            public static final String JAVAEE_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
091:            public static final String RESIN_NAMESPACE = "http://caucho.com/ns/resin";
092:
093:            /**
094:             * Return a J2EEVersion based on the namespace, the version attribute,
095:             * and the doctype.
096:             *
097:             * @param top the top level element of a configuration file.
098:             */
099:            public static J2EEVersion getJ2EEVersion(Element top) {
100:                String version = top.getAttribute("version");
101:                String ns = top.getNamespaceURI();
102:
103:                if (version.length() > 0) {
104:                    if (ns == null)
105:                        throw new ConfigException(
106:                                L
107:                                        .l(
108:                                                "namespace is required because version is specified, either xmlns='{0}', xmlns='{1}', or xmlns='{2}'",
109:                                                RESIN_NAMESPACE,
110:                                                JAVAEE_NAMESPACE,
111:                                                J2EE_NAMESPACE));
112:
113:                    if (ns.equals(J2EE_NAMESPACE)) {
114:                        if (version.equals("1.4"))
115:                            return J2EE14;
116:                        else
117:                            throw new ConfigException(
118:                                    L
119:                                            .l(
120:                                                    "version must be '{0}' for namespace '{1}'",
121:                                                    "1.4", ns));
122:                    } else if (ns.equals(JAVAEE_NAMESPACE)) {
123:                        if (version.equals("5") || version.equals("5.0")
124:                                || version.equals("2.5")) // XXX For TCK emitted web.xmls
125:                            return JAVAEE5;
126:                        else
127:                            throw new ConfigException(
128:                                    L
129:                                            .l(
130:                                                    "version must be '{0}' for namespace '{1}'",
131:                                                    "5", ns));
132:                    } else if (ns.equals(RESIN_NAMESPACE)) {
133:                        return RESIN;
134:                    }
135:                } else if (ns != null) {
136:                    if (ns.equals(RESIN_NAMESPACE))
137:                        return RESIN;
138:
139:                    throw new ConfigException(
140:                            L
141:                                    .l(
142:                                            "unknown namespace '{0}', namespace must be one of xmlns='{1}', xmlns='{2}', or xmlns='{3}'",
143:                                            ns, RESIN_NAMESPACE,
144:                                            JAVAEE_NAMESPACE, J2EE_NAMESPACE));
145:                }
146:
147:                DocumentType doctype = top.getOwnerDocument().getDoctype();
148:
149:                if (doctype != null) {
150:                    String publicId = doctype.getPublicId();
151:
152:                    if (publicId != null) {
153:                        if (publicId.contains("1.3"))
154:                            return J2EE13;
155:                    }
156:                }
157:
158:                return J2EE12;
159:            }
160:
161:            /**
162:             * Returns true if this version is equal to or more recent than the
163:             * passed version.
164:             */
165:            abstract public boolean hasFeaturesOf(J2EEVersion version);
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.