<document>
<localtoc/>

Resin organizes its resources into a tree, rooted in the system classloader. Each Resin context is associated with a classloader, a JNDI context, and a set of resources (databases, JMS, EJB beans, etc.)

Child contexts inherit classes and resources from the parent contexts. For example, a database with a JNDI name "java:comp/env/jdbc/foo" belonging to the foo.com virtual host would be shared for all web-applications in that host.

When Resin detects class or configuration changes in a context, it will reload that context and all child contexts. This is how Resin reloads an application when a servlet changes.

Each web-app gets its own JNDI copy. So a web-app named /quercus and a web-app named /cmp could each use java:comp/env/jdbc/test for a database pool, but would use unique pools (probably using different databases.)

This separation keeps web-apps from stepping on each other's toes and also lets each virtual host use different databases.

The web-apps can share JNDI configuration from its host, and the hosts can share JNDI configuration from the global server. Each web-app copies the host JNDI tree, and each host copies the server JNDI tree. So the web-app can't affect the host's JNDI, but it can share the host's pools.

In Resin's configuration, the context determines where the JNDI will be shared. If the JNDI configuration is in the <host>, it will be shared across the entire host. If it's in the <web-app>, it will only be used in the web-app.

<deftable>
contextscope
http-servershared across all applications
hostshared across the virtual host
web-appspecific to the servlet application (.war)
</deftable> ... <host id='foo.com'> <database name='jdbc/foo'> <driver-class id="org.gjt.mm.mysql.Driver"/> <driver-url id="jdbc:mysql://localhost:3306/foo"/> </database> <web-app id='/quercus'> <database name='jdbc/quercus'. <driver-class id="org.gjt.mm.mysql.Driver"/> <driver-url id="jdbc:mysql://localhost:3306/quercus"/> </database> </web-app> </host> ...

In the previous example, the java:comp/env/jdbc/foo pool is shared across all web-apps in foo.com, but the java:comp/env/jdbc/quercus pool is only available in the /quercus web-app.

</document>