• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • Last Change
  • Annotate
  • Revision Log

root/trunk/components/server/resources/ome/services/hibernate.xml

Revision 3045, 5.7 kB (checked in by jmoore, 2 months ago)

ticket:1114 - Fixing sql connection errors in new OmeroSessions code

This does not actually solve the issue within the new
session code which caused weblitz's DoS'ing ways to
consume all the connections. Instead, this tidies up the
c3p0 connection pooling configuration which makes connection
acquisition more robust.

Specifically, the redundant (and unused) properties in
omero.properties are gone (everything in c3p0.properties)
and some minor build changes were needed to make that
happen.

Patch from downstream: dd096cc4cc17a71e8c6f760cf6f7e72baa512ebd

  • Property svn:keywords set to Id
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
3<!--
4#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5#
6# $Id$
7#
8# Copyright 2006 University of Dundee. All rights reserved.
9# Use is subject to license terms supplied in LICENSE.txt
10#
11#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12-->
13
14<!--
15#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16# Written by:  Josh Moore <josh.moore@gmx.de>
17#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
18-->
19
20<beans> 
21
22  <description>
23    Configuration for Hibernate data access. The beans in this configuration file
24    should NOT be generally accessed. In general, this entire file should be
25    considered to have a "private" scope.
26  </description>
27
28  <bean id="extendedMetadata" class="ome.tools.hibernate.ExtendedMetadata">
29    <description>
30    Simple cache for metadata needed throughout the server. Uses the Hibernate
31    metamodel to fill the cache during creation. On ContextRefreshedEvent,
32    the ExtendedMetadata instance will acquire the SessionFactory from the
33    ApplicationContext and assemble its metadata. The SessionFactory cannot
34    be injected directly because several security objects depend on the
35    metadata, but they themselves must be injected into the SessionFactory
36    for proper functioning. To prevent this circular dependency, we do a
37    form of lazy loading.
38    </description>
39  </bean>
40
41  <bean id="hibernateProperties"
42    class="org.springframework.beans.factory.config.PropertiesFactoryBean">
43    <description>
44    Scope: private
45    </description>
46    <property name="properties">
47      <props>
48        <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
49        <prop key="hibernate.dialect">${hibernate.dialect}</prop>
50        <prop key="hibernate.connection.driver_class">${hibernate.connection.driver_class}</prop>
51        <prop key="hibernate.connection.url">${hibernate.connection.url}</prop>
52        <prop key="hibernate.connection.username">${hibernate.connection.username}</prop>
53        <prop key="hibernate.connection.password">${hibernate.connection.password}</prop>
54        <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>
55        <prop key="cache.use_query_cache">false</prop>
56        <prop key="cache.use_minimal_puts">false</prop>
57        <prop key="hibernate.search.default.indexBase">${omero.data.dir}</prop>
58        <prop key="hibernate.search.analyzer">${omero.search.analyzer}</prop>
59        <prop key="hibernate.c3p0.acquire_increment">${c3p0.acquireIncrement}</prop>
60        <prop key="hibernate.c3p0.max_size">${c3p0.maxPoolSize}</prop>
61        <prop key="hibernate.c3p0.max_statements">${c3p0.maxStatements}</prop>
62        <prop key="hibernate.c3p0.min_size">${c3p0.minPoolSize}</prop>
63        <prop key="hibernate.c3p0.timeout">${c3p0.maxIdleTime}</prop><!-- seconds -->
64        <prop key="hibernate.c3p0.idle_test_period">${c3p0.idleConnectionTestPeriod}</prop> <!-- seconds -->
65      </props>
66    </property>
67  </bean>
68
69  <!-- Scope: private -->
70
71  <!-- Used here to inject a value into the parent ome.model context
72  which is available to all model objects. -->
73  <bean class="ome.util.MapPut" lazy-init="false">
74    <property name="map" ref="bridges"/>
75    <property name="key" value="fieldBridges"/>
76    <property name="object" ref="fullTextIndexer"/>
77  </bean>
78 
79  <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">
80    <constructor-arg ref="transactionManager"/>
81  </bean>
82 
83  <bean id="proxyHandler" class="ome.tools.hibernate.ProxyCleanupFilter$Interceptor">
84    <description>
85    Scope: private
86    </description>
87    <property name="sessionHandler" ref="sessionHandler"/>
88  </bean>
89 
90  <bean id="sessionHandler" class="ome.tools.hibernate.SessionHandler">
91    <description>
92    Scope: private
93   
94    The session handler is used to handle sessions for stateful beans. A single
95    session is opened for any new stateful session invocation, and will be closed
96    once "close()" is invoked.
97    </description>
98    <constructor-arg ref="sessionFactory"/>   
99  </bean>
100
101  <bean id="hibernateHandler" class="org.springframework.orm.hibernate3.HibernateInterceptor">
102    <description>
103    Scope: private
104    </description>
105    <property name="sessionFactory" ref="sessionFactory"/>
106  </bean>
107
108  <bean id="hibernateTemplate" class="ome.tools.spring.ManualFlushHibernateTemplate">
109    <description>
110    Scope: private
111    </description>
112    <property name="sessionFactory" ref="sessionFactory"/>
113    <property name="allowCreate" value="false"/>
114  </bean>
115
116  <bean id="simpleJdbcTemplate" class="ome.tools.spring.DelegatingJdbcTemplate">
117    <description>
118    Scope: private
119   
120    This template uses session.connection() for data access. See javadocs for
121    more info.
122    </description>
123    <constructor-arg ref="hibernateTemplate"/>
124  </bean>
125 
126  <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
127    <description>
128    Scope: private
129    Note:  many of the references for the sessionFactory are defined in
130           security.xml
131    </description>
132    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
133    <property name="hibernateProperties" ref="hibernateProperties"/>
134    <property name="dataSource" ref="dataSource"/>
135    <property name="entityInterceptor" ref="omeroInterceptor"/>
136    <property name="eventListeners" ref="eventListeners"/>
137        <property name="filterDefinitions">
138                <list>
139                        <ref bean="securityFilter"/>
140                </list>
141        </property>
142  </bean>
143
144</beans>
Note: See TracBrowser for help on using the browser.

Download in other formats:

  • Plain Text
  • Original Format

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/