Stax-web.xml
From Stax
The stax-web.xml file is used to set container-specific settings for an application. This file is defined in the WEB-INF directory next to the standard web.xml.
Contents |
Element Summary
Here's an overview of the top-level elements in stax-web.xml
<stax-web-app xmlns="http://www.stax.net/xml/webapp/1"> <appid /> <context-param /> <resource type="javax.sql.DataSource" /> <sessionDataSource /> <realm /> </stax-web-app>
Application ID
This element specifies the default application ID when deploying the application
<appid>STAXACCOUNT/APPNAME</appid>
Context Parameters
Use this element to add ServletContext parameters in addition to those provided in the standard WEB-INF/web.xml.
<context-param> <param-name>myparm.name</param-name> <param-value>my value</param-value> </context-param>
JDBC DataSources
Use the element to define the actual database that is referenced in the web.xml file using the <resource-ref> element. The name attribute must correspond to the name used in the web.xml <resource-ref> element. The rule below show how to access a Stax MySQL database, but you are free to access other databases by using appropriate URLs and credentials.
<resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"> <param name="username" value="DB_USER" /> <param name="password" value="DB_PASSWORD" /> <param name="url" value="jdbc:stax://STAX_DB" /> </resource>
Here is an example of the expected XML in the WEB-INF/web.xml file that would reference this datasource
<resource-ref> <res-ref-name>jdbc/mydb</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Additional Resource Parameters
Stax Datasource resources leverage Apache DBCP to manage connection pools, so any of the standard DBCP parameters can be passed using the <param> element.
<resource name="jdbc/mydb" auth="Container" type="javax.sql.DataSource"> ... <param name="maxActive" value="10" /> <param name="maxIdle" value="30" /> <param name="maxWait" value="10000" /> <param name="removeAbandoned" value="true" /> <param name="removeAbandonedTimeout" value="60" /> <param name="logAbandoned" value="true" /> <param name="validationQuery" value="SELECT 1" /> <param name="testOnBorrow" value="true" /> </resource>
JDBC Clustered Sessions
When clustering Stax applications, sessions may be clustered via JDBC by specifying the name of the datasource the application should use to store session data. When processing requests, session data will be pushed back to the specified datasource at the end of the request.
<sessionDataSource>jdbc/mydb</sessionDataSource>
Authentication Realms
Use this element to bind your web application's login verification and role assignments to a datasource.
<realm> <param name="className" value="org.apache.catalina.realm.DataSourceRealm" /> <param name="dataSourceName" value="jdbc/myauthdb" /> <param name="localDataSource" value="true" /> <param name="digest" value="SHA" /> <param name="userTable" value="users" /> <param name="userNameCol" value="username" /> <param name="userCredCol" value="password" /> <param name="userRoleTable" value="users" /> <param name="roleNameCol" value="role" /> </realm>
