jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jukka Zitting ...@yukatan.fi>
Subject Re: implementation independent repository lookup
Date Wed, 07 Sep 2005 13:47:31 GMT
Hi,

Michael Wechner wrote:
>> Are you looking for something like the DriverManager in JDBC?
> 
> yes, I guess something like
> 
> jcr.drivers=org.apache.jackrabbit.Driver:com.jeceira.Driver
> 
> but I assume that JCR would have to enhance the API, right? Also
> I guess the various implementations would have to find consensus on
> how the configuration is being loaded or rather the API would impose
> that on them I guess.

Yes. Either extend the API or create some other de facto repository 
instantiation standard. However I think that this issue is better 
handled by the various component frameworks than a JCR-specific API.

>> I was thinking about proposing such a mechanism sometime ago, but I've 
>> since settled on using JNDI in container environments and Spring (or 
>> another component framework) in standalone applications.
> 
> do you have some code snippets how this can be done without using for 
> instance the jackrabbit specific RegistryHelper?

I've been using something like the following with the Spring framework 
to avoid a direct Jackrabbit dependency in standalone applications:

     ApplicationContext context = ...;
     Repository repository = (Repository)
         context.getBean("repository", Repository.class);

The current Jackrabbit core classes are not very Spring-friendly, but 
the following sample bean configuration should give you a configured 
Jackrabbit Repository instance as the "repository" bean:

   <bean id="repository-config"
         class="org.apache.jackrabbit.core.config.RepositoryConfig"
         factory-method="create">
     <constructor-arg type="java.lang.String" index="0">
       <value>/path/to/repository.xml</value>
     </constructor-arg>
     <constructor-arg type="java.lang.String" index="1">
       <value>/path/to/repository</value>
     </constructor-arg>
   </bean>

   <bean id="repository"
         class="org.apache.jackrabbit.core.RepositoryImpl">
     <constructor-arg>
       <ref local="repository-config"/>
     </constructor-arg>
   </bean>

It should be possible to create similar configuration snippets for other 
JCR implementations as well.

BR,

Jukka Zitting

Mime
View raw message