On Fri, Dec 11, 2009 at 1:11 PM, Ben Short <[email protected]> wrote:
> Sergey,
>
> Can I see your spring config that creates the repository?
>
Sure, but it's a bit tricky cause I had to configure distributed
transactions for JCR and MySQL.
Going with Jencks was the only way I managed to achieve it.
applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<import resource="jdbc.xml" />
<import resource="jcr.xml" />
<bean id="jtaTransactionManager"
class="org.jencks.factory.TransactionManagerFactoryBean" />
...
</beans>
jcr.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<bean id="connectionTracker"
class="org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator"/>
<bean id="jrConnectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager">
<ref bean="jtaTransactionManager" />
</property>
<property name="transaction" value="xa"/>
<property name="pooling" value="true" />
<property name="poolMinSize" value="5" />
<property name="poolMaxSize" value="100" />
<property name="connectionTracker" ref="connectionTracker" />
</bean>
<bean id="repository" class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory">
<ref local="repositoryManagedConnectionFactory"/>
</property>
<property name="connectionManager">
<ref local="jrConnectionManager"/>
</property>
</bean>
<bean id="repositoryManagedConnectionFactory"
class="org.apache.jackrabbit.jca.JCAManagedConnectionFactory">
<property name="homeDir" value="@repo.home@" />
<property name="configFile" value="@repo.config@" />
</bean>
<!-- SessionFactory -->
<bean id="jcrSessionFactory" class="org.springmodules.jcr.JcrSessionFactory">
<property name="repository">
<ref local="repository"/>
</property>
<property name="credentials">
<bean class="javax.jcr.SimpleCredentials">
<constructor-arg index="0" value="@repo.login@" />
<constructor-arg index="1" value="@repo.password@" />
</bean>
</property>
</bean>
<bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
<property name="sessionFactory">
<ref local="jcrSessionFactory"/>
</property>
<property name="allowCreate" value="true"/>
</bean>
</beans>
jcbc.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
<bean id="jdbcConnectionManager"
class="org.jencks.factory.ConnectionManagerFactoryBean">
<property name="transactionManager">
<ref bean="jtaTransactionManager"/>
</property>
<property name="transaction" value="xa"/>
</bean>
<bean id="jdbcManagedConnectionFactory"
class="org.jencks.tranql.DataSourceMCF">
<property name="driverName" value="com.mysql.jdbc.Driver" />
<property name="url" value="@mysql.url@" />
<property name="user" value="@mysql.login@" />
<property name="password" value="@mysql.password@" />
</bean>
<bean id="jdbcXaDataSource"
class="org.jencks.factory.ConnectionFactoryFactoryBean">
<property name="managedConnectionFactory">
<ref local="jdbcManagedConnectionFactory"/>
</property>
<property name="connectionManager">
<ref local="jdbcConnectionManager" />
</property>
</bean>
</beans>
All the @...@ values are replaced at build time.
--
sp