<!-- サンプル・サーバ構成ファイル -->
<!-- 構成要素は、互いに親子供関係の状態で入れ子になっています -->

<!-- "Server" は JVM環境に相当する一つだけの要素であり、1つ以上の
     "Service"要素を含んでいます。サーバは 指定のポートで、shutdown 
     コマンドを待ちます。

     注意:  "Server" はそれ自体 "Container" ではありません。したがって、
     このレベルに"Valves"あるいは"Loggers"のようなサブコンポーネントを
     定義してはなりません。
 -->

<Server port="8005" shutdown="SHUTDOWN" debug="0">


  <!-- JMX MBeans サポートを有効にするにはこれらの要素のコメントをはずして
       ください -->
  <!-- You may also configure カスタム・コンポーネント (例 Valves/Realms) by 
       including your own mbean-descriptor file(s), and setting the 
       "descriptors" attribute to point to a ';' seperated list of paths
       (in the ClassLoader sense) of files to add to the default list.
       e.g. descriptors="/com/myfirm/mypackage/mbean-descriptor.xml"
       mbean記述子ファイルの中にカスタム・コンポーネント (例 Values/Realms)を設定することができます。
  -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
            debug="0"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
            debug="0"/>

  <!-- Global JNDI resources -->
  <GlobalNamingResources>

    <!-- デモンストレーション目的のテスト項目 -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- UserDatabaseRealmによってユーザ認証に利用される、
         編集可能なユーザ・データベース  -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>

  </GlobalNamingResources>

  <!-- "Service" は単一の"Container"を共有する1つ以上の"Connectors"の集まり
       です。(その結果、コンテナー内にwebアプリケーションが見えます)
       通常は、そのコンテナーは"Engine"です。しかし、これは要求されません。

       注: "Service" はそれ自体 "Container" ではありません。したがって、
       このレベルに "Valves" あるいは "Loggers" のようなサブコンポーネントを
       定義してはなりません。
   -->

  <!-- Tomcat スタンドアロン・サービスの定義 -->
  <Service name="Catalina">

    <!-- "Connector" は、リクエストを受け取り、レスポンスを返す端点を表わ
         します。各コネクター(Connector)は、関連する"Container"(通常、Engine)
         に、リクエストを渡します。

         初期設定では port 8080 の非SSL HTTP/1.1 コネクタが有効になっています。
         次の操作をして、2番目のConnector項目のコメントをはずすことで、
         port 8443のSSL HTTP/1.1コネクタを有効にすることもできます。
         SSLのサポートには次の手順が必要です。(詳細については Tomcat 5 
         ドキュメンテーションの SSL Config HOWTO を参照してください):
         * もし、JDK 1.3 またはそれ以前であれば、JSSE 1.0.2以降をダウンロード、
           インストールして、JARファイルを"$JAVA_HOME/jre/lib/ext"の中に置いて
           ください。
         * 証明書とkeystore自身のパスワードの値を"changeit"として次のコマンド
           を実行します:
             %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
             $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)

         初期状態では、web アプリケーションが request.getRemoteHost() をcall
         するためにDNS検索が有効になっています。これは、パフォーマンスに悪影響
         を与えるので、"enableLookups"の項目を"false"にして、これを無効に
         することもできます。 DNS検索を無効にしたとき、request.getRemoteHost()
         は、リモート・クライアントのIPアドレスを文字列にしたものを返します。
    -->

    <!-- 非SSL Coyote HTTP/1.1 コネクタ(port 8080) の定義 -->
    <Connector port="8080"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000" 
               disableUploadTimeout="true" />
    <!-- メモ : コネクション・タイムアウトを無効にするには connectionTimeout
     の値を 0 に設定します。 -->
	
	<!-- メモ : gzip 圧縮を使うために、次のプロパティを設定できます:
	
			   compression="on" 
			   compressionMinSize="2048" 
			   noCompressionUserAgents="gozilla, traviata" 
			   compressableMimeType="text/html,text/xml"
	-->

    <!-- SSL Coyote HTTP/1.1 コネクタ(port 8443)の定義 -->
    <!--
    <Connector port="8443" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" debug="0" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Coyote/JK2 AJP 1.3 コネクタ(port 8009)の定義 -->
    <Connector port="8009" 
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />

    <!-- Proxied HTTP/1.1 コネクタ(port 8082)の定義 -->
    <!-- これを利用するための詳細は、proxy ドキュメンテーションを参照してく
         ださい。  -->
    <!--
    <Connector port="8082" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false"
               acceptCount="100" debug="0" connectionTimeout="20000"
               proxyPort="80" disableUploadTimeout="true" />
    -->

    <!-- Engineは、 全てのリクエストを処理する(Catalina内の)エントリー・
         ポイントを表します。 Tomcat stand alone エンジンの実装は、リクエスト
         (request)に含まれる HTTPヘッダを解析し、適したホスト(バーチャルホスト)
         へ処理を渡します。 -->

    <!-- JK/JK2でload-balancingをサポートするためにjvmRouteをセットすることが
         できます。例:
    <Engine name="Standalone" defaultHost="localhost" debug="0" jvmRoute="jvm1">         
    --> 
         
    <!-- コンテナ階層の最上位コンテナの定義 -->
    <Engine name="Catalina" defaultHost="localhost" debug="0">

      <!-- request dumper の値は、Tomcatのインスタンスが送受信するすべてのリク
           エストヘッダ、レスポンス・ヘッダとCookieの使いやすいデバッグ情報を
           ダンプします。特定のバーチャルホストまたはアプリケーションでのみ必
           要であれば、このエレメント(要素)を対応する <Host> または <Context>
           エントリーの中に記述してください。

           同様の構造は、サンプルアプリケーション中の"RequestDumperFilter" 
           フィルター をチェックアウトすることで、全ての Servlet 2.4コンテナ
           で利用できます。 (このフィルターのソースコードは
           "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters" にありま
           す).

           Request dumping は、初期設定では無効にされています。有効にするには
           次のエレメントのコメントを外してください。  -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- Global logger unless overridden at lower levels -->
      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="catalina_log." suffix=".txt"
              timestamp="true"/>

      <!-- このレルムがここにあるのは、インスタンスがグローバルに共有されるからです -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm. 
           このレルムはグローバルJNDIリソース内の"UserDatabase"キー以下に
           あるUserDatabaseの設定を使います。 -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 debug="0" resourceName="UserDatabase"/>

      <!-- Comment out the old realm but leave here for now in case we
           need to go back quickly -->
      <!--
      <Realm className="org.apache.catalina.realm.MemoryRealm" />
      -->

      <!-- Replace the above Realm with one of the following to get a Realm
           stored in a database and accessed via JDBC
           データベースにRealmを保存し、JDBCでアクセスして -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="org.gjt.mm.mysql.Driver"
          connectionURL="jdbc:mysql://localhost/authority"
         connectionName="test" connectionPassword="test"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="oracle.jdbc.driver.OracleDriver"
          connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
         connectionName="scott" connectionPassword="tiger"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm" debug="99"
             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
          connectionURL="jdbc:odbc:CATALINA"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!-- デフォルト・バーチャルホストの定義
           注意: XML Schema validation は、Xerces 2.2では動きません。
       -->
      <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

        <!-- Defines a cluster for this node,
             By defining this element, means that every manager will be changed.
             So when running a cluster, only make sure that you have webapps in there
             that need to be clustered and remove the other ones.
             A cluster has the following parameters:
             このノードのクラスターの定義,
             このエレメントを

             className = クラスター・クラスのフル名

             name = a descriptive name for your cluster, can be anything

             debug = デバッグ・レベル, higher means more output

             mcastAddr = マルチキャスト・アドレス, has to be the same for all the nodes

             mcastPort = マルチキャスト・ポート, has to be the same for all the nodes
             
             mcastBindAddr = bind the multicast socket to a specific address
             
             mcastTTL = マルチキャストTTL ブロードキャストを制限したいときのためのもの。
             
             mcastSoTimeout = マルチキャスト readtimeout 

             mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat

             mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received

             tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes 

             tcpListenAddress = the listen address (bind address) for TCP cluster request on this host, 
                                in case of multiple ethernet cards.
                                auto means that address becomes
                                InetAddress.getLocalHost().getHostAddress()

             tcpListenPort = TCP 待ち受けポート

             tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
                                  has a wakup bug in java.nio. Set to 0 for no timeout

             printToScreen = true means that managers will also print to std.out

             expireSessionsOnShutdown = true means that 

             useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
                            false means to replicate the session after each request.
                            false means that replication would work for the following piece of code:
                            <%
                            HashMap map = (HashMap)session.getAttribute("map");
                            map.put("key","value");
                            %>
             replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
                               * Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
                               * Synchronous means that the thread that executes the request, is also the
                               thread the replicates the data to the other nodes, and will not return until all
                               nodes have received the information.
                               * Asynchronous means that there is a specific 'sender' thread for each cluster node,
                               so the request thread will queue the replication request into a "smart" queue,
                               and then return to the client.
                               The "smart" queue is a queue where when a session is added to the queue, and the same session
                               already exists in the queue from a previous request, that session will be replaced
                               in the queue instead of replicating two requests. This almost never happens, unless there is a 
                               large network delay.
        -->             
        <!--
            When configuring for clustering, you also add in a valve to catch all the requests
            coming in, at the end of the request, the session may or may not be replicated.
            A session is replicated if and only if all the conditions are met:
            1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
            2. a session exists (has been created)
            3. the request is not trapped by the "filter" attribute

            The filter attribute is to filter out requests that could not modify the session,
            hence we don't replicate the session after the end of this request.
            The filter is negative, ie, anything you put in the filter, you mean to filter out,
            ie, no replication will be done on requests that match one of the filters.
            The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.

            filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
            ending with .gif and .js are intercepted.
        -->
        
        <!--
        <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
                 managerClassName="org.apache.catalina.cluster.session.DeltaManager"
                 expireSessionsOnShutdown="false"
                 useDirtyFlag="true">

            <Membership 
                className="org.apache.catalina.cluster.mcast.McastService"
                mcastAddr="228.0.0.4"
                mcastPort="45564"
                mcastFrequency="500"
                mcastDropTime="3000"/>

            <Receiver 
                className="org.apache.catalina.cluster.tcp.ReplicationListener"
                tcpListenAddress="auto"
                tcpListenPort="4001"
                tcpSelectorTimeout="100"
                tcpThreadCount="6"/>

            <Sender
                className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                replicationMode="pooled"/>

            <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
                   filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;"/>
        </Cluster>
        -->        



        <!-- Normally, users must authenticate themselves to each web app
             individually.  Uncomment the following entry if you would like
             a user to be authenticated the first time they encounter a
             resource protected by a security constraint, and then have that
             user identity maintained across *all* web applications contained
             in this virtual host. 
             普通、利用者は複数のweb appを個々に認証しなければならない。次の
             項目のコメントを外すと、ユーザが最初に保護されたリソースにアクセ
             スしたときに認証すると、*全て*のwebアプリケーション -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn"
                   debug="0"/>
        -->

        <!-- アクセスログは、この仮想ホストのすべてのリクエストを処理します。初期
             状態では、ログファイルは $CATALINA_HOME内の"logs" ディレクトリに作ら
             れます。"directory" 属性を指定することで、他のディレクトリにすること
             もできます。($CATALINA_HOMEに関連する)相対パスでも絶対パスでもどちら
             でも指定できます。
        -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
        -->

        <!-- Logger shared by all Contexts related to this virtual host.  By
             default (when using FileLogger), log files are created in the "logs"
             directory relative to $CATALINA_HOME.  If you wish, you can specify
             a different directory with the "directory" attribute.  Specify either a
             relative (to $CATALINA_HOME) or absolute path to the desired
             directory.-->
        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>

      </Host>

    </Engine>

  </Service>

</Server>
