J'ai une application qui tourne dans une webapp, j'aimerais récupérer la bean factory de spring afin de pouvoir instancier mes bean dans mon code lorsque ceux-ci ne sont pas des singletons. Je m'attendais à trouver simplement un méthode statique mais si elle existe je ne l'ai pas trouvée.

Comment faire pour récupérer dans mon code java la XmlBeanFactory initialisée par le serveur d'application ?

Voici une partie de mon web.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
<web-app>
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath*:/WEB-INF/applicationContext.xml</param-value>
	</context-param>
</web-app>
Et un échantillon de mon applicationContext.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:util="http://www.springframework.org/schema/util"
	xmlns:configurator="http://cocoon.apache.org/schema/configurator"
	xmlns:avalon="http://cocoon.apache.org/schema/avalon"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
                           http://cocoon.apache.org/schema/configurator http://cocoon.apache.org/schema/configurator/cocoon-configurator-1.0.xsd
                           http://cocoon.apache.org/schema/avalon http://cocoon.apache.org/schema/avalon/cocoon-avalon-1.0.xsd">
	<!-- Activate Cocoon Spring Configurator -->
	<configurator:settings />
	<!-- Configure Log4j -->
 	<bean name="org.apache.cocoon.spring.configurator.log4j"
		class="org.apache.cocoon.spring.configurator.log4j.Log4JConfigurator"
		scope="singleton">
		<property name="settings"
		ref="org.apache.cocoon.configuration.Settings" />
		<property name="resource" value="/WEB-INF/log4j.xml" />
	</bean>
	<!-- Activate Avalon Bridge -->
	<avalon:bridge />
	<bean id="myDataSource"
		class="org.springframework.jndi.JndiObjectFactoryBean">
		<property name="jndiName" value="java:comp/env/jdbc/metadatadb" />
	</bean>
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource" ref="myDataSource" />
		<property name="configLocation">
			<value>classpath:/hibernate.cfg.xml</value>
		</property>
	</bean>
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
	<bean id="storageInitializer"
		class="xxx.StorageInitializer">
		<property name="sessionFactory">
			<ref bean="sessionFactory"/>
		</property>
	</bean>
</beans>
D'avance merci.