eXo Platform 3.5

## Chapter 13. eXo JCR configuration

## Related documents

- Configuration persister

- Search Configuration

- JDBC Data Container config

- External Value Storages

- Workspace Persistence Storage

## Portal and Standalone configuration

Like other eXo services, eXo JCR can be configured and used in the portal or embedded mode (as a service embedded in eXo Portal) and in standalone mode.

In Embedded mode, JCR services are registered in the Portal container and the second option is to use a Standalone container. The main difference between these container types is that the first one is intended to be used in a Portal (Web) environment, while the second one can be used standalone (see the comprehensive page Service Configuration for Beginners for more details).

The following setup procedure is used to obtain a Standalone configuration (see more in Container configuration):

- Configuration that is set explicitly using StandaloneContainer.addConfigurationURL(String url) or StandaloneContainer.addConfigurationPath(String path) before getInstance()

- Configuration from $base:directory/exo-configuration.xml or $base:directory/conf/exo-configuration.xml file. Where $base:directory is either AS's home directory in case of J2EE AS environment or just the current directory in case of a standalone application.

- /conf/exo-configuration.xml in the current classloader (e.g. war, ear archive)

- Configuration from $service_jar_file/conf/portal/configuration.xml. WARNING: Don't rely on some concrete jar's configuration if you have more than one jar containing conf/portal/configuration.xml file. In this case choosing a configuration is unpredictable.

JCR service configuration looks like:

    <component>

      <key>org.exoplatform.services.jcr.RepositoryService</key>

      <type>org.exoplatform.services.jcr.impl.RepositoryServiceImpl</type>

    </component>

    <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 repositories configuration file</description>

          <value>jar:/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="hsqldb" />

          <property name="persister-class-name" value="org.exoplatform.services.jcr.impl.config.JDBCConfigurationPersister" />

        </properties-param>

      </init-params>

    </component>

conf-path : a path to a RepositoryService JCR Configuration.

working-conf : optional; JCR configuration persister configuration. If there isn't a working-conf, the persister will be disabled.

## JCR Configuration

The Configuration is defined in an XML file (see DTD below).

JCR Service can use multiple Repositories and each repository can have multiple Workspaces.

From v.1.9 JCR, repositories configuration parameters support human-readable formats of values. They are all case-insensitive:

- Numbers formats: K,KB - kilobytes, M,MB - megabytes, G,GB - gigabytes, T,TB - terabytes. Examples: 100.5 - digit 100.5, 200k - 200 Kbytes, 4m - 4 Mbytes, 1.4G - 1.4 Gbytes, 10T - 10 Tbytes

- Time format endings: ms - milliseconds, m - minutes, h - hours, d - days, w - weeks, if no ending - seconds. Examples: 500ms - 500 milliseconds, 20 - 20 seconds, 30m - 30 minutes, 12h - 12 hours, 5d - 5 days, 4w - 4 weeks.

## Repository service configuration (JCR repositories configuration)

Service configuration may be placed in jar:/conf/standalone/exo-jcr-config.xml for standalone mode. For portal mode, it is located in the portal web application portal/WEB-INF/conf/jcr/repository-configuration.xml.

default-repository: The name of a default repository (one returned by RepositoryService.getRepository()).

repositories: The list of repositories.

## Repository configuration:

name: The name of a repository.

default-workspace: The name of a workspace obtained using Session's login() or login(Credentials) methods (ones without an explicit workspace name).

system-workspace: The name of workspace where /jcr:system node is placed.

security-domain: The name of a security domain for JAAS authentication.

access-control: The name of an access control policy. There can be 3 types: optional - ACL is created on-demand(default), disable - no access control, mandatory - an ACL is created for each added node(not supported yet).

authentication-policy: The name of an authentication policy class.

workspaces: The list of workspaces.

session-max-age: The time after which an idle session will be removed (called logout). If session-max-age is not set up, idle session will never be removed.

