jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Bergöö <jacob.ber...@gmail.com>
Subject Re: Connecting to different repositories
Date Fri, 24 Apr 2009 14:01:02 GMT

Thanks for the quick reply,
have you heard that this has been done before or does everybody else only
work with one repository? How do you switch between different states in your
development process (dev, test, prod)?

do you have any more code examples on how to do the rmi connection?


thanks for the help,
Jacob


Alexander Klimetschek wrote:
> 
> On Fri, Apr 24, 2009 at 3:25 PM, Jacob Bergöö <jacob.bergoo@gmail.com>
> wrote:
>>
>> Hi,
>> I am working with Spring 2.5.6, spring-modules-jcr 0.8a, jcrom 1.3.2.
>>
>> In my application I have the need of be able to connect to different
>> repositories depending on if I am in development, test or production
>> mode.
>>
>> The way it is setup now I have a repository.xml configuration in my
>> src/main/resources folder where I setup a local derby repository, but I
>> want
>> to be able to create a "test" build that will connect to a repository
>> that
>> is on another machine. Therefor I cant use the way I have configured it
>> now
>> in spring.
>>
>> This is my configuration:
>>
>>  <bean id="jcrom" class="org.jcrom.Jcrom">
>>        <constructor-arg type="boolean" value="true"/>
>>        <constructor-arg type="boolean" value="true"/>
>>        <constructor-arg type="java.util.Set">
>>            <set>
>>                <value type="java.lang.Class">org.jcrom.JcrFile</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.urltree.URLNode</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.urltree.URLTree</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.page.ViewPage</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.template.TemplateNode</value>
>>                <value
>> type="java.lang.Class">com.xxx.domain.composition.template.ChildArea</value>
>>            </set>
>>        </constructor-arg>
>>    </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="user"/>
>>                <constructor-arg index="1">
>>                    <bean factory-bean="password"
>> factory-method="toCharArray"/>
>>                </constructor-arg>
>>            </bean>
>>        </property>
>>    </bean>
>>
>>    <bean id="password" class="java.lang.String">
>>        <constructor-arg index="0" value="password"/>
>>    </bean>
>>
>>    <bean id="transactionManager"
>> class="org.springmodules.jcr.jackrabbit.LocalTransactionManager">
>>        <property name="sessionFactory" ref="jcrSessionFactory"/>
>>    </bean>
>>
>>    <bean id="rmiRegistry"
>> class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"/>
>>    <bean id="rmiServer"
>> class="org.springmodules.jcr.jackrabbit.RmiServerRepositoryFactoryBean">
>>        <property name="repository" ref="repository"/>
>>        <property name="remoteAdapterFactory">
>>            <bean
>> class="org.apache.jackrabbit.rmi.server.ServerAdapterFactory"/>
>>        </property>
>>        <property name="registry" ref="rmiRegistry"/>
>>        <property name="rmiName" value="jackrabbit"/>
>>    </bean>
>>
>>   <bean id="jcrPropertyPlaceholder"
>> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
>>        <property name="location"
>> value="classpath:jcr-persistence-config.properties"/>
>>    </bean>
>>
>>    <bean id="repository"
>> class="org.springmodules.jcr.jackrabbit.RepositoryFactoryBean">
>>        <property name="configuration"
>> value="${jcr.repository.config.file}"/>
>>        <property name="homeDir" value="${jcr.repository.home.dir}"/>
>>    </bean>
>>
>>    <!-- DAO classes -->
>>
>>    <bean id="urlTreeDao" class="com.xxx.persistence.urltree.URLTreeDao">
>>        <constructor-arg index="0" ref="jcrom"/>
>>    </bean>
>>
>>
>>
>> and the property file:
>>
>> jcr.repository.config.file=classpath:repository.xml
>> jcr.repository.home.dir=file:./target/trex_jcr_repo
>>
>> So I am guessing I need to be able to connect to the other machine with
>> some
>> rmi connection but when I looked on the documentation for
>> spring-modules-jcr
>> is states:
>>
>> <!-- rmi client -->
>> <bean id="rmiClientFactory"
>> class="org.apache.jackrabbit.rmi.client.ClientRepositoryFactory"/>
>>
>> <bean id="rmiClient" factory-bean="rmiClientFactory"
>> factory-method="getRepository"
>>                   depends-on="rmiServer">
>>  <constructor-arg value="rmi://localhost:1099/jackrabbit"/>
>> </bean>
>>
>> and that means that depends-on="rmiServer" needs a rmiServer that needs a
>> repository that needs to read a repository.xml file.... this clearly does
>> not work... I would have expected that I should be able to create a
>> repository bean where I provide a URI and username, password...
> 
> In JCR/Jackrabbit, you use a JCR session to log in. In case of an RMI
> connection to the repository, the publicly available interface via RMI
> is javax.jcr.Repository (eg. "rmi://localhost:1099/jackrabbit"). You
> cannot specify credentials here. These are used when doing a
> Repository.login() to get a session.
> 
> You have to change your bean config / factories to allow multiple
> repositories, depending on some parameter or context information,
> which contains the rmi url. AFAIK the standard spring-jcr module isn't
> built for that.
> 
> Regards,
> Alex
> 
> -- 
> Alexander Klimetschek
> alexander.klimetschek@day.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Connecting-to-different-repositories-tp23216439p23217033.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message