lidonghe 发表于 2017-1-25 10:12:19

Tomcat学习笔记(二)

  6 .

<Manager className="some.manager.implementation.className"
customAttribute1="some custom value"
customAttribute2="some other custom value"/>
   
在Tomcat中,Session的管理主要还是通过如此的方法,自定义管理Session的Manager。

    
StandardManager

         默认的Manager。只有在服务器正常关闭的时候,才会序列化session到硬盘。

    
PersistentManager

        
文中说这是试验性质的。实现了所有的Session序列化的方法。根据其使用Store的不同。可以把Seession实例化到本地或数据库。

        
其提供的实现类是org.apache.catalina.session.PersistentManager

              
文件系统的store是org.apache.catalina.session.FileStore 文件格式是<session
ID>.session

                     
DB的store是org.apache.catalina.session.JDBCStore


7. JDBC
DataSources

    文件中的配置


<resource-ref>
<description>
The database DataSource for the Acme web application.
</description>
<res-ref-name>jdbc/JabaDotDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- Configure a JDBC DataSource for the user database. -->
<Resource name="jdbc/JabaDotDB"
type="javax.sql.DataSource"
auth="Container"
user="ian"
password="top_secret_stuff"
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql:jabadot"
maxActive="8"
maxIdle="4"/>
   具体的使用


Context ctx = new InitialContext( );
DataSource ds = (DataSource)
ctx.lookup("java:comp/env/jdbc/JabaDotDB");
Connection conn = ds.getConnection( );
//... Java code that accesses the database ...
conn.close( );
   

8 自定义用户目录


<Listener className="org.apache.catalina.startup.UserConfig"
directoryName="public_html"
userClass="org.apache.catalina.startup.PasswdUserDatabase"/>
   
方法一,其目录会使/home/users/ian/public_html or /users/jbrittain/public_html.



<Listener className="org.apache.catalina.startup.UserConfig"
directoryName="public_html"
homeBase="/home"
userClass="org.apache.catalina.startup.HomesUserDatabase"/>
   
方法二

               其目录会使/home/ian/public_html and
/home/jbrittain/public_html.
页: [1]
查看完整版本: Tomcat学习笔记(二)