001: /*
002: License $Id: I_JoServletContextPeer.java,v 1.13 2005/03/15 03:47:31 hendriks73 Exp $
003:
004: Copyright (c) 2001-2005 tagtraum industries.
005:
006: LGPL
007: ====
008:
009: jo! is free software; you can redistribute it and/or
010: modify it under the terms of the GNU Lesser General Public
011: License as published by the Free Software Foundation; either
012: version 2.1 of the License, or (at your option) any later version.
013:
014: jo! is distributed in the hope that it will be useful,
015: but WITHOUT ANY WARRANTY; without even the implied warranty of
016: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017: Lesser General Public License for more details.
018:
019: You should have received a copy of the GNU Lesser General Public
020: License along with this library; if not, write to the Free Software
021: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
022:
023: For LGPL see <http://www.fsf.org/copyleft/lesser.txt>
024:
025:
026: Sun license
027: ===========
028:
029: This release contains software by Sun Microsystems. Therefore
030: the following conditions have to be met, too. They apply to the
031: files
032:
033: - lib/mail.jar
034: - lib/activation.jar
035: - lib/jsse.jar
036: - lib/jcert.jar
037: - lib/jaxp.jar
038: - lib/crimson.jar
039: - lib/servlet.jar
040: - lib/jnet.jar
041: - lib/jaas.jar
042: - lib/jaasmod.jar
043:
044: contained in this release.
045:
046: a. Licensee may not modify the Java Platform
047: Interface (JPI, identified as classes contained within the javax
048: package or any subpackages of the javax package), by creating additional
049: classes within the JPI or otherwise causing the addition to or modification
050: of the classes in the JPI. In the event that Licensee creates any
051: Java-related API and distribute such API to others for applet or
052: application development, you must promptly publish broadly, an accurate
053: specification for such API for free use by all developers of Java-based
054: software.
055:
056: b. Software is confidential copyrighted information of Sun and
057: title to all copies is retained by Sun and/or its licensors. Licensee
058: shall not modify, decompile, disassemble, decrypt, extract, or otherwise
059: reverse engineer Software. Software may not be leased, assigned, or
060: sublicensed, in whole or in part. Software is not designed or intended
061: for use in on-line control of aircraft, air traffic, aircraft navigation
062: or aircraft communications; or in the design, construction, operation or
063: maintenance of any nuclear facility. Licensee warrants that it will not
064: use or redistribute the Software for such purposes.
065:
066: c. Software is provided "AS IS," without a warranty
067: of any kind. ALL EXPRESS OR IMPLIED REPRESENTATIONS AND WARRANTIES,
068: INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
069: PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
070:
071: d. This License is effective until terminated. Licensee may
072: terminate this License at any time by destroying all copies of Software.
073: This License will terminate immediately without notice from Sun if Licensee
074: fails to comply with any provision of this License. Upon such termination,
075: Licensee must destroy all copies of Software.
076:
077: e. Software, including technical data, is subject to U.S.
078: export control laws, including the U.S. Export Administration Act and its
079: associated regulations, and may be subject to export or import regulations
080: in other countries. Licensee agrees to comply strictly with all such
081: regulations and acknowledges that it has the responsibility to obtain
082: licenses to export, re-export, or import Software. Software may not be
083: downloaded, or otherwise exported or re-exported (i) into, or to a national
084: or resident of, Cuba, Iraq, Iran, North Korea, Libya, Sudan, Syria or any
085: country to which the U.S. has embargoed goods; or (ii) to anyone on the
086: U.S. Treasury Department's list of Specially Designated Nations or the U.S.
087: Commerce Department's Table of Denial Orders.
088:
089:
090: Feedback
091: ========
092:
093: We encourage your feedback and suggestions and want to use your feedback to
094: improve the Software. Send all such feedback to:
095: <feedback@tagtraum.com>
096:
097: For more information on tagtraum industries and jo!
098: please see <http://www.tagtraum.com/>.
099:
100:
101: */
102: package com.tagtraum.jo;
103:
104: import com.tagtraum.framework.http.URI;
105: import com.tagtraum.framework.util.FactoryException;
106: import com.tagtraum.jo.builder.I_JoServletContextPeerBuilder;
107: import com.tagtraum.jo.jsp.JspEngine;
108: import com.tagtraum.jo.jsp.JspModel;
109: import com.tagtraum.jo.security.I_JoLoginConfig;
110: import com.tagtraum.jo.security.I_JoSecurityConstraint;
111: import com.tagtraum.jo.security.I_JoSecurityRole;
112: import com.tagtraum.jo.util.URIFilterMapper;
113: import com.tagtraum.jo.util.URIMapper;
114:
115: import javax.servlet.ServletException;
116: import javax.servlet.UnavailableException;
117: import javax.servlet.jsp.tagext.TagLibraryInfo;
118: import java.io.IOException;
119: import java.net.URL;
120: import java.net.URLClassLoader;
121: import java.util.Enumeration;
122: import java.util.Iterator;
123: import java.util.Locale;
124: import java.util.Set;
125:
126: /**
127: * Peer of a {@link I_JoServletContext}. The peer is a kind of
128: * serverside ServletContext. It is needed to manage the
129: * {@link I_JoServletModel}. A {@link I_JoServletModel} is the
130: * 'serverside' view of a Servlet.
131: * <p>
132: * Every <code>I_JoServletContextPeer</code> has one {@link I_JoServletContext}
133: * and many {@link I_JoServletModel}s. Each model has one {@link I_JoServletConfig}.
134: *
135: * @author <a href="mailto:hs@tagtraum.com">Hendrik Schreiber</a>
136: * @version 1.1beta1 $Id: I_JoServletContextPeer.java,v 1.13 2005/03/15 03:47:31 hendriks73 Exp $
137: * @see I_JoServletContext
138: * @see I_JoServletModel
139: * @see I_JoServletConfig
140: */
141: public interface I_JoServletContextPeer {
142:
143: /**
144: * Source-Version
145: */
146: public static String vcid = "$Id: I_JoServletContextPeer.java,v 1.13 2005/03/15 03:47:31 hendriks73 Exp $";
147:
148: /**
149: * Sets the name of this peer (webapp) and the host it belongs to. This
150: * method must be called right after the constructor and must inly be called
151: * once.
152: *
153: * @param aName Name of the peer
154: * @param aHost Virtual host
155: * @exception FactoryException if the instantiation of the
156: * <code>I_JoServletContextes</code> fails
157: * @see I_JoServletContext
158: */
159: public void init(String aName, I_JoHost aHost)
160: throws FactoryException;
161:
162: /**
163: * Returns the URI mapper for this peer.
164: */
165: public URIMapper getURIMapper();
166:
167: /**
168: * Returns the associated host.
169: *
170: * @return Host
171: */
172: public I_JoHost getHost();
173:
174: /**
175: * Adds a model to this peer.
176: *
177: * @param aModel the model to add.
178: */
179: public void addServletModel(I_JoServletModel aModel);
180:
181: /**
182: * Removes a model.
183: *
184: * @param aName the model to remove.
185: */
186: public void removeServletModel(String aName);
187:
188: /**
189: * Returns an Iterator over all registered models.
190: *
191: * @return iterator
192: */
193: public Iterator servletModels();
194:
195: /**
196: * Returns a {@link I_JoServletModel} for a request or null if no
197: * matching model exists.
198: *
199: * @param aRequest Request
200: * @return corresponding ServletModel or <code>null</code>.
201: */
202: public I_JoServletModel getServletModel(I_JoServletRequest aRequest)
203: throws ServletException;
204:
205: /**
206: * Returns a {@link I_JoServletModel} for a key or null if no matching model exists.
207: *
208: * @param aKey Key for a ServletModel.
209: * @return matching ServletModel or <code>null</code>.
210: */
211: public I_JoServletModel getServletModel(String aKey)
212: throws ServletException;
213:
214: /**
215: * Returns a {@link I_JoServletModel} for a request of null if none exists.
216: *
217: * @param aRequest Request
218: * @param aURI URI
219: * @return matching ServletModel or <code>null</code>.
220: */
221: public I_JoServletModel getServletModel(
222: I_JoServletRequest aRequest, String aURI)
223: throws ServletException;
224:
225: /**
226: * Returns a {@link I_JoServletModel} for a name or null if no matching
227: * model exists.
228: *
229: * @return corresponding <code>I_SeServletModel</code>
230: * or <code>null</code>.
231: */
232: public I_JoServletModel getNamedServletModel(String aName)
233: throws ServletException;
234:
235: /**
236: * Sets the default model used for this peer. If a
237: * Model was set before its {@link I_JoServletModel#unload()}-method is called.
238: *
239: * @param aModel the default model
240: */
241: public void setDefaultModel(I_JoServletModel aModel);
242:
243: /**
244: * Returns the default model.
245: *
246: * @return the default model
247: */
248: public I_JoServletModel getDefaultModel() throws ServletException;
249:
250: /**
251: * Indicates whether this peer has a default model.
252: */
253: public boolean hasDefaultModel();
254:
255: /**
256: * Sets whether servlets and JSP should be reloaded automatically.
257: *
258: * @param reload
259: */
260: public void setAutoReloadServlets(boolean reload);
261:
262: /**
263: * Indicates whether servlets and JSP should be reloaded automatically.
264: *
265: * @return true or false
266: */
267: public boolean isAutoReloadServlets();
268:
269: /**
270: * Indicates whether session should be saved to disc when the webapp
271: * is shut down.
272: */
273: public void setRestoreSessions(boolean restore);
274:
275: /**
276: * Indicates whether session should be saved to disc when the webapp
277: * is shut down.
278: */
279: public boolean isRestoreSessions();
280:
281: /**
282: * Returns the name of this ContextPeer.
283: *
284: * @return peer name
285: */
286: public String getName();
287:
288: /**
289: * Returns the associated ServletContext.
290: *
291: * @return Context of this peer.
292: */
293: public I_JoServletContext getServletContext();
294:
295: /**
296: * Returns a classloader for servlets
297: *
298: * @return URLClassLoader
299: */
300: public ClassLoader getClassLoader();
301:
302: /**
303: * Sets a classloader for servlets.
304: *
305: * @param aServletClassLoader
306: */
307: public void setClassLoader(ClassLoader aServletClassLoader);
308:
309: /**
310: * Returns an attribute of this peer.
311: *
312: * @param name Name of the attribute
313: * @return value of this attribute
314: */
315: public Object getAttribute(String name);
316:
317: /**
318: * Sets an attribute of this peer.
319: *
320: * @param aName Name of the attribute
321: * @param aValue attribute
322: */
323: public void setAttribute(String aName, Object aValue);
324:
325: /**
326: * Returns an enumeration of the attribute names.
327: *
328: * @return enumeration.
329: */
330: public Enumeration getAttributeNames();
331:
332: /**
333: * Removes an attribute.
334: *
335: * @param aName Name
336: */
337: public void removeAttribute(String aName);
338:
339: /**
340: * Returns a <code>String</code> containing the value of the named
341: * context-wide initialization parameter, or <code>null</code> if the
342: * parameter does not exist.<p>
343: *
344: * This method can make available configuration information useful
345: * to an entire "web application". For example, it can provide a
346: * webmaster's email address or the name of a system that holds
347: * critical data.
348: *
349: * @param name a <code>String</code> containing the name of the
350: * parameter whose value is requested
351: * @return a <code>String</code> containing the init value
352: */
353: public String getInitParameter(String name);
354:
355: /**
356: * Returns the names of the context's initialization parameters as an
357: * <code>Enumeration</code> of <code>String</code> objects, or an
358: * empty <code>Enumeration</code> if the context has no initialization
359: * parameters.
360: *
361: * @return an <code>Enumeration</code> of <code>String</code>
362: * objects containing the names of the context's initialization parameters
363: */
364: public Enumeration getInitParameterNames();
365:
366: /**
367: * Sets an initparameter.
368: *
369: * @param name name of the parameter
370: * @param value value of the parameter
371: */
372: public void setInitParameter(String name, String value);
373:
374: /**
375: * Removes an initparamater.
376: *
377: * @param name name of the parameter
378: *
379: * @return the removed value or null
380: */
381: public String removeInitParameter(String name);
382:
383: /**
384: * Destroys all ServletModels.
385: *
386: * @see I_JoServletModel#unload()
387: */
388: public void destroy();
389:
390: /**
391: * Returns the path this peer/context was mapped to.
392: *
393: * @return URIPath
394: */
395: public String getContextPath();
396:
397: /**
398: * Sets the path, this peer/context was mapped to.
399: *
400: * @param aURIPath
401: */
402: public void setContextPath(String aURIPath);
403:
404: /**
405: * Sets the base URL for a web application.
406: *
407: * @param aWebAppRoot
408: */
409: public void setWebAppRoot(URL aWebAppRoot);
410:
411: /**
412: * Returns the base URL for a web application.
413: *
414: * @return webAppRoot
415: */
416: public URL getWebAppRoot();
417:
418: /**
419: * Returns a URL for a URI.
420: *
421: * @return aURL
422: */
423: public URL getResource(String aURI);
424:
425: /**
426: * Returns a localized URL for a URI and a Locale
427: *
428: * @return aURL
429: */
430: public URL getResource(String aURI, Locale aLocale);
431:
432: /**
433: * Adds a localized resource loader.
434: *
435: * @param aLocale
436: * @param aDocumentRoot
437: */
438: public void addResourceLoader(Locale aLocale, URL aDocumentRoot);
439:
440: /**
441: * Removes a localized resource loader.
442: *
443: * @param aLocale
444: */
445: public void removeResourceLoader(Locale aLocale);
446:
447: /**
448: * Adds a mapping to this peer.
449: *
450: * @param aURLPattern
451: * @param aServletName
452: */
453: public void addServletMapping(String aURLPattern,
454: String aServletName);
455:
456: /**
457: * Adds a mime type mapping to this peer.
458: *
459: * @param anExtension an Extension like <code>".txt"</code>
460: * @param aMimeType a MimeType like <code>"text/html"</code>
461: */
462: public void addMimeType(String anExtension, String aMimeType);
463:
464: /**
465: * Returns a set of all registered Mime types and their extensions.
466: */
467: public Set mimeTypes();
468:
469: /**
470: * Returns a mime type for a pathname.
471: *
472: * @param aFilename a filename like <code>"ddjh/bla.txt"</code>
473: * @return aMimeType or <code>null</code>
474: */
475: public String getMimeType(String aFilename);
476:
477: /**
478: * Returns a localized resource loader.
479: *
480: * @param aLocale
481: */
482: public URLClassLoader getResourceLoader(Locale aLocale);
483:
484: /**
485: * Resturns the standard resourceloader.
486: */
487: public URLClassLoader getResourceLoader();
488:
489: /**
490: * Returns the {@link I_JoSessionContext} for this peer.
491: *
492: * @return Sessioncontext
493: */
494: public I_JoSessionContext getSessionContext();
495:
496: /**
497: * Adds an Error-Page to this Peer.
498: * The key is either an Integer-Object representing
499: * a statuscode or an exception type
500: *
501: * @param aKey Integer or exception type
502: * @param aURI the URI of the error page
503: */
504: public void addErrorPage(Object aKey, String aURI);
505:
506: /**
507: * Removes an Error-Page from this Peer.
508: * The key is either an Integer-Object representing
509: * a statuscode or an exception type
510: *
511: * @param aKey Integer or exception type
512: * @return the URI of the removed error page
513: */
514: public String removeErrorPage(Object aKey);
515:
516: /**
517: * Returns an Error-Page for a key.
518: * The key is either an Integer-Object representing
519: * a statuscode or an exception type
520: *
521: * @param aKey Integer or exception type
522: * @return the URI of the error page or <code>null</code>
523: */
524: public String getErrorPage(Object aKey);
525:
526: /**
527: * Sets the session timeout in minutes.
528: *
529: * @param minutes time in minutes
530: */
531: public void setSessionTimeout(int minutes);
532:
533: /**
534: * Returns the session timeout in minutes.
535: *
536: * @return time in minutes
537: */
538: public int getSessionTimeout();
539:
540: /**
541: * Sets the distributable flag.
542: *
543: * @param isDistributable
544: */
545: public void setDistributable(boolean isDistributable);
546:
547: /**
548: * Indicates whether the corresponding ServletContext is distributable.
549: *
550: * @return true or false
551: */
552: public boolean isDistributable();
553:
554: /**
555: * Removes a security-constraint.
556: *
557: * @param aSecurityConstraint SecurityConstraint to remove
558: */
559: public boolean removeSecurityConstraint(
560: I_JoSecurityConstraint aSecurityConstraint);
561:
562: /**
563: * Adds a the security-constraint.
564: *
565: * @param aSecurityConstraint a security constraint
566: */
567: public boolean addSecurityConstraint(
568: I_JoSecurityConstraint aSecurityConstraint);
569:
570: /**
571: * Returns an <code>Iterator</code> for the registered security-constraints.
572: *
573: * @return an Iterator
574: */
575: public Iterator getSecurityConstraints();
576:
577: /**
578: * Returns the corresponding security constraint or <code>null</code>
579: * if none apply.
580: *
581: * @return the constraint
582: */
583: public I_JoSecurityConstraint getSecurityConstraint(String aMethod,
584: String aURI);
585:
586: /**
587: * Translates a virtual path to a real path.
588: *
589: * @param path virtual path
590: * @return real path
591: */
592: public String getRealPath(String path);
593:
594: /**
595: * Sets the maximum number of sessions. A negative
596: * number indicates that there is no limit.
597: */
598: public void setMaxSessions(int aLimit);
599:
600: /**
601: * Returns the maximum number of sessions. A negative
602: * number indicates that there is no limit.
603: *
604: * @return max number of sessions
605: */
606: public int getMaxSessions();
607:
608: /**
609: * Returns the login-config.
610: *
611: * @return the login-config
612: */
613: public I_JoLoginConfig getLoginConfig();
614:
615: /**
616: * Sets the Login-Config associated with this peer.
617: *
618: * @param aLoginConfig a login config
619: */
620: public void setLoginConfig(I_JoLoginConfig aLoginConfig);
621:
622: /**
623: * Authentificates this request.
624: *
625: * @param aRequest the request
626: * @param aResponse the response
627: * @see I_JoSecurityConstraint
628: */
629: public void authentificate(I_JoServletRequest aRequest,
630: I_JoServletResponse aResponse) throws IOException,
631: ServletException;
632:
633: /**
634: * Adds a welcomefile.
635: *
636: * @param aFilename a filename
637: */
638: public void addWelcomeFile(String aFilename);
639:
640: /**
641: * Removes a welcomefile.
642: *
643: * @param aFilename
644: */
645: public boolean removeWelcomeFile(String aFilename);
646:
647: /**
648: * Returns an Enumeration of the filenames
649: *
650: * @return Enumeration of welcomfilenames
651: */
652: public Iterator welcomeFiles();
653:
654: /**
655: * Specifies whether this servlet context diallows the usage of cookies
656: * for keeping state.
657: *
658: * @param noSessionCookies
659: */
660: public void setNoSessionCookies(boolean noSessionCookies);
661:
662: /**
663: * Indicates whether this servlet context diallows the usage of cookies
664: * for keeping state.
665: *
666: * @return true, if only URL reqriting is allows to keep state (no cookies)
667: */
668: public boolean isNoSessionCookies();
669:
670: /**
671: * Sets the session cookie domain.
672: *
673: * @param aDomain the domain
674: */
675: public void setSessionCookieDomain(String aDomain);
676:
677: /**
678: * Returns the session cookie domain.
679: *
680: * @return the domain
681: */
682: public String getSessionCookieDomain();
683:
684: /**
685: * Returns the value for auto-internationalization.
686: *
687: * @return AutoInternationalization
688: */
689: public boolean getAutoInternationalization();
690:
691: /**
692: * Sets AutoInternationalization.
693: *
694: * @param anAutoInternationalization
695: */
696: public void setAutoInternationalization(
697: boolean anAutoInternationalization);
698:
699: /**
700: * Returns the set automapping.
701: *
702: * @return AutoMapping
703: */
704: public String getAutoMapping();
705:
706: /**
707: * Sets automapping.
708: *
709: * @param anAutoMapping
710: */
711: public void setAutoMapping(String anAutoMapping);
712:
713: /**
714: * Removes a security-role from this peer.
715: */
716: public I_JoSecurityRole removeSecurityRole(I_JoSecurityRole aRole);
717:
718: /**
719: * Adds a security-role to this peer.
720: */
721: public void addSecurityRole(I_JoSecurityRole aRole);
722:
723: /**
724: * Gets a security-role for a RoleName.
725: */
726: public I_JoSecurityRole getSecurityRole(String aRoleName);
727:
728: /**
729: * Gets a TagLibraryInfo object.
730: */
731: public TagLibraryInfo getTagLibraryInfo(String anURI,
732: String prefix, JspModel model) throws IOException;
733:
734: /**
735: * Gets a JoTagLib object for an absolute URI
736: */
737: public JoTagLib getTagLib(String anAbsURI);
738:
739: /**
740: * Removes a TagLib object for an absolute URI
741: */
742: public JoTagLib removeTagLib(String anAbsURI);
743:
744: /**
745: * Adds a TagLib.
746: */
747: public void addTagLib(JoTagLib aTagLib);
748:
749: /**
750: * Returns the JspEngine.
751: */
752: public JspEngine getJspEngine();
753:
754: /**
755: * Sets showIndex.
756: */
757: public void setShowIndex(boolean aShowIndex);
758:
759: /**
760: * Returns showIndex.
761: */
762: public boolean getShowIndex();
763:
764: /**
765: * Sets the JspEngine.
766: */
767: public void setJspEngine(JspEngine anEngine);
768:
769: /**
770: * Returns the FileTransferCompression.
771: */
772: public I_JoFileTransferCompression getFileTransferCompression();
773:
774: /**
775: * Sets the FileTransferCompression.
776: */
777: public void setFileTransferCompression(
778: I_JoFileTransferCompression aFileTransferCompression);
779:
780: /**
781: * Sets the Builder for this peer.
782: */
783: public void setBuilder(I_JoServletContextPeerBuilder builder);
784:
785: /**
786: * Gets the Builder for this peer.
787: */
788: public I_JoServletContextPeerBuilder getBuilder();
789:
790: /**
791: * Indicates whether a rebuild is necessary.
792: */
793: public boolean needsRebuild();
794:
795: /**
796: * Rebuilds the object.
797: */
798: public void rebuild();
799:
800: /**
801: * Sets whether the peer ios currently available.
802: */
803: public void setAvailable(boolean available);
804:
805: /**
806: * Indicates that the peer is not started, has been destroyed or is in the
807: * process of being destroyed.
808: */
809: public boolean isAvailable();
810:
811: /**
812: * Starts the webapp.
813: */
814: public void start();
815:
816: /**
817: * Returns a charset encoding for a locale.
818: *
819: * @param locale a locale
820: * @return encoding or null, if none is defined
821: */
822: public String getEncoding(Locale locale);
823:
824: public void addLocaleEncoding(Locale locale, String encoding);
825:
826: public ListenerSupport getListenerSupport();
827:
828: public void addFilterHolder(JoFilterHolder filterHolder);
829:
830: public void addURLPatternFilterMapping(String urlPattern,
831: String filterName);
832:
833: public URIFilterMapper getURIFilterMapper();
834:
835: public void addServletFilterMapping(String servletName,
836: String filterName);
837:
838: public JoFilterChain getFilterChain(I_JoServletRequest request,
839: String uri) throws UnavailableException;
840:
841: public Iterator filterHolders();
842:
843: public ModelMatch getServletModel(URI uri)
844: throws UnavailableException;
845: }
|