![]() |
| |||||||||||||||||||||||||||||||||||||
| Resin 3.1 Documentation Examples Changes Overview Installation Configuration Quercus SOA/IoC JSP Servlets and Filters Admin (JMX) EJB Amber Security Performance Hessian XML and XSLT Third-party Troubleshooting/FAQ Command-Line Options Tags Common Tasks Relax Schema howto Config FAQ Scrapbook DB Scrapbook Environment tags <resin> <cluster> <server> Port tags <host> <web-app> <database> Session tags Rewrite tags Service tags Log tags EL variables and functions Control tags Tag Index |
Resin's configuration files provide support for certain control tags for conditional processing. Control StructuresThe resin.conf and web.xml configuration files can use control structures. The syntax of the control structures is deliberately similar to the control structures used in JSTL. These can be useful to create a resin.conf which works for both testing and deployment, depending on an environment parameter. When possible, users should avoid using the control tags when possible to keep their configuration files as simple as possible.
<web-app xmlns="http://caucho.com/ns/resin"
xmlns:resin="http://caucho.com/ns/resin/core">
<resin:choose>
<resin:when test="\${mode='development'}">
<resin:log>Development Mode</resin:log>
</resin:when>
<resin:when test="\${mode='deploy'}">
<resin:log>Deployment Mode</resin:log>
</resin:when>
<resin:otherwise>
<resin:log>Unknown Mode \${mode}</resin:log>
</resin:otherwise>
<resin:choose>
</web-app>
The source code for the control elements is found in com.caucho.config.core. resin:setresin:set adds an EL variable to the current context.
<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="http://caucho.com/ns/resin/core">
<resin:set name="root" value="/var/www">
<cluster id="app-tier">
<root-directory>${root}</root-directory>
...
</cluster>
</resin>
resin:ifresin:if executes part of the configuration file conditionally.
resin:chooseresin:choose implements an if, elsif, else.
resin:whenchild of resin:choose<resin:when> conditionally configures a block within a <resin:choose> block. If the matches, Resin will use the enclosed configuration.
resin:otherwisechild of resin:choose<resin:otherwise> is the catch-all configuration for a <resin:choose> block when none of the <resin:when> items match.
Special Directivesresin:logLogs a message to the given log file. The content of the element is the message.
<web-app xmlns="http://caucho.com/ns/resin">
<resin:log>Starting server \${server.name}</resin:log>
</web-app>
resin:importresin:import is used to read configuration information from another file. The target file is validated by a schema where the schema depends on the location of the resin:import. A resin:import in <server> will have a target with a top-level of <server>.
<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="http://caucho.com/ns/resin/core">
<cluster id="app-tier">
<web-app-default>
<resin:import path="WEB-INF/web.xml" optional="true"/>
<resin:import path="WEB-INF/resin-web.xml" optional="true"/>
</web-app-default>
</cluster>
</resin>
resin:envresin:env creates a new environment for a section of the configuration file. Some users may want to use this to create resources or databases with custom <class-loader> tags. resin:env is tricky and only required for some extraordinary circumstances. Using it correctly requires a good understanding of classloaders. Here is an example of a solution for the situation where a custom access
logging class requires an old version of a jar that the web application uses as
well. The requirement is that the In a normal circumstance, The following example solves the problem by using
<host id=''>
<resin:env>
<class-loader>
<library-loader path="/opt/lib/oldversion-Foo.jar"/>
</class-loader>
<access-log resin:type="example.MyAccessLog"/>
</resin:env>
...
<web-app>
<!-- WEB-INF/lib can contain Foo.jar and the classes are not overridden
by the classes in oldversion-Foo.jar.
-->
...
</web-app>
</host>
| |||||||||||||||||||||||||||||||||||||