Source Code Cross Referenced for ItsNatServletConfigImpl.java in  » Ajax » ItsNat » org » itsnat » impl » core » 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 
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:        package org.itsnat.impl.core;
014:
015:        import java.text.DateFormat;
016:        import java.text.NumberFormat;
017:        import java.util.HashMap;
018:        import java.util.Map;
019:        import org.itsnat.core.ItsNatServletConfig;
020:        import org.itsnat.core.ItsNatServletContext;
021:        import javax.servlet.ServletConfig;
022:        import org.itsnat.core.ItsNatException;
023:        import org.itsnat.core.ClientErrorMode;
024:        import org.itsnat.core.SyncMode;
025:        import org.itsnat.core.UseGZip;
026:        import org.itsnat.impl.core.http.ItsNatImpl;
027:
028:        /**
029:         *
030:         * @author jmarranz
031:         */
032:        public class ItsNatServletConfigImpl extends ItsNatUserDataImpl
033:                implements  ItsNatServletConfig {
034:            protected ServletConfig servletConfig;
035:            protected ItsNatServletImpl servlet;
036:            protected ItsNatServletContextImpl servletContext;
037:            protected Map cacheDOMNodesByMime = new HashMap();
038:            protected int syncMode = SyncMode.ASYNC_HOLD;
039:            protected long ajaxTimeout = -1; // No timeout
040:            protected String defaultEncoding = "UTF-8"; // "ISO-8859-1" "UTF-8"
041:            protected boolean debugMode = false;
042:            protected int clientErrorMode = ClientErrorMode.SHOW_SERVER_AND_CLIENT_ERRORS;
043:            protected boolean loadScriptInline = true;
044:            protected boolean fastLoadMode = true;
045:            protected boolean nodeCacheEnabled = true;
046:            protected String jsFilesBasePath = "js";
047:            protected boolean addJSFiles = true;
048:            protected boolean autoBuildComponents = false;
049:            protected int useGZip = UseGZip.SCRIPT; // Sólo el JavaScript
050:            protected DateFormat dateFormat = DateFormat.getInstance();
051:            protected NumberFormat numberFormat = NumberFormat.getInstance();
052:            protected long evtDispMaxWait = 0;
053:            protected boolean referrerEnabled = false; // El sistema de referrers requiere que el programador lo necesite por lo que lo normal es que lo active en los templates que lo necesiten
054:            protected boolean referrerPushEnabled = false; // Idem referrerEnabled
055:            protected boolean ajaxEnabled = true;
056:            protected boolean scriptEnabled = true;
057:            protected boolean autoCleanEventListeners = true;
058:            protected boolean usePatternMarkupToRender = false;
059:            protected Map artifacts;
060:
061:            /** Creates a new instance of ItsNatServletConfigImpl */
062:            public ItsNatServletConfigImpl(ServletConfig servletConfig,
063:                    ItsNatServletImpl servlet) {
064:                super (true);
065:
066:                this .servletConfig = servletConfig;
067:                this .servlet = servlet;
068:
069:                ItsNatImpl itsNat = servlet.getItsNatImpl();
070:                this .servletContext = itsNat
071:                        .getItsNatServletContextImpl(servletConfig
072:                                .getServletContext());
073:
074:                cacheDOMNodesByMime.put("text/html", Boolean.TRUE);
075:                cacheDOMNodesByMime.put("application/xhtml+xml", Boolean.TRUE);
076:                cacheDOMNodesByMime.put("text/xml", Boolean.FALSE); // No tiene mucho sentido cachear nodos pues si generamos un XML todo seguramente será contenido generado y nada estático           
077:            }
078:
079:            public ServletConfig getServletConfig() {
080:                return servletConfig;
081:            }
082:
083:            public ItsNatServletContext getItsNatServletContext() {
084:                return servletContext;
085:            }
086:
087:            public ItsNatServletContextImpl getItsNatServletContextImpl() {
088:                return servletContext;
089:            }
090:
091:            public void checkIsAlreadyUsed() {
092:                servlet.checkIsAlreadyUsed();
093:            }
094:
095:            public int getDefaultSyncMode() {
096:                return syncMode;
097:            }
098:
099:            public void setDefaultSyncMode(int syncMode) {
100:                checkIsAlreadyUsed();
101:
102:                checkSyncMode(syncMode);
103:                this .syncMode = syncMode;
104:            }
105:
106:            public long getAJAXTimeout() {
107:                return ajaxTimeout;
108:            }
109:
110:            public void setAJAXTimeout(long timeout) {
111:                checkIsAlreadyUsed();
112:
113:                this .ajaxTimeout = timeout; // Un valor 0 o negativo es no usar el timeout
114:            }
115:
116:            public static void checkSyncMode(int syncMode) {
117:                //int ASYNC = 1;
118:                //int ASYNC_HOLD = 2;    
119:                //int SYNC  = 3; 
120:                if ((syncMode < SyncMode.ASYNC) || (syncMode > SyncMode.SYNC))
121:                    throw new ItsNatException("Bad sync mode: " + syncMode);
122:            }
123:
124:            public int getUseGZip() {
125:                return useGZip;
126:            }
127:
128:            public void setUseGZip(int value) {
129:                checkIsAlreadyUsed();
130:
131:                this .useGZip = value;
132:            }
133:
134:            public boolean isOnLoadCacheStaticNodes(String mime) {
135:                Boolean value = (Boolean) cacheDOMNodesByMime.get(mime);
136:                if (value == null)
137:                    return false;
138:                return value.booleanValue();
139:            }
140:
141:            public void setOnLoadCacheStaticNodes(String mime, boolean cache) {
142:                checkIsAlreadyUsed();
143:
144:                cacheDOMNodesByMime.put(mime, Boolean.valueOf(cache));
145:            }
146:
147:            public String getDefaultEncoding() {
148:                return defaultEncoding;
149:            }
150:
151:            public void setDefaultEncoding(String defaultEncoding) {
152:                checkIsAlreadyUsed();
153:
154:                this .defaultEncoding = defaultEncoding;
155:            }
156:
157:            public boolean isLoadScriptInline() {
158:                return loadScriptInline;
159:            }
160:
161:            public void setLoadScriptInline(boolean value) {
162:                checkIsAlreadyUsed();
163:
164:                this .loadScriptInline = value;
165:            }
166:
167:            public boolean isDebugMode() {
168:                return debugMode;
169:            }
170:
171:            public void setDebugMode(boolean debugMode) {
172:                checkIsAlreadyUsed();
173:
174:                this .debugMode = debugMode;
175:            }
176:
177:            public int getClientErrorMode() {
178:                return clientErrorMode;
179:            }
180:
181:            public void setClientErrorMode(int mode) {
182:                checkIsAlreadyUsed();
183:
184:                this .clientErrorMode = mode;
185:            }
186:
187:            public boolean isFastLoadMode() {
188:                return fastLoadMode;
189:            }
190:
191:            public void setFastLoadMode(boolean fastLoadMode) {
192:                checkIsAlreadyUsed();
193:
194:                this .fastLoadMode = fastLoadMode;
195:            }
196:
197:            public boolean isNodeCacheEnabled() {
198:                return nodeCacheEnabled;
199:            }
200:
201:            public void setNodeCacheEnabled(boolean nodeCacheEnabled) {
202:                checkIsAlreadyUsed();
203:
204:                this .nodeCacheEnabled = nodeCacheEnabled;
205:            }
206:
207:            public String getFrameworkScriptFilesBasePath() {
208:                return jsFilesBasePath;
209:            }
210:
211:            public void setFrameworkScriptFilesBasePath(String path) {
212:                checkIsAlreadyUsed();
213:
214:                this .jsFilesBasePath = path;
215:            }
216:
217:            public boolean isAddFrameworkScriptFiles() {
218:                return addJSFiles;
219:            }
220:
221:            public void setAddFrameworkScriptFiles(boolean value) {
222:                checkIsAlreadyUsed();
223:
224:                this .addJSFiles = value;
225:            }
226:
227:            public boolean isAutoBuildComponents() {
228:                return autoBuildComponents;
229:            }
230:
231:            public void setAutoBuildComponents(boolean autoBuildComponents) {
232:                checkIsAlreadyUsed();
233:
234:                this .autoBuildComponents = autoBuildComponents;
235:            }
236:
237:            public DateFormat getDefaultDateFormat() {
238:                return dateFormat;
239:            }
240:
241:            public void setDefaultDateFormat(DateFormat dateFormat) {
242:                checkIsAlreadyUsed();
243:
244:                this .dateFormat = dateFormat;
245:            }
246:
247:            public NumberFormat getDefaultNumberFormat() {
248:                return numberFormat;
249:            }
250:
251:            public void setDefaultNumberFormat(NumberFormat numberFormat) {
252:                checkIsAlreadyUsed();
253:
254:                this .numberFormat = numberFormat;
255:            }
256:
257:            public long getEventDispatcherMaxWait() {
258:                return evtDispMaxWait;
259:            }
260:
261:            public void setEventDispatcherMaxWait(long wait) {
262:                checkIsAlreadyUsed();
263:
264:                this .evtDispMaxWait = wait;
265:            }
266:
267:            public boolean isReferrerEnabled() {
268:                return referrerEnabled;
269:            }
270:
271:            public void setReferrerEnabled(boolean referrerEnabled) {
272:                checkIsAlreadyUsed();
273:
274:                this .referrerEnabled = referrerEnabled;
275:            }
276:
277:            public boolean isReferrerPushEnabled() {
278:                return referrerPushEnabled;
279:            }
280:
281:            public void setReferrerPushEnabled(boolean referrerPushEnabled) {
282:                checkIsAlreadyUsed();
283:
284:                this .referrerPushEnabled = referrerPushEnabled;
285:            }
286:
287:            public boolean isAJAXEnabled() {
288:                return ajaxEnabled;
289:            }
290:
291:            public void setAJAXEnabled(boolean enable) {
292:                checkIsAlreadyUsed();
293:
294:                this .ajaxEnabled = enable;
295:            }
296:
297:            public boolean isScriptingEnabled() {
298:                return scriptEnabled;
299:            }
300:
301:            public void setScriptingEnabled(boolean enabled) {
302:                checkIsAlreadyUsed();
303:
304:                this .scriptEnabled = enabled;
305:
306:                if (!enabled) {
307:                    setAJAXEnabled(false);
308:                    setFastLoadMode(true); // Pues el modo "slow" necesariamente necesita enviar JavaScript por los cambios en el DOM en tiempo de carga
309:                }
310:            }
311:
312:            public boolean isAutoCleanEventListeners() {
313:                return autoCleanEventListeners;
314:            }
315:
316:            public void setAutoCleanEventListeners(boolean enable) {
317:                checkIsAlreadyUsed();
318:
319:                this .autoCleanEventListeners = enable;
320:            }
321:
322:            public boolean isUsePatternMarkupToRender() {
323:                return usePatternMarkupToRender;
324:            }
325:
326:            public void setUsePatternMarkupToRender(
327:                    boolean usePatternMarkupToRender) {
328:                checkIsAlreadyUsed();
329:                this .usePatternMarkupToRender = usePatternMarkupToRender;
330:            }
331:
332:            public boolean hasArtifacts() {
333:                if (artifacts == null)
334:                    return false;
335:                return !artifacts.isEmpty();
336:            }
337:
338:            public Map getArtifactMap() {
339:                if (artifacts == null)
340:                    this .artifacts = new HashMap();
341:                return artifacts;
342:            }
343:
344:            public Object getArtifact(String name) {
345:                if (!hasArtifacts())
346:                    return null;
347:
348:                Map artifacts = getArtifactMap();
349:                return artifacts.get(name);
350:            }
351:
352:            public void registerArtifact(String name, Object value) {
353:                checkIsAlreadyUsed(); // Así evitamos sincronizar (sólo lectura)
354:
355:                Map artifacts = getArtifactMap();
356:                artifacts.put(name, value);
357:            }
358:
359:            public Object removeArtifact(String name) {
360:                checkIsAlreadyUsed(); // Así evitamos sincronizar (sólo lectura)
361:
362:                Map artifacts = getArtifactMap();
363:                return artifacts.remove(name);
364:            }
365:
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.