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.core;
015:
016: import java.text.DateFormat;
017: import java.text.NumberFormat;
018: import javax.servlet.ServletConfig;
019:
020: /**
021: * Is the wrapper object defined by ItsNat to wrap the <code>javax.servlet.ServletConfig</code> object.
022: *
023: * <p>The main use is to setup the default behavior of the servlet.</p>
024: *
025: * @author Jose Maria Arranz Santamaria
026: */
027: public interface ItsNatServletConfig extends ItsNatUserData {
028: /**
029: * Returns the servlet configuration object wrapped.
030: *
031: * @return the internal servlet configuration object.
032: */
033: public ServletConfig getServletConfig();
034:
035: /**
036: * Returns the application context.
037: *
038: * <p>This object instance is shared by all {@link ItsNatServlet}s
039: * defined by the application.</p>
040: *
041: * @return the application context.
042: */
043: public ItsNatServletContext getItsNatServletContext();
044:
045: /**
046: * Returns the encoding used. This encoding is used to render
047: * to text and in the header sent to clients.
048: *
049: * @return the encoding, UTF-8 by default.
050: * @see #setDefaultEncoding(String)
051: */
052: public String getDefaultEncoding();
053:
054: /**
055: * Sets the encoding used.
056: *
057: * @param encoding the new encoding.
058: * @see #getDefaultEncoding()
059: */
060: public void setDefaultEncoding(String encoding);
061:
062: /**
063: * Informs whether static nodes are serialized as text and globally cached when
064: * the template is loaded to save memory (it improves the performance too).
065: *
066: * <p>This cache flag is configured by MIME type.</p>
067: *
068: * @param mime the MIME type.
069: * @return true if caching is enabled. By default is true if mime is "text/html" or "application/xhtml+xml" else is false.
070: * @see #setOnLoadCacheStaticNodes(String,boolean)
071: */
072: public boolean isOnLoadCacheStaticNodes(String mime);
073:
074: /**
075: * Sets whether static nodes are serialized as text and globally cached when
076: * the template is loaded to save memory (it improves the performance too).
077: *
078: * @param mime the MIME type.
079: * @param cache true to enable the static node cache to the specified MIME.
080: * @see #isOnLoadCacheStaticNodes(String)
081: */
082: public void setOnLoadCacheStaticNodes(String mime, boolean cache);
083:
084: /**
085: * Informs whether the debug mode is enabled.
086: *
087: * <p>In debug mode the framework makes more checks to ensure is correctly used.</p>
088: *
089: * @return true if debug is enabled. False by default.
090: * @see #setDebugMode(boolean)
091: */
092: public boolean isDebugMode();
093:
094: /**
095: * Sets the debug mode.
096: *
097: * @param debugMode true to set debug mode.
098: * @see #isDebugMode()
099: */
100: public void setDebugMode(boolean debugMode);
101:
102: /**
103: * Returns the default client error mode.
104: *
105: * <p>This value specifies whether the browser catches JavaScript errors
106: * and if they are shown to the user using a JavaScript <code>alert</code> call.</p>
107: *
108: * <p>This feature only affects to (X)HTML documents not to fragments</p>
109: *
110: * @return the default client error mode. By default {@link ClientErrorMode#SHOW_SERVER_AND_CLIENT_ERRORS}
111: * @see #setClientErrorMode(int)
112: * @see ClientErrorMode
113: */
114: public int getClientErrorMode();
115:
116: /**
117: * Sets the default client error mode.
118: *
119: * @param mode the default client error mode.
120: * @see #getClientErrorMode()
121: */
122: public void setClientErrorMode(int mode);
123:
124: /**
125: * Returns the default synchronous mode of AJAX events.
126: *
127: * <p>This feature only affects to (X)HTML documents not to fragments</p>
128: *
129: * @return the synchronous mode. {@link SyncMode#ASYNC_HOLD} by default.
130: * @see #setDefaultSyncMode(int)
131: */
132: public int getDefaultSyncMode();
133:
134: /**
135: * Sets the default synchronous mode of AJAX events.
136: *
137: * @param syncMode the new synchronous mode.
138: * @see #getDefaultSyncMode()
139: */
140: public void setDefaultSyncMode(int syncMode);
141:
142: /**
143: * Returns the default timeout of asynchronous AJAX events.
144: *
145: * <p>This feature only affects to (X)HTML documents not to fragments
146: * and is ignored in synchronous AJAX events</p>
147: *
148: * <p>When an unfinished AJAX request takes more time than the specified timeout,
149: * the request is aborted.</p>
150: *
151: * @return the timeout of asynchronous AJAX events in miliseconds. -1 by default (no timeout).
152: * @see #setAJAXTimeout(long)
153: */
154: public long getAJAXTimeout();
155:
156: /**
157: * Sets the default timeout of asynchronous AJAX events.
158: *
159: * @param timeout the new timeout. If negative no timeout is defined.
160: * @see #getAJAXTimeout()
161: */
162: public void setAJAXTimeout(long timeout);
163:
164: /**
165: * Returns whether JavaScript code and/or markup sent to the client is
166: * automatically compressed if the browser accepts this encoding.
167: *
168: * <p>This feature only affects to documents not to fragments</p>
169: *
170: * @return the bitwise value containing whether gzip is used to encode JavaScript code and/or markup. By default JavaScript code is compressed.
171: * @see #setUseGZip(int)
172: */
173: public int getUseGZip();
174:
175: /**
176: * Sets whether JavaScript code and/or markup sent to the client is
177: * automatically compressed if the browser accepts this encoding.
178: *
179: * <p>A bitwise value must be used using {@link UseGZip} constants, for instance:
180: * <code>setUseGZip(UseGZip.MARKUP | UseGZip.SCRIPT)</code>.</p>
181: *
182: * @param value a bitwise value.
183: * @see #getUseGZip()
184: * @see UseGZip
185: */
186: public void setUseGZip(int value);
187:
188: /**
189: * Informs whether the initial JavaScript code is sent inline into the loaded page
190: * or is loaded externally.
191: *
192: * <p>This feature only affects to (X)HTML documents not to fragments</p>
193: *
194: * @return true if script is sent inline. True by default.
195: * @see #setLoadScriptInline(boolean)
196: */
197: public boolean isLoadScriptInline();
198:
199: /**
200: * Sets the initial JavaScript code is sent inline into the loaded page
201: * or is loaded externally.
202: *
203: * @param value true to sent inline.
204: * @see #isLoadScriptInline()
205: */
206: public void setLoadScriptInline(boolean value);
207:
208: /**
209: * Informs whether the fast load mode is enabled.
210: *
211: * <p>This feature only affects to (X)HTML documents not to fragments</p>
212: *
213: * @return true if fast mode is enabled. True by default.
214: * @see #setFastLoadMode(boolean)
215: */
216: public boolean isFastLoadMode();
217:
218: /**
219: * Sets whether fast load mode is used.
220: *
221: * @param fastLoadMode true to enable fast load.
222: * @see #isFastLoadMode()
223: */
224: public void setFastLoadMode(boolean fastLoadMode);
225:
226: /**
227: * Informs whether the speed oriented node cache is enabled.
228: *
229: * <p>This feature only affects to (X)HTML documents not to fragments</p>
230: *
231: * @return true if node cache is enabled. True by default.
232: * @see #setNodeCacheEnabled(boolean)
233: */
234: public boolean isNodeCacheEnabled();
235:
236: /**
237: * Sets whether the speed oriented node cache is enabled.
238: *
239: * @param enable true to enable node cache.
240: * @see #isNodeCacheEnabled()
241: */
242: public void setNodeCacheEnabled(boolean enable);
243:
244: /**
245: * Informs whether components are build automatically using the necessary
246: * markup declarations.
247: *
248: * <p>If this feature is enabled any component registered
249: * into the component manager and associated to a DOM element
250: * being removed from the tree is removed and disposed automatically.</p>
251: *
252: * <p>This feature only affects to documents not to fragments</p>
253: *
254: * @return true if automatic component build is enabled. False by default.
255: * @see #setAutoBuildComponents(boolean)
256: */
257: public boolean isAutoBuildComponents();
258:
259: /**
260: * Sets whether components are build automatically using the necessary
261: * markup declarations.
262: *
263: * @param value true to enable automatic component build.
264: * @see #isAutoBuildComponents()
265: */
266: public void setAutoBuildComponents(boolean value);
267:
268: /**
269: * Informs whether the necessary framework JavaScript files are included
270: * into the page automatically.
271: *
272: * <p>This feature only affects to (X)HTML documents not to fragments</p>
273: *
274: * @return true if framework files are included automatically. True by default.
275: * @see #setAddFrameworkScriptFiles(boolean)
276: */
277: public boolean isAddFrameworkScriptFiles();
278:
279: /**
280: * Sets whether the necessary framework JavaScript files are included
281: * into the page automatically.
282: *
283: * @param value true to include the framework files automatically.
284: * @see #isAddFrameworkScriptFiles()
285: */
286: public void setAddFrameworkScriptFiles(boolean value);
287:
288: /**
289: * Returns the relative web path directory where the necessary framework JavaScript files are located.
290: * This path only has sense if framework files are included automatically.
291: *
292: * <p>For instance: is the path is "js" framework files must be located in:
293: * http://<host>:<port>/<app>/js</p>
294: *
295: * <p>This feature only affects to (X)HTML documents not to fragments</p>
296: *
297: * @return the relative web path of framework files. By default is the "js" folder.
298: * @see #isAddFrameworkScriptFiles()
299: * @see #setFrameworkScriptFilesBasePath(String)
300: */
301: public String getFrameworkScriptFilesBasePath();
302:
303: /**
304: * Sets the relative web path where the necessary framework JavaScript files are located.
305: * This path only has sense if framework files are included automatically.
306: *
307: * @param path the relative web path of framework files.
308: * @see #isAddFrameworkScriptFiles()
309: */
310: public void setFrameworkScriptFilesBasePath(String path);
311:
312: /**
313: * Returns the default date format used by components such as
314: * {@link org.itsnat.comp.html.ItsNatHTMLInputTextFormatted}.
315: *
316: * <p>This feature only affects to documents not to fragments</p>
317: *
318: * @return the default data format. By default returns <code>DateFormat.getInstance()</code>.
319: * @see #setDefaultDateFormat(DateFormat)
320: */
321: public DateFormat getDefaultDateFormat();
322:
323: /**
324: * Sets the default date format used by components such as
325: * {@link org.itsnat.comp.html.ItsNatHTMLInputTextFormatted}.
326: *
327: * @param format the default data format.
328: * @see #getDefaultDateFormat()
329: */
330: public void setDefaultDateFormat(DateFormat format);
331:
332: /**
333: * Returns the default number format used by components such as
334: * {@link org.itsnat.comp.html.ItsNatHTMLInputTextFormatted}.
335: *
336: * <p>This feature only affects to documents not fragments</p>
337: *
338: * @return the default data format. By default returns <code>NumberFormat.getInstance()</code>.
339: * @see #setDefaultNumberFormat(NumberFormat)
340: */
341: public NumberFormat getDefaultNumberFormat();
342:
343: /**
344: * Sets the default data format used by components such as
345: * {@link org.itsnat.comp.html.ItsNatHTMLInputTextFormatted}.
346: *
347: * @param format the default data format.
348: * @see #getDefaultNumberFormat()
349: */
350: public void setDefaultNumberFormat(NumberFormat format);
351:
352: /**
353: * Returns the default max wait until a server fired event with
354: * {@link ItsNatDocument#dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event)}
355: * is processed by the client and returns.
356: *
357: * <p>This feature only affects to (X)HTML documents not fragments</p>
358: *
359: * @return the default max wait in milliseconds. By default is 0 (undefined).
360: * @see #setEventDispatcherMaxWait(long)
361: * @see ItsNatDocument#getItsNatNode(org.w3c.dom.Node)
362: */
363: public long getEventDispatcherMaxWait();
364:
365: /**
366: * Sets the default max wait until a server fired event with
367: * {@link ItsNatDocument#dispatchEvent(org.w3c.dom.events.EventTarget,org.w3c.dom.events.Event)}
368: * is processed by the client and returns.
369: *
370: * @param wait the default max wait in milliseconds.
371: * @see #getEventDispatcherMaxWait()
372: */
373: public void setEventDispatcherMaxWait(long wait);
374:
375: /**
376: * Informs whether referrer feature is enabled by default.
377: *
378: * <p>This feature only affects to (X)HTML documents not fragments (because requires AJAX)</p>
379: *
380: * <p>This feature only works if AJAX is enabled.</p>
381: *
382: * @return true if referrer is enabled. By default is false.
383: * @see #setReferrerEnabled(boolean)
384: * @see #isAJAXEnabled()
385: * @see ItsNatServletRequest#getItsNatDocumentReferrer()
386: */
387: public boolean isReferrerEnabled();
388:
389: /**
390: * Sets whether referrer feature is enabled by default.
391: *
392: * @param enabled if referrer is enabled.
393: * @see #isReferrerEnabled()
394: */
395: public void setReferrerEnabled(boolean enabled);
396:
397: /**
398: * Informs whether referrer "push" feature is enabled by default.
399: *
400: * <p>This feature only affects to documents not fragments</p>
401: *
402: * @return true if referrer "push" is enabled, if false no document can be accessed by the referrer.
403: * @see #setReferrerPushEnabled(boolean)
404: * @see #isReferrerEnabled()
405: * @see ItsNatDocument#addReferrerItsNatServletRequestListener(ItsNatServletRequestListener)
406: */
407: public boolean isReferrerPushEnabled();
408:
409: /**
410: * Sets whether referrer "push" feature is enabled by default.
411: *
412: * @param enabled if referrer "push" is enabled.
413: * @see #isReferrerPushEnabled()
414: */
415: public void setReferrerPushEnabled(boolean enabled);
416:
417: /**
418: * Informs whether AJAX events are enabled.
419: *
420: * <p>This feature only affects to (X)HTML documents not fragments.</p>
421: *
422: * @return true if AJAX is enabled. By default is true.
423: * @see #setAJAXEnabled(boolean)
424: */
425: public boolean isAJAXEnabled();
426:
427: /**
428: * Sets whether AJAX events are enabled.
429: *
430: * @param enabled if AJAX is enabled.
431: * @see #isAJAXEnabled()
432: */
433: public void setAJAXEnabled(boolean enabled);
434:
435: /**
436: * Informs whether JavaScript is enabled.
437: *
438: * <p>This feature only affects to (X)HTML documents not fragments.</p>
439: *
440: * @return true if JavaScript is enabled. By default is true.
441: * @see #setScriptingEnabled(boolean)
442: */
443: public boolean isScriptingEnabled();
444:
445: /**
446: * Sets whether JavaScript is enabled.
447: *
448: * <p>If JavaScript is disabled then AJAX is disabled too.</p>
449: *
450: * @param enabled if JavaScript is enabled.
451: * @see #isScriptingEnabled()
452: * @see #setAJAXEnabled(boolean)
453: */
454: public void setScriptingEnabled(boolean enabled);
455:
456: /**
457: * Informs whether the auto clean event listeners mode is enabled.
458: *
459: * <p>This feature only affects to (X)HTML documents not fragments.</p>
460: *
461: * @return true if enabled. By default is true.
462: * @see #setAutoCleanEventListeners(boolean)
463: */
464: public boolean isAutoCleanEventListeners();
465:
466: /**
467: * Sets whether the auto clean event listeners mode is enabled.
468: *
469: * @param enabled if auto clean event listeners is enabled.
470: * @see #isAutoCleanEventListeners()
471: */
472: public void setAutoCleanEventListeners(boolean enabled);
473:
474: /**
475: * Informs whether dom utils and components use by default the original
476: * (saved as pattern) markup to render.
477: *
478: * <p>This feature only affects to documents not fragments.</p>
479: *
480: * @return true if the original markup is used. False by default.
481: * @see #setUsePatternMarkupToRender(boolean)
482: */
483: public boolean isUsePatternMarkupToRender();
484:
485: /**
486: * Sets whether dom utils and components use by default the original
487: * (saved as pattern) markup to render.
488: *
489: * @param value true to enable the use of original markup to render.
490: * @see #isUsePatternMarkupToRender()
491: */
492: public void setUsePatternMarkupToRender(boolean value);
493:
494: /**
495: * Registers an artifact with the specified name.
496: *
497: * @param name the artifact name
498: * @param value the artifact.
499: * @see #getArtifact(String)
500: * @see #removeArtifact(String)
501: * @see org.itsnat.core.NameValue
502: */
503: public void registerArtifact(String name, Object value);
504:
505: /**
506: * Returns the artifact with the specified name.
507: *
508: * @param name the artifact name to look for.
509: * @return the artifact or null if not found.
510: * @see #registerArtifact(String,Object)
511: */
512: public Object getArtifact(String name);
513:
514: /**
515: * Removes the artifact with the specified name.
516: *
517: * @param name the artifact name to look for.
518: * @return the removed artifact.
519: * @see #registerArtifact(String,Object)
520: */
521: public Object removeArtifact(String name);
522:
523: }
|