JCR Configuration persister

JCR Configuration persister

Idea

JCR Repository Service uses org.exoplatform.services.jcr.config.RepositoryServiceConfiguration component to read its configuration.

<component>
    <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
    <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
    <init-params>
      <value-param>
        <name>conf-path</name>
        <description>JCR configuration file</description>
        <value>/conf/standalone/exo-jcr-config.xml</value>
      </value-param>
    </init-params>
  </component>

In the example Repository Service will read the configuration from the file /conf/standalone/exo-jcr-config.xml.

But in some cases it's required to change the configuration on the fly. And know that the new one will be used. Additionally we wish not to modify the original file.

In this case we have to use the configuration persister feature which allows to store the configuration in different locations.

Usage

On startup RepositoryServiceConfiguration component checks if a configuration persister was configured. In that case it uses the provided ConfigurationPersister implementation class to instantiate the persister object.

Configuration with persister:

<component>
    <key>org.exoplatform.services.jcr.config.RepositoryServiceConfiguration</key>
    <type>org.exoplatform.services.jcr.impl.config.RepositoryServiceConfigurationImpl</type>
    <init-params>
      <value-param>
        <name>conf-path</name>
        <description>JCR configuration file</description>
        <value>/conf/standalone/exo-jcr-config.xml</value>
      </value-param>
      <properties-param>
        <name>working-conf</name>
        <description>working-conf</description>
        <property name="source-name" value="jdbcjcr" />
        <property name="dialect" value="mysql" />
        <property name="persister-class-name" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister" />
      </properties-param>
    </init-params>
  </component>

where: source-name - JNDI source name configured in InitialContextInitializer component. (sourceName prior v.1.9.) Find more in database configuration.

dialect - SQL dialect which will be used with database from source-name. Find more in database configuration.

persister-class-name - class name of ConfigurationPersister interface implementation. (persisterClassName prior v.1.9.)

ConfigurationPersister interface:

/**
   * Init persister.
   * Used by RepositoryServiceConfiguration on init. 
   * @return - config data stream
   */
  void init(PropertiesParam params) throws RepositoryConfigurationException;
  
  /**
   * Read config data.
   * @return - config data stream
   */
  InputStream read() throws RepositoryConfigurationException;
  
  /**
   * Create table, write data.
   * @param confData - config data stream
   */
  void write(InputStream confData) throws RepositoryConfigurationException;
  
  /**
   * Tell if the config exists.
   * @return - flag
   */
  boolean hasConfig() throws RepositoryConfigurationException;

JCR Core implementation contains a persister which stores the repository configuration in the relational database using JDBC calls - org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister.

The implementation will crate and use table JCR_CONFIG in the provided database.

But the developer can implement his own persister for his particular usecase.

Tags:
Created by Peter Nedonosko on 07/10/2008
Last modified by Sören Schmidt on 08/07/2009

Products

generated on Thu Sep 02 15:46:45 UTC 2010

eXo Optional Modules

eXo Core Foundations


Copyright (c) 2000-2010. All Rights Reserved - eXo platform SAS
2.4.30451