lock-remover-max-threads: Number of threads that can serve LockRemover tasks. Default value is 1. Repository may have many workspaces, each workspace have own LockManager. JCR supports Locks with defined lifetime. Such a lock must be removed is it become expired. That is what LockRemovers does. But LockRemovers is not an independent timer-threads, its a task that executed each 30 seconds. Such a task is served by ThreadPoolExecutor which may use different number of threads.

## Workspace configuration:

name: The name of a workspace

auto-init-root-nodetype: DEPRECATED in JCR 1.9 (use initializer). The node type for root node initialization.

container: Workspace data container (physical storage) configuration.

initializer: Workspace initializer configuration.

cache: Workspace storage cache configuration.

query-handler: Query handler configuration.

auto-init-permissions: DEPRECATED in JCR 1.9 (use initializer). Default permissions of the root node. It is defined as a set of semicolon-delimited permissions containing a group of space-delimited identities (user, group, etc, see Organization service documentation for details) and the type of permission. For example, any read; :/admin read;:/admin add_node; :/admin set_property;:/admin remove means that users from group admin have all permissions and other users have only a 'read' permission.

## Workspace data container configuration:

class: A workspace data container class name.

properties: The list of properties (name-value pairs) for the concrete Workspace data container.

trigger_events_for_descendents_on_rename | indicates if need to trigger events for descendents on rename or not. It allows to increase performance on rename operation but in same time Observation'll not notified, has default value true
lazy-node-iterator-page-size | the page size for lazy iterator. Indicates how many nodes can be retrieved from storage per request. The default value is 100
acl-bloomfilter-false-positive-probability | ACL Bloom-filter desired false positive probability. Range [0..1]. Default value 0.1d. (See the note below)
acl-bloomfilter-elements-number | Expected number of ACL-elements in the Bloom-filter. Default value 1000000. (See the note below)

### Note

Bloom filters are not supported by all the cache implementations so far only the inplementation for infinispan supports it.

value-storages: The list of value storage plugins.

## Value Storage plugin configuration (for data container):

### Note

The value-storage element is optional. If you don't include it, the values will be stored as BLOBs inside the database.

value-storage: Optional value Storage plugin definition.

class: A value storage plugin class name (attribute).

properties: The list of properties (name-value pairs) for a concrete Value Storage plugin.

filters: The list of filters defining conditions when this plugin is applicable.

## Initializer configuration (optional):

class: Initializer implementation class.

properties: The list of properties (name-value pairs). Properties are supported.

root-nodetype: The node type for root node initialization.

root-permissions: Default permissions of the root node. It is defined as a set of semicolon-delimited permissions containing a group of space-delimited identities (user, group etc, see Organization service documentation for details) and the type of permission. For example any read; :/admin read;:/admin add_node; :/admin set_property;:/admin remove means that users from group admin have all permissions and other users have only a 'read' permission.

Configurable initializer adds a capability to override workspace initial startup procedure (used for Clustering). Also it replaces workspace element parameters auto-init-root-nodetype and auto-init-permissions with root-nodetype and root-permissions.

## Cache configuration:

enabled: If workspace cache is enabled or not.

class: Cache implementation class, optional from 1.9. Default value is. org.exoplatform.services.jcr.impl.dataflow.persistent.LinkedWorkspaceStorageCacheImpl.

Cache can be configured to use concrete implementation of WorkspaceStorageCache interface. JCR core has two implementation to use:

- LinkedWorkspaceStorageCacheImpl - default, with configurable read behavior and statistic.

- WorkspaceStorageCacheImpl - pre 1.9, still can be used.

properties: The list of properties (name-value pairs) for Workspace cache.

max-size: Cache maximum size (maxSize prior to v.1.9).

live-time: Cached item live time (liveTime prior to v.1.9).

From 1.9 LinkedWorkspaceStorageCacheImpl supports additional optional parameters.

