org.modeshape.jcr.index.local

## Class LocalIndexProvider

- java.lang.Object
- - org.modeshape.jcr.spi.index.provider.IndexProvider
  - - org.modeshape.jcr.index.local.LocalIndexProvider

-     public class LocalIndexProvider
      extends IndexProvider

  An `IndexProvider` implementation that maintains indexes on the local file system using MapDB.

  This provider is instantiated with:

  - an `directory` attribute, or
  - an `path` attribute and an `relativeTo` attribute

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.modeshape.jcr.spi.index.provider.IndexProvider

      `IndexProvider.ManagedIndexOperation`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LocalIndexProvider()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected ManagedIndex` | `createIndex(IndexDefinition defn, String workspaceName, NodeTypes.Supplier nodeTypesSupplier, ChangeSetAdapter.NodeTypePredicate matcher, IndexFeedback feedback)` Method called when this provider needs to create a new index given the unique pair of workspace name and index definition.
    `protected void` | `doInitialize()` Method that should do the provider-specific initialization work.
    `String` | `getDirectory()` Get the absolute or relative path to the directory where this provider should store the indexes.
    `protected void` | `planUseOfIndex(QueryContext context, IndexCostCalculator calculator, String workspaceName, ManagedIndex index, IndexDefinition defn)` The method that is called by the IndexProvider's `default IndexPlanner` for each managed index in the given workspace.
    `protected void` | `postShutdown()` Method called during #shutdown() after each of the managed indexes have been shutdown.
    `protected void` | `removeIndex(IndexDefinition oldDefn, ManagedIndex existingIndex, String workspaceName)` Method called when this provider needs to remove an existing index given the unique pair of workspace name and index definition.
    `protected ManagedIndex` | `updateIndex(IndexDefinition oldDefn, IndexDefinition updatedDefn, ManagedIndex existingIndex, String workspaceName, NodeTypes.Supplier nodeTypesSupplier, ChangeSetAdapter.NodeTypePredicate matcher, IndexFeedback feedback)` Method called when this provider needs to update an existing index given the unique pair of workspace name and index definition.
    `void` | `validateProposedIndex(ExecutionContext context, IndexDefinition defn, NodeTypes.Supplier nodeTypeSupplier, Problems problems)` Validate the proposed index definition, and use the supplied problems to report any issues that will prevent this provider from creating and using an index with the given definition.

    - ### Methods inherited from class org.modeshape.jcr.spi.index.provider.IndexProvider

      `context, getIndex, getIndexes, getIndexPlanner, getIndexWriter, getName, getRepositoryName, initialize, logger, names, namespaces, notify, notify, notify, onEachIndex, onEachIndexInWorkspace, preShutdown, shutdown, valueFactories`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### LocalIndexProvider

          public LocalIndexProvider()

  - ### Method Detail

    - #### getDirectory

          public String getDirectory()

      Get the absolute or relative path to the directory where this provider should store the indexes.
      Returns:
        the path to the directory

    - #### doInitialize

          protected void doInitialize()
                               throws RepositoryException

      Description copied from class: `IndexProvider`
      Method that should do the provider-specific initialization work. This is called by ModeShape once each time the repository is started; this method should not be called by the provider itself.

      By the time this method is called, ModeShape will hav already set the `IndexProvider.context`, `IndexProvider.logger`, `IndexProvider.name`, and `IndexProvider.repositoryName` plus any fields that match configuration properties for the provider.

      This is an excellent place for providers to validate the provider-specific fields set by ModeShape via reflection during instantiation.

      Specified by:
        `doInitialize` in class `IndexProvider`
      Throws:
        `RepositoryException` - if there is a problem initializing the provider

    - #### postShutdown

          protected void postShutdown()

      Description copied from class: `IndexProvider`
      Method called during #shutdown() after each of the managed indexes have been shutdown.
      Overrides:
        `postShutdown` in class `IndexProvider`

    - #### validateProposedIndex

          public void validateProposedIndex(ExecutionContext context,
                                   IndexDefinition defn,
                                   NodeTypes.Supplier nodeTypeSupplier,
                                   Problems problems)

      Description copied from class: `IndexProvider`
      Validate the proposed index definition, and use the supplied problems to report any issues that will prevent this provider from creating and using an index with the given definition.
      Specified by:
        `validateProposedIndex` in class `IndexProvider`
      Parameters:
        `context` - the execution context in which to perform the validation; never null
        `defn` - the proposed index definition; never null
        `nodeTypeSupplier` - the supplier for the NodeTypes object that contains information about the currently-registered node types; never null
        `problems` - the problems that should be used to report any issues with the index definition; never null

    - #### createIndex

          protected ManagedIndex createIndex(IndexDefinition defn,
                                 String workspaceName,
                                 NodeTypes.Supplier nodeTypesSupplier,
                                 ChangeSetAdapter.NodeTypePredicate matcher,
                                 IndexFeedback feedback)

      Description copied from class: `IndexProvider`
      Method called when this provider needs to create a new index given the unique pair of workspace name and index definition. An index definition can apply to multiple workspaces, and when it does this method will be called once for each applicable workspace.
      Specified by:
        `createIndex` in class `IndexProvider`
      Parameters:
        `defn` - the definition of the index; never null
        `workspaceName` - the name of the actual workspace to which the new index applies; never null
        `nodeTypesSupplier` - the supplier for the current node types cache; never null
        `matcher` - the node type matcher used to determine which nodes should be included in the index, and which automatically updates when node types are changed in the repository; may not be null
        `feedback` - the feedback mechanism for this provider to signal to ModeShape that portions of the repository content must be scanned to build/populate the new index; never null
      Returns:
        the implementation-specific `ManagedIndex` for the new index; may not be null

    - #### updateIndex

          protected ManagedIndex updateIndex(IndexDefinition oldDefn,
                                 IndexDefinition updatedDefn,
                                 ManagedIndex existingIndex,
                                 String workspaceName,
                                 NodeTypes.Supplier nodeTypesSupplier,
                                 ChangeSetAdapter.NodeTypePredicate matcher,
                                 IndexFeedback feedback)

      Description copied from class: `IndexProvider`
      Method called when this provider needs to update an existing index given the unique pair of workspace name and index definition. An index definition can apply to multiple workspaces, and when it is changed this method will be called once for each applicable workspace.
      Specified by:
        `updateIndex` in class `IndexProvider`
      Parameters:
        `oldDefn` - the previous definition of the index; never null
        `updatedDefn` - the updated definition of the index; never null
        `existingIndex` - the existing index prior to this update, as returned from `IndexProvider.createIndex(org.modeshape.jcr.api.index.IndexDefinition, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)` or `IndexProvider.updateIndex(org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.spi.index.provider.ManagedIndex, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)` ; never null
        `workspaceName` - the name of the actual workspace to which the new index applies; never null
        `nodeTypesSupplier` - the supplier for the current node types cache; never null
        `matcher` - the node type matcher used to determine which nodes should be included in the index, and which automatically updates when node types are changed in the repository; may not be null
        `feedback` - the feedback mechanism for this provider to signal to ModeShape that portions of the repository content must be scanned to rebuild/repopulate the updated index; never null
      Returns:
        the operations and provider-specific state for this index; never null

    - #### removeIndex

          protected void removeIndex(IndexDefinition oldDefn,
                         ManagedIndex existingIndex,
                         String workspaceName)

      Description copied from class: `IndexProvider`
      Method called when this provider needs to remove an existing index given the unique pair of workspace name and index definition. An index definition can apply to multiple workspaces, and when it does this method will be called once for each applicable workspace.
      Specified by:
        `removeIndex` in class `IndexProvider`
      Parameters:
        `oldDefn` - the previous definition of the index; never null
        `existingIndex` - the existing index prior to this update, as returned from `IndexProvider.createIndex(org.modeshape.jcr.api.index.IndexDefinition, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)` or `IndexProvider.updateIndex(org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.api.index.IndexDefinition, org.modeshape.jcr.spi.index.provider.ManagedIndex, java.lang.String, org.modeshape.jcr.NodeTypes.Supplier, org.modeshape.jcr.cache.change.ChangeSetAdapter.NodeTypePredicate, org.modeshape.jcr.spi.index.IndexFeedback)` ; never null
        `workspaceName` - the name of the actual workspace to which the new index applies; never null

    - #### planUseOfIndex

          protected void planUseOfIndex(QueryContext context,
                            IndexCostCalculator calculator,
                            String workspaceName,
                            ManagedIndex index,
                            IndexDefinition defn)

      Description copied from class: `IndexProvider`
      The method that is called by the IndexProvider's `default IndexPlanner` for each managed index in the given workspace.

      Subclasses should implement this method to determine and record whether the supplied index can be used by the query against the named workspace.

      The `IndexUsage` class may be useful to determine for a given index definition whether criteria is applicable.

      Specified by:
        `planUseOfIndex` in class `IndexProvider`
      Parameters:
        `context` - the context of the original query; never null
        `calculator` - the calculator that should be used to record plan information for the index; never null
        `workspaceName` - the name of the workspace against which the query is operating; never null
        `index` - the managed index in the given workspace; never null
        `defn` - the definition for the index; never null

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.