Source Code Cross Referenced for ItsNatImpl.java in  » Ajax » ItsNat » org » itsnat » impl » core » http » 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 » Ajax » ItsNat » org.itsnat.impl.core.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:          ItsNat Java Web Application Framework
003:          Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
004:          Author: Jose Maria Arranz Santamaria
005:
006:          This program is free software: you can redistribute it and/or modify
007:          it under the terms of the GNU Affero General Public License as published by
008:          the Free Software Foundation, either version 3 of the License, or
009:          (at your option) any later version. See the GNU Affero General Public 
010:          License for more details. See the copy of the GNU Affero General Public License
011:          included in this program. If not, see <http://www.gnu.org/licenses/>.
012:         */
013:
014:        package org.itsnat.impl.core.http;
015:
016:        import java.util.Collections;
017:        import org.itsnat.impl.core.ItsNatServletContextImpl;
018:        import java.util.HashMap;
019:        import java.util.Map;
020:        import javax.servlet.Servlet;
021:        import javax.servlet.ServletContext;
022:        import javax.servlet.http.HttpServlet;
023:        import org.itsnat.core.ItsNat;
024:        import org.itsnat.core.ItsNatException;
025:        import org.itsnat.core.ItsNatServlet;
026:        import org.itsnat.impl.core.ItsNatUserDataImpl;
027:
028:        /**
029:         *
030:         * @author jmarranz
031:         */
032:        public class ItsNatImpl extends ItsNat {
033:            protected static final ItsNatImpl SINGLETON = newInstance();
034:            protected Map servletContexts = new HashMap();
035:            protected Map features = Collections.synchronizedMap(new HashMap());
036:            protected ItsNatUserDataImpl userData = new ItsNatUserDataImpl(true);
037:
038:            // Xerces 2.6.2 (el que incluye la Sun JVM 1.5) tiene errores en las
039:            // HTMLCollection devueltas, no se a partir de qué versión deja de ternerlos, habría que determinarlo
040:            // Tomcat 5.5 pensado para la JVM 1.5 puede funcionar con la JVM 1.4 pero te dice que añadas unos jar
041:            // entre ellos está el Xerces 2.6.2
042:            // No estoy seguro si es este error: http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200405.mbox/%3C803282686.1085102760820.JavaMail.apache@nagoya%3E
043:            // Al menos se sabe que la versión Xerces 2.8.0 incluida en el Tomcat 5.5.17 (includo en el NetBeans 5.5)
044:            // sí funciona bien.
045:            // http://today.java.net/pub/n/Tomcat5.5.17Stable
046:
047:            protected static final boolean oldXerces; // tras el primer valor no cambia
048:
049:            static {
050:                String verStr = org.apache.xerces.impl.Version.getVersion();
051:
052:                // Ej. de formato: "Xerces-J 2.6.2"
053:                int pos = verStr.lastIndexOf(' ');
054:                verStr = verStr.substring(pos + 1); // Aisla el "2.6.2"
055:                int[] version = getFirstSecondVersion(verStr);
056:                oldXerces = ((version[0] * 10 + version[1]) < 28);
057:            }
058:
059:            public static ItsNat get() {
060:                return ItsNatImpl.SINGLETON;
061:            }
062:
063:            public static ItsNatImpl newInstance() {
064:                return new ItsNatImpl();
065:            }
066:
067:            public static int[] getFirstSecondVersion(String verStr) {
068:                // Formato esperado: "v1.v2.v3..."
069:                // Al menos debe existir v1.v2. en donde v1 y v2 son enteros
070:                int[] version = new int[2];
071:
072:                int pos = verStr.indexOf('.');
073:                version[0] = Integer.parseInt(verStr.substring(0, pos));
074:
075:                verStr = verStr.substring(pos + 1);
076:                pos = verStr.indexOf('.');
077:                if (pos != -1)
078:                    verStr = verStr.substring(0, pos);
079:                version[1] = Integer.parseInt(verStr);
080:                return version;
081:            }
082:
083:            /**
084:             * Creates a new instance of ItsNatImpl
085:             */
086:            public ItsNatImpl() {
087:            }
088:
089:            public ItsNatServletContextImpl getItsNatServletContextImpl(
090:                    ServletContext context) {
091:                // Hay un ServletContext por cada aplicación web (común a todos los servlets), por tanto
092:                // la instancia ItsNatServletContextImpl representaría una aplicación ItsNat
093:                synchronized (servletContexts) {
094:                    ItsNatServletContextImpl itsNatContext = (ItsNatServletContextImpl) servletContexts
095:                            .get(context);
096:                    if (itsNatContext == null) {
097:                        itsNatContext = new ItsNatServletContextImpl(context,
098:                                this );
099:                        servletContexts.put(context, itsNatContext);
100:                    }
101:                    return itsNatContext;
102:                }
103:            }
104:
105:            public ItsNatServlet createItsNatServlet(Servlet servlet) {
106:                // No se conoce otro tipo de Servlet que el Http
107:                return new ItsNatHttpServletImpl(this , (HttpServlet) servlet);
108:            }
109:
110:            public Object getFeature(String name) {
111:                return features.get(name);
112:            }
113:
114:            public Object setFeature(String name, Object value) {
115:                if (value == null)
116:                    throw new ItsNatException("Null value is not allowed");
117:                throw new ItsNatException("Feature not supported: \"" + name
118:                        + "\"");
119:                //return features.put(name,value);
120:            }
121:
122:            public static boolean isOldXerces() {
123:                return oldXerces;
124:            }
125:
126:            public boolean containsUserValueName(String name) {
127:                return userData.containsUserValueName(name);
128:            }
129:
130:            public Object getUserValue(String name) {
131:                return userData.getUserValue(name);
132:            }
133:
134:            public Object setUserValue(String name, Object value) {
135:                return userData.setUserValue(name, value);
136:            }
137:
138:            public Object removeUserValue(String name) {
139:                return userData.removeUserValue(name);
140:            }
141:
142:            public String[] getUserValueNames() {
143:                return userData.getUserValueNames();
144:            }
145:
146:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.