statistic-period: Period (time format) of cache statistic thread execution, 5 minutes by default.

statistic-log: If true cache statistic will be printed to default logger (log.info), false by default or not.

statistic-clean: If true cache statistic will be cleaned after was gathered, false by default or not.

cleaner-period: Period of the eldest items remover execution, 20 minutes by default.

blocking-users-count: Number of concurrent users allowed to read cache storage, 0 - unlimited by default.

## Query Handler configuration:

class: A Query Handler class name.

properties: The list of properties (name-value pairs) for a Query Handler (indexDir).

Properties and advanced features described in Search Configuration.

## Lock Manager configuration:

time-out: Time after which the unused global lock will be removed.

persister: A class for storing lock information for future use. For example, remove lock after jcr restart.

path: A lock folder. Each workspace has its own one.

### Note

Also see lock-remover-max-threads repository configuration parameter.

    <!ELEMENT repository-service (repositories)>

    <!ATTLIST repository-service default-repository NMTOKEN #REQUIRED>

    <!ELEMENT repositories (repository)>

    <!ELEMENT repository (security-domain,access-control,session-max-age,authentication-policy,workspaces)>

    <!ATTLIST repository

      default-workspace NMTOKEN #REQUIRED

      name NMTOKEN #REQUIRED

      system-workspace NMTOKEN #REQUIRED

    >

    <!ELEMENT security-domain (#PCDATA)>

    <!ELEMENT access-control (#PCDATA)>

    <!ELEMENT session-max-age (#PCDATA)>

    <!ELEMENT authentication-policy (#PCDATA)>

    <!ELEMENT workspaces (workspace+)>

    <!ELEMENT workspace (container,initializer,cache,query-handler)>

    <!ATTLIST workspace name NMTOKEN #REQUIRED>

    <!ELEMENT container (properties,value-storages)>

    <!ATTLIST container class NMTOKEN #REQUIRED>

    <!ELEMENT value-storages (value-storage+)>

    <!ELEMENT value-storage (properties,filters)>

    <!ATTLIST value-storage class NMTOKEN #REQUIRED>

    <!ELEMENT filters (filter+)>

    <!ELEMENT filter EMPTY>

    <!ATTLIST filter property-type NMTOKEN #REQUIRED>

    <!ELEMENT initializer (properties)>

    <!ATTLIST initializer class NMTOKEN #REQUIRED>

    <!ELEMENT cache (properties)>

    <!ATTLIST cache

      enabled NMTOKEN #REQUIRED

      class NMTOKEN #REQUIRED

    >

    <!ELEMENT query-handler (properties)>

    <!ATTLIST query-handler class NMTOKEN #REQUIRED>

    <!ELEMENT access-manager (properties)>

    <!ATTLIST access-manager class NMTOKEN #REQUIRED>

    <!ELEMENT lock-manager (time-out,persister)>

    <!ELEMENT time-out (#PCDATA)>

    <!ELEMENT persister (properties)>

    <!ELEMENT properties (property+)>

    <!ELEMENT property EMPTY>

## Help application to prohibit the use of closed sessions

Products that use eXo JCR, sometimes missuse it since they continue to use a session that has been closed through a method call on a node, a property or even the session itself. To prevent bad practices we propose three modes which are the folllowing:

1. If the system property exo.jcr.prohibit.closed.session.usage has been set to true, then a RepositoryException will be thrown any time an application will try to access to a closed session. In the stack trace, you will be able to know the call stack that closes the session.

2. If the system property exo.jcr.prohibit.closed.session.usage has not been set and the system property exo.product.developing has been set to true, then a warning will be logged in the log file with the full stack trace in order to help identifying the root cause of the issue. In the stack trace, you will be able to know the call stack that closes the session.

3. If none of the previous system properties have been set, then we will ignore that the issue and let the application use the closed session as it was possible before without doing anything in order to allow applications to migrate step by step.