⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config-env.xtp

📁 RESIN 3.2 最新源码
💻 XTP
📖 第 1 页 / 共 2 页
字号:
<document><header><product>resin</product><title>Environment: Class Loaders, Resources and JNDI</title><version>Resin 3.0</version><description><p>Resin organizes resources and classloaders into nested environments.Each environment context merges its own configuration with configurationinherited from the parent environment.  Each environment context: server,host, web-app, etc. may be configured with any of the environmentconfiguration tags.</p></description></header><body><localtoc/><s1 title="Classloaders"><s2 title="class-loader" occur="*" version="Resin 3.0" type="defun">  <parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.loader.DynamicLoader --><p>Adds dynamic classloaders to the current environment.</p><p>Each environment (&lt;server&gt;, &lt;host&gt;, &lt;web-app&gt;) etc,can add dynamic classloaders.  The environment will inherit the parentclassloaders.  Each &lt;class-loader&gt; is comprised of several implementingloader items: library-loader for WEB-INF/lib, compiling-loader forWEB-INF/classes, even make-loader for more complex auto-compilation.</p><example title="&lt;class-loader> in resin-web.xml">&lt;web-app xmlns="http://caucho.com/ns/resin"&gt;  &lt;prologue>    &lt;class-loader&gt;      &lt;compiling-loader path="WEB-INF/classes"/&gt;      &lt;library-loader path="WEB-INF/lib"/&gt;    &lt;/class-loader&gt;  &lt;/prologue>&lt;/web-app&gt;</example></s2><s2 title="compiling-loader" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents>  <!-- com.caucho.loader.CompilingLoader --><p>Configures an auto-compiling <var>WEB-INF/classes</var>-style class loader.</p><p>The compiling-loader will automatically compile Java code into .classfiles loading them.</p><deftable-childtags><tr><td>args</td><td>Additional arguments to be passed to the Java compiler. Resin 3.0</td><td>none</td></tr><tr><td>batch</td><td>If true, multiple changed *.java files will be compiled in a single batch. Resin 3.0.7</td><td>true</td></tr><tr><td>encoding</td><td>I18N encoding for the Java compiler. Since Resin 3.0</td><td>none</td></tr><tr><td>path</td><td>Filesystem path for the class loader.  Since Resin 3.0</td><td>required</td></tr><tr><td>source</td><td>Java source directory. Since Resin 3.0</td><td>value of path</td></tr><tr><td>require-source</td><td>If true, .class files without matching .java files will be deleted. Since Resin 3.0</td><td>false</td></tr></deftable-childtags></s2><s2 title="library-loader" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents><p>Configures a jar library, <var>WEB-INF/lib</var>-style class loader.</p><p>The library-loader will add jar files in its path to the current classpath.Jar files are recognized wihen they have a filename extension of<code>.jar</code> or <code>.zip</code>.</p><deftable-childtags><tr><td>path</td><td>Filesystem path for the class loader.  Since Resin 3.0</td><td>required</td></tr></deftable-childtags><p>See <a href="javadoc|com.caucho.loader.DirectoryLoader|"/>.</p></s2><s2 title="tree-loader" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents>  <!-- com.caucho.loader.TreeLoader --><p>Configures a jar library, <var>WEB-INF/lib</var>-style class loader similar to<a config-tag="library-loader"/>, but will also find <code>.jar</code> and<code>.zip</code> files in subdirectories.</p><deftable-childtags><tr><td>path</td><td>Filesystem path for the class loader.  Since Resin 3.0</td><td>required</td></tr></deftable-childtags><p>See <a href="javadoc|com.caucho.loader.TreeLoader|"/>.</p></s2><s2 title="make-loader" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents>  <!-- com.caucho.loader.MakeLoader --><p>Configures a custom make-style loader.</p></s2><s2 title="servlet-hack" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents><p>Use of servlet-hack is discouraged.  Using servlet-hack violatesthe JDK's classloader delegation model and canproduce surprising ClassCastExceptions.</p><p>servlet-hack reverses the normal class loader order.Instead of parent classloaders having priority, child classloadershave priority.</p></s2><s2 title="simple-loader" occur="*" version="Resin 3.0" type="defun">  <parents>class-loader</parents>  <!-- com.caucho.loader.SimpleLoader --><p>Configures a simple <var>classes</var>-style class loader.</p><p>.class files in the specified directory will be loaded without anyspecial compilation steps (in contrast with compiling-loader.)</p><deftable-childtags><tr><td>path</td><td>Filesystem path for the class loader.  Since Resin 3.0</td><td>required</td></tr><tr><td>prefix</td><td>Class package prefix to only load to a subset of classes. Resin 3.0</td><td>none</td></tr></deftable-childtags></s2></s1><s1 title="Clustering"><s2 title="cluster" occur="?" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.server.cluster.Cluster --><p>Configures a cluster of Resin servers for load balancing and sharingstate information.</p><p>Each cluster is a collection of Resin servers.The servers will share session information if the sessions are configuredfor &lt;cluster-store&gt;.</p><p>Each environment context is associated with a single cluster.  If nocluster is defined for the context, it defaults to the parent cluster.</p><p>Normally, the cluster will be configured in the &lt;server&gt; context,although a cluster could be defined in a web-app for finer load-balancing.Only clusters defined in the &lt;server&gt; context are used for listeningto ports.  Other clusters are only for outgoing load balancing.</p><deftable-childtags><tr><td>id</td><td>identifies the cluster for later reference.  Since Resin 3.0</td><td>none</td></tr><tr><td>srun</td><td>configures the srun port and protocol for a cluster server. Since Resin 3.0</td><td>none</td></tr><tr><td>cluster-group</td><td>specialized configuration for sub-clusters. Since Resin 3.0</td><td>none</td></tr><tr><td>cluster-ref</td><td>an identifier for a previous cluster-definition to use for the cluster.  Since Resin 3.0</td><td>none</td></tr></deftable-childtags><example>&lt;resin xmlns="http://caucho.com/ns/resin"&gt;&lt;server&gt;  &lt;cluster&gt;    &lt;srun id='a' port='6810'/&gt;    &lt;srun id='b' port='6811'/&gt;  &lt;/cluster&gt;  ...</example></s2><s2 title="cluster-definition" occur="*" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.server.cluster.ClusterDef --><p>Defines a cluster for later use by cluster-ref.</p><deftable-childtags><tr><td>id</td><td>identifies the cluster for later reference.  Since Resin 3.0</td><td>required</td></tr><tr><td>srun</td><td>configures the srun port and protocol for a cluster server. Since Resin 3.0</td><td>none</td></tr><tr><td>cluster-group</td><td>specialized configuration for sub-clusters. Since Resin 3.0</td><td>none</td></tr></deftable-childtags></s2></s1><s1 title="Resources"><s2 title="connector" occur="*" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.jca.ConnectorResource --><p>Configures a JCA resource adapter and itsassociated connection factories.</p><p>The resource adapter/connector  will have been added as a rarfile (see <a href="#resource-deploy">resource-deploy</a>.  The&lt;connector&gt; configures that rar resource.</p><example title="Connector Example">&lt;connector connector-name="Test Resource"&gt;  &lt;connection-factory jndi-name="eis/test"&gt;    &lt;init&gt;      &lt;value&gt;b&lt;/value&gt;    &lt;/init&gt;  &lt;/connection-factory&gt;&lt;/connector&gt;</example><deftable-childtags><tr><td>connector</td><td>Configures a connector</td><td>required</td></tr><tr><td>connector-name</td><td>Specifies the rar connector's display-name</td><td>required</td></tr><tr><td>resource-adapter</td><td>Configures the resource-adapter</td><td>optional</td></tr><tr><td>connection-factory</td><td>Configures a connection-factory</td><td>optional</td></tr><tr><td>jndi-name</td><td>JNDI name for a resource-adapter or connection-factory</td><td>required</td></tr><tr><td>type</td><td>For connectors with multiple connection-factories, specifies the connection-factory</td><td>optional</td></tr><tr><td>local-transaction-optimization</td><td>Enables the local transaction optimization. Resin 3.0.7</td><td>true</td></tr><tr><td>init</td><td>Bean-style initialization</td><td>optional</td></tr></deftable-childtags><def title="connector schema">element connector {  connector-name { string }  &amp; resource-adapter?  &amp; connection-factory*}element connection-factory {  jndi-name,  type?,  element init { any }?}element resource-adapter {  jndi-name,  element init { any }?}</def></s2><s2 title="database" occur="*" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.sql.DBPool --><p>Defines a database resource.</p><p>The <a href="config-database.xtp">database configuration</a> section hasmore details on the configuration.  A code pattern for using databasesis in a <a href="examples|db-jdbc/index.xtp">DataSource tutorial.</a></p><example>&lt;database jndi-name='jdbc/test_mysql'&gt;  &lt;driver     type="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"&gt;    &lt;url&gt;jdbc:mysql://localhost:3306/test&lt;/url&gt;    &lt;user&gt;&lt;/user&gt;    &lt;password&gt;&lt;/password&gt;  &lt;/driver&gt;&lt;/database&gt;</example></s2><s2 title="ejb-server" occur="*" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.ejb.EJBServer --><p>Configures an EJB/CMP server.  See the CMP configuration for more details.</p></s2><s2 title="env-entry" occur="*" version="Resin 3.0" type="defun"><parents>resin, server, host-default, host, web-app-default, web-app</parents>  <!-- com.caucho.config.types.EnvEntry --><p>Configures a JNDI scalar value for JNDI-based application configuration.</p><p>Some application beans prefer to retrieve configuration data from JNDI,including String, Integer, and Double constants.  env-entry configuresthat data in the current context.  As with other Resin configuration, thevalue can use JSP-EL expressions.</p><deftable-childtags><tr><td>env-entry-name</td><td>JNDI name to store the value.  Since Servlet 2.1</td><td>required</td></tr><tr><td>env-entry-type</td><td>Java type for the value.  Since Servlet 2.1</td><td>required</td></tr><tr><td>env-entry-value</td><td>Value to be stored.  Since Servlet 2.1</td><td>required</td></tr></deftable-childtags><p>The example configuration stores a string in java:comp/env/greeting.Following the J2EE spec, the env-entry-name is relative tojava:comp/env.  If the env-entry is in the &lt;host&gt; context, it willbe visible to all web-apps in the host.</p><example title="Example resin.xml fragment">&lt;env-entry&gt;  &lt;env-entry-name&gt;greeting&lt;/env-entry-name&gt;  &lt;env-entry-type&gt;java.lang.String&lt;/env-entry-type&gt;  &lt;env-entry-value&gt;Hello, World&lt;/env-entry-value&gt;&lt;/env-entry&gt;</example><p>The following servlet fragment is a typical use in a servlet.  Theservlet only looks up the variable once and stores it for later use.</p><example title="GreetingServlet.java">import java.io.*;import javax.naming.*;import javax.servlet.*;import javax.servlet.http.*;public class TestServlet extends HttpServlet {  private String greeting;  public void init()    throws ServletException  {    try {      Context env =         (Context) new InitialContext().lookup("java:comp/env");      greeting = (String) env.lookup("greeting");    } catch (NamingException e) {      throw new ServletException(e);    }  }  ...}</example><def title="env-entry schema">element env-entry {  (attribute env-entry-name { string } |    element env-entry-name { string }),  (attribute env-entry-type { string } |    element env-entry-type { string }),  (attribute env-entry-value { string } |    element env-entry-value { string })}</def></s2>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -