alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Tomcat example source code file (engine.xml)

This example Tomcat source code file (engine.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Tomcat tags/keywords

access, catalina, engine, engine, filter, host, host, license, license, must, must, remote, the, valve

The Tomcat engine.xml source code

<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document [
  <!ENTITY project SYSTEM "project.xml">
]>
<document url="engine.html">

  &project;

  <properties>
    <author email="craigmcc@apache.org">Craig R. McClanahan
    <title>The Engine Container
  </properties>

<body>


<section name="Introduction">

  <p>The Engine element represents the entire request
  processing machinery associated with a particular Catalina
  <a href="service.html">Service.  It receives and processes
  <em>all requests from one or more Connectors,
  and returns the completed response to the Connector for ultimate
  transmission back to the client.</p>

  <p>Exactly one Engine element MUST be nested inside
  a <a href="service.html">Service element, following all of the
  corresponding Connector elements associated with this Service.</p>

</section>


<section name="Attributes">

  <subsection name="Common Attributes">

    <p>All implementations of Engine
    support the following attributes:</p>

    <attributes>

      <attribute name="backgroundProcessorDelay" required="false">
        <p>This value represents the delay in seconds between the 
        invocation of the backgroundProcess method on this engine and 
        its child containers, including all hosts and contexts. 
        Child containers will not be invoked if their delay value is not 
        negative (which would mean they are using their own processing 
        thread). Setting this to a positive value will cause 
        a thread to be spawn. After waiting the specified amount of time, 
        the thread will invoke the backgroundProcess method on this engine 
        and all its child containers. If not specified, the default value for
        this attribute is 10, which represent a 10 seconds delay.</p>
      </attribute>

      <attribute name="className" required="false">
        <p>Java class name of the implementation to use.  This class must
        implement the <code>org.apache.catalina.Engine interface.
        If not specified, the standard value (defined below) will be used.</p>
      </attribute>

      <attribute name="defaultHost" required="true">
        <p>The default host name, which identifies the
        <a href="host.html">Host that will process requests directed
        to host names on this server, but which are not configured in
        this configuration file.  This name MUST match the <code>name
        attributes of one of the <a href="host.html">Host elements
        nested immediately inside.</p>
      </attribute>

      <attribute name="jvmRoute" required="false">
        <p>Identifier which must be used in load balancing scenarios to enable
        session affinity. The identifier, which must be unique across all
        Tomcat 5 servers which participate in the cluster, will be appended to
        the generated session identifier, therefore allowing the front end
        proxy to always forward a particular session to the same Tomcat 5
        instance.</p>
      </attribute>

      <attribute name="name" required="true">
        <p>Logical name of this Engine, used in log and error messages. When
        using muliple <a href="service.html">Service elements in the same
        <a href="server.html">Server, each Engine MUST be assigned a unique
        name.</em>

</attribute> </attributes> </subsection> <subsection name="Standard Implementation"> <p>The standard implementation of Engine is <strong>org.apache.catalina.core.StandardEngine. It supports the following additional attributes (in addition to the common attributes listed above):</p> <attributes> </attributes> </subsection> </section> <section name="Nested Components"> <p>You can nest one or more Host elements inside this <strong>Engine element, each representing a different virtual host associated with this server. At least one <a href="host.html">Host is required, and one of the nested <a href="host.html">Hosts MUST have a name that matches the name specified for the <code>defaultHost attribute, listed above.

<p>You can optional nest a DefaultContext element inside this <strong>Engine element, to define the default characteristics of web applications that are automatically deployed.</p> <p>You can nest at most one instance of the following utility components by nesting a corresponding element inside your <strong>Engine element:</p> <ul> <li>Realm - Configure a realm that will allow its database of users, and their associated roles, to be shared across all <a href="host.html">Hosts and Contexts nested inside this Engine, unless overridden by a <a href="realm.html">Realm configuration at a lower level. </ul> </section> <section name="Special Features"> <subsection name="Logging"> <p>An engine is associated with the <code>org.apache.catalina.core.ContainerBase.[enginename] log category. Note that the brackets are actually part of the name, don't omit them.</p> </subsection> <subsection name="Access Logs"> <p>When you run a web server, one of the output files normally generated is an <em>access log
, which generates one line of information for each request processed by the server, in a standard format. Catalina includes an optional <a href="valve.html">Valve implementation that can create access logs in the same standard format created by web servers, or in any number of custom formats.</p> <p>You can ask Catalina to create an access log for all requests processed by an <a href="engine.html">Engine, <a href="host.html">Host, or Context by nesting a <a href="valve.html">Valve element like this:

<source> <Engine name="Standalone" ...> ... <Valve className="org.apache.catalina.valves.AccessLogValve" prefix="catalina_access_log." suffix=".txt" pattern="common"/> ... </Engine> </source> <p>See Access Log Valve for more information on the configuration attributes that are supported.</p> </subsection> <subsection name="Lifecycle Listeners"> <p>If you have implemented a Java object that needs to know when this <strong>Engine is started or stopped, you can declare it by nesting a <strong>Listener element inside this element. The class name you specify must implement the <code>org.apache.catalina.LifecycleListener interface, and it will be notified about the occurrence of the coresponding lifecycle events. Configuration of such a listener looks like this:</p> <source> <Engine name="Standalone" ...> ... <Listener className="com.mycompany.mypackage.MyListener" ... > ... </Engine> </source> <p>Note that a Listener can have any number of additional properties that may be configured from this element. Attribute names are matched to corresponding JavaBean property names using the standard property method naming patterns.</p> </subsection> <subsection name="Request Filters"> <p>You can ask Catalina to check the IP address, or host name, on every incoming request directed to the surrounding <a href="engine.html">Engine, Host, or <a href="context.html">Context element. The remote address or name will be checked against a configured list of "accept" and/or "deny" filters, which are defined using the Regular Expression syntax supported by the <a href="http://jakarta.apache.org/regexp/">Jakarta Regexp regular expression library. Requests that come from locations that are not accepted will be rejected with an HTTP "Forbidden" error. Example filter declarations:</p> <source> <Engine name="Standalone" ...> ... <Valve className="org.apache.catalina.valves.RemoteHostValve" allow="*.mycompany.com,www.yourcompany.com"/> <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.1.*"/> ... </Engine> </source> <p>See Remote Address Filter and <a href="valve.html#Remote Host Filter">Remote Host Filter for more information about the configuration options that are supported.</p> </subsection> </section> </body> </document>

Other Tomcat examples (source code examples)

Here is a short list of links related to this Tomcat engine.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.