jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Costin Leau <costin.l...@gmail.com>
Subject Re[2]: shutting down repository obtained from jndi via spring
Date Thu, 29 Sep 2005 07:46:35 GMT
Thanks Aaron!

I looked over to JndiObjectFactoryBean and the main issue is that you
need an interface to which to cast to. I will check the forums is
adding class support is possible to implement in the future.
You can however bypass this (unless you want to use the SM support) by
creating just a wrapper bean that does manually a casting of the
repository class retrieved from the JNDI and calls destroy on it manually (this is what the
FactoryBean actually does).

I'd really like feedback on the project so if you discover any bugs or
have ideas for improvements add them please to SM JIRA
(http://opensource2.atlassian.com/projects/spring/browse/MOD).


> Checkout the RepositoryFactoryBean in the sandbox of the SpringModules
> project (https://springmodules.dev.java.net/). This factory bean takes care
> of shutting down the repository correctly. It also offers the jcrTemplate
> for simplifying many of the common JCR actions and an
> OpenSessionInViewFilter that will maintain an open JCR Session throughout
> the lifetime of a request.. I am using it in my webapp and it works great.

> Thanks to Costin Leau for this great addition to the SpringModules.

> --
> Aaron Jackson

> Here are the bean entries I added to my application context:

> <bean id="repository" class="
> org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
> <!-- normal factory beans params -->
> <property name="configuration"
> value="classpath:jackrabbit-repo.xml"/>
> <property name="homeDir" value="file:/repository"/>
> </bean>

> <bean id="jcrSessionFactory"
> class="org.springmodules.jcr.JcrSessionFactory
">>
> <property name="repository" ref="repository"/>
> <property name="credentials">
> <bean class="javax.jcr.SimpleCredentials">
> <constructor-arg index="0" value="bogus"/>
> <!-- create the credentials using a bean factory -->
> <constructor-arg index="1">
> <bean factory-bean="password"
> factory-method="toCharArray"/>
> </constructor-arg>
> </bean>
> </property>
> </bean>

> <!-- create the password to return it as a char[] -->
> <bean id="password" class="java.lang.String">
> <constructor-arg index="0" value="pass"/>
> </bean>

> <bean id="jcrTemplate" class="org.springmodules.jcr.JcrTemplate">
> <property name="sessionFactory" ref="jcrSessionFactory"/>
> <property name="allowCreate" value="true"/>
> </bean>

> On 9/28/05, Brian Moseley <bcm@osafoundation.org> wrote:
>>
>> i know at least a few folks here use spring with jackrabbit, so i'm
>> asking this question here first in hopes that somebody has already
>> solved the problem.
>>
>> i'm using spring's JndiObjectFactoryBean to obtain the Repository i've
>> set up as a naming resource in tomcat.
>>
>> since updating to the latest jackrabbit source, i'm finding that a
>> normal server shutdown does not cause the repository to be shutdown. the
>> repository lock file is not removed, and i can not successfully reopen
>> the repository when restarting tomcat.
>>
>> i tried using a destroy method on my bean (see below), but i got an
>> error from DefaultListableBeanFactory that "Couldn't find a destroy
>> method named 'shutdown' on bean with name 'jcrRepository'".
>>
>> <bean id="jcrRepository"
>> class="org.springframework.jndi.JndiObjectFactoryBean"
>> destroy-method="shutdown">
>> <property name="jndiName">
>> <value>jcr/cosmo</value>
>> </property>
>> <property name="resourceRef">
>> <value>true</value>
>> </property>
>> </bean>
>>
>> destroy-method works fine in my test environment, where i instantiate
>> RepositoryImpl directly.
>>
>> <bean id="jcrRepositoryConfig"
>> class="org.apache.jackrabbit.core.config.RepositoryConfig"
>> factory-method="create">
>> <constructor-arg type="java.lang.String" index="0">
>> <value>@CONFIGFILEPATH@</value>
>> </constructor-arg>
>> <constructor-arg type="java.lang.String" index="1">
>> <value>@REPOSITORYHOMEDIRPATH@</value>
>> </constructor-arg>
>> </bean>
>>
>> <bean id="jcrRepository"
>> class="org.apache.jackrabbit.core.RepositoryImpl"
>> destroy-method="shutdown">
>> <constructor-arg>
>> <ref local="jcrRepositoryConfig"/>
>> </constructor-arg>
>> </bean>
>>
>> any suggestions? i *really* don't want to have to write a servlet
>> context listener to shut jackrabbit down. i have thus far managed to
>> keep jackrabbit-specific code out of the webapp and would like to keep
>> it that way.
>>
>> thanks!
>>



-- 
Best regards,
 Costin                            mailto:costin.leau@gmail.com


Mime
View raw message