Overview
Tomcat accomplishes connections pooling by defining a resource for a given context. Then that resource is referenced within a web application's web.xml which will cause the Tomcat Resource Factory to create the requested resource and it will be accessible to that web application.Defining Resources
Resources can be defined in either of the following locations:Global Context
tomcat/conf/context.xmlAll resources defined here can be referenced in any web application.
Context Specific
tomcat/conf/[enginename]/[hostname]/[appcontext].xml[enginename] This will be Catalina
[hostname] This will usually be localhost
[appcontext] This will be the directory name the application is deployed to under the tomcat/webapp directory.
Following the above directory structure and naming convention allows you define a context and resource that can only be accessed by a specific application. An example would be of this would be tomcat/Catalina/localhost/MyExampleApp.xml
Below is an example of context.xml with a resource defined within. You can also take this example and remove WatchedResource element and use it for a context specific resource.
Web Application Setup
To allow access to the resource you must make a reference to it in your applications web.xmlHibernate Setup
To configure hibernate to use the resource you reference it using its full JNDI name in the <property name="hibernate.connection.datasource"> tagSources:
http://wiki.apache.org/tomcat/TomcatHibernatehttp://tomcat.apache.org/tomcat-7.0-doc/jndi-resources-howto.html
http://tomcat.apache.org/tomcat-7.0-doc/jndi-datasource-examples-howto.html
No comments :
Post a Comment