tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@eng.sun.com
Subject Re: Context & Containers
Date Wed, 21 Jun 2000 21:57:17 GMT
> 
>     I was thinking about Contexts and Containers and their relationships.
> After a pair of hours browsing the sources I came to some level of
> understanding. I'm posting this explanation (altough I'm not sure it's
> completly right) hoping it will be useful for someone:

Great ! You can add this to the faq-o-matic. 

After this release goes out I'll spend some time documenting what I
know about tomcat.

I can add some of the reasons behind this Context/Container.

Context is clearly defined and represent all the informations we know
about a web application. 

Container represents a group of URLs ( a subset of a web application ),
and is similar with dir_struct in Apache. 

In tomcat 3.0 all mappings were hardcoded in Context, and we tried to
simplify Context and reduce it to something manageable. We also wanted to
"integrate" with apache - and allow some of the mapping to be done outside
tomcat.

We want Container to be used in all mapping-related actions, we want
context to be just a representation of global webapp properties. 

>     A Context has a corresponding Container (default Container) with null
> path and itself as context.


> This Container has a note with a hash that maps
> resources extensions to servlets in the Context to which it belongs. The
> Context has also a containers hash with containers for exact or prefix
> mapped servlets. 

The context stores all web-app informations, inclusing the (raw) mappings.

For each map it will notify all interceptors and allow them to store this
in their ( more efficient ) data structures. 

In particular, SimpleMapper uses a Hashtable for extension maps, and
associates this structure with the context ( as a note ). There is no
guarantee that SimpleMapper will be used and this structure will be
present !
SimpleMapper also uses a Hashtable mapping hostnames to PrefixMappers,
and inside PrefixMapper 2 Hashtables for exact and prefix mappings.
I hope to see a Tree-based mapper. 
 


> Exact, prefix and extension mapped servlets Containers are
> registered by the ContextManager addContainer method. This method is invoked
> by Context's addServletMapping. addContainer invokes addContainer in every
> ContextInterceptor bringing SimpleMapper1 (between its other brothers) into
> play. SimpleMapper1 registers the exact and prefix mappings in a
> PrefixMapper and the extension mappings in a note (that contains a hash, see
> above) indexed by ctExtMapNote in the default Container belonging to the
> Context belonging the Container to be mapped.

You should keep SimpleMapper's behavior separated - from tomcat core you
just have addServletMapping() that send notification that  a new map was
added, with the (uninterpreted) url pattern and the Handler (
ServletWrapper), encapsulated in a Container.

Container is used for all properties associated with urls, Handler is the
most common. Also - security constraints. In future we may allow per/url
interceptors.




Costin


Mime
View raw message