01 <Context path="/appfuse" docBase="appfuse" debug="99" reloadable="true">
02 <Logger className="org.apache.catalina.logger.FileLogger"
03 prefix="appfuse_log." suffix=".txt" timestamp="true"/>
04
05 <Resource name="jdbc/appfuse" auth="Container" type="javax.sql.DataSource"/>
06 <ResourceParams name="jdbc/appfuse">
07 <parameter>
08 <name>factory</name>
09 <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
10 </parameter>
11 <!-- Maximum number of dB connections in pool. Make sure you
12 configure your mysqld max_connections large enough to handle
13 all of your db connections. Set to 0 for no limit.
14 -->
15 <parameter>
16 <name>maxActive</name>
17 <value>100</value>
18 </parameter>
19 <!-- Maximum number of idle dB connections to retain in pool.
20 Set to 0 for no limit.
21 -->
22 <parameter>
23 <name>maxIdle</name>
24 <value>30</value>
25 </parameter>
26 <!-- Maximum time to wait for a dB connection to become available
27 in ms, in this example 10 seconds. An Exception is thrown if
28 this timeout is exceeded. Set to -1 to wait indefinitely.
29 -->
30 <parameter>
31 <name>maxWait</name>
32 <value>10000</value>
33 </parameter>
34 <!-- MySQL dB username and password for dB connections -->
35 <parameter>
36 <name>username</name>
37 <value>test</value>
38 </parameter>
39 <parameter>
40 <name>password</name>
41 <value>test</value>
42 </parameter>
43 <!-- Class name for JDBC driver -->
44 <parameter>
45 <name>driverClassName</name>
46 <value>com.mysql.jdbc.Driver</value>
47 </parameter>
48 <!-- Autocommit setting. This setting is required to make
49 Hibernate work. Or you can remove calls to commit(). -->
50 <parameter>
51 <name>defaultAutoCommit</name>
52 <value>true</value>
53 </parameter>
54 <!-- The JDBC connection url for connecting to your MySQL dB.
55 The autoReconnect=true argument to the url makes sure that the
56 mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
57 connection. mysqld by default closes idle connections after 8 hours.
58 -->
59 <parameter>
60 <name>url</name>
61 <value>jdbc:mysql://localhost/appfuse?autoReconnect=true&useUnicode=true&characterEncoding=utf-8</value>
62 </parameter>
63 <!-- Recover abandoned connections -->
64 <parameter>
65 <name>removeAbandoned</name>
66 <value>true</value>
67 </parameter>
68 <!-- Set the number of seconds a dB connection has been idle
69 before it is considered abandoned.
70 -->
71 <parameter>
72 <name>removeAbandonedTimeout</name>
73 <value>60</value>
74 </parameter>
75 <!-- Log a stack trace of the code which abandoned the dB
76 connection resources.
77 -->
78 <parameter>
79 <name>logAbandoned</name>
80 <value>true</value>
81 </parameter>
82 </ResourceParams>
83 </Context>
|
appfuse.xml파일은 크게 다음과 같이 3가지로 나뉜다.
- Context설정
- Logger설정
- DataSource와 관련된 Resource설정
Context설정#
1라인의 설정은 결과적으로 다음과 같은 설정임을 나타낸다.
http://[hostname]:[port]/[path값]
즉 자신의 컴퓨터에 Tomcat을 디폴트로 설치하였다면 http://localhost:8080/appfuse
라고 할수 있다.
docBase값은 서버상의 해당 소스파일들의 위치라고 보면 된다. 여기서 appfuse라고 지정되어 있는데, 시스템의 절대경로가 아니고 이런식으로 appfuse라고 지정이 된다면 Tomcat의 디폴트 webapp경로인 [Tomcat설치경로]/webapps 밑의 해당 이름의 디렉토리를 가리키게 된다. 즉 여기서는 [Tomcat설치경로]/webapps/appfuse
Logger 설정#
org.apache.catalina.logger.FileLogger에 의해 로그는 파일에 남게된다. prefix, suffix값에 의해 결과적으로 appfuse_log.*.txt 형태로 로그가 남는다. timestamp가 true값을 가지므로 appfuse_log.*.txt 파일형태에서 *는 시각표시(yyyy-MM-dd)와 같은 값이 더해지게 된다. 즉 appfuse_log.2006-01-13.txt 이런식으로 로그가 남게 되는것이다.
DataSource설정#
DataSource이름은 jdbc/appfuse 이다. JNDI명으로는 java:comp/env/jdbc/appfuse 와 같이 사용하면 된다.
많은 설정이 포함되어 있으나. 중요한 몇가지만 알아보자.
- factory - DBCP를 사용하고 있음을 나타내고 있다.
- maxActive - Connection pool에서 connection을 최대 100개까지만 생성이 가능.
- minIdle - Connection pool에서 대기중인 connection의 갯수라고 볼수 있다.
- maxWait - 이를테면 Connection pool에 할당한 connection이 maxActive를 넘어서 사용가능한 connection을 기다려야 할때, 그 기다리는 시간의 최대값을 설정하는 것이다. 단위는 ms로 예제의 1000은 10초를 나타낸다.
- username, password - DB연결을 위한 사용자 계정
- driverClassName - MySQL을 사용중이다.
- defaultAutoCommit - 자동 커밋에 대한 설정
- url - DB연결에 관련된 url값.