Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.modeshape.graph.search
Class SearchableRepositorySource

    java.lang.Object
      org.modeshape.graph.search.SearchableRepositorySource

All Implemented Interfaces:
  Serializable, Referenceable, RepositorySource

    @ThreadSafe
    public class SearchableRepositorySource

extends Object
implements RepositorySource

A `RepositorySource` implementation that can be used as a wrapper around another `non-searchable` or `non-querable` RepositorySource instance to provide search and query capability.

See Also:
  Serialized Form

Nested Class Summary
`protected class` | `SearchableRepositorySource.AbstractConnection`
`protected class` | `SearchableRepositorySource.ParallelConnection` A `RepositoryConnection` implementation that calls the delegate processor in a background thread, allowing the processing of the `FullTextSearchRequest` and `AccessQueryRequest` objects to be done in this thread and in parallel with other requests.
`protected class` | `SearchableRepositorySource.SynchronousConnection` A `RepositoryConnection` implementation that calls the delegate processor in the calling thread.

Constructor Summary
`SearchableRepositorySource(RepositorySource wrapped, SearchEngine searchEngine)` Create a new searchable and queryable RepositorySource around an instance that is neither.
`SearchableRepositorySource(RepositorySource wrapped, SearchEngine searchEngine, ExecutorService executorService, boolean executeAsynchronously, boolean updateIndexesAsynchronously)` Create a new searchable and queryable RepositorySource around an instance that is neither.

Method Summary
`void` | `close()` Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired.
`protected RepositorySource` | `delegate()`
`protected boolean` | `executeRequestsAsynchronously()`
`protected ExecutorService` | `executorService()`
`RepositorySourceCapabilities` | `getCapabilities()` Get the capabilities for this source.
`RepositoryConnection` | `getConnection()` Get a connection from this source.
`String` | `getName()` Get the name for this repository source.
`Reference` | `getReference()`
`int` | `getRetryLimit()` Get the maximum number of retries that may be performed on a given operation when using `connections` created by this source.
`void` | `initialize(RepositoryContext context)` Initialize this source to use the supplied `RepositoryContext`, from which this source can obtain the `configuration` defining this source, `connections` to other `sources`, and the `execution context`.
`protected void` | `process(ExecutionContext context, Changes changes)` Do the work of processing the changes and updating the `searchEngine`.
`protected SearchEngine` | `searchEngine()`
`void` | `setRetryLimit(int limit)` Set the maximum number of retries that may be performed on a given operation when using `connections` created by this source.
`protected boolean` | `updateIndexesAsynchronously()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SearchableRepositorySource

    public SearchableRepositorySource(RepositorySource wrapped,
                                      SearchEngine searchEngine,
                                      ExecutorService executorService,
                                      boolean executeAsynchronously,
                                      boolean updateIndexesAsynchronously)

  Create a new searchable and queryable RepositorySource around an instance that is neither.

  Parameters:
    `wrapped` - the RepositorySource that is not searchable and queryable
    `searchEngine` - the search engine that is to be used
    `executorService` - the ExecutorService that should be used when submitting requests to the wrapped service; may be null if all operations should be performed in the calling thread
    `executeAsynchronously` - true if an `ExecutorService` is provided and the requests to the wrapped source are to be executed asynchronously
    `updateIndexesAsynchronously` - true if an `ExecutorService` is provided and the indexes are to be updated in a different thread than the thread executing the `RepositoryConnection.execute(ExecutionContext, Request)` calls.

### SearchableRepositorySource

    public SearchableRepositorySource(RepositorySource wrapped,
                                      SearchEngine searchEngine)

  Create a new searchable and queryable RepositorySource around an instance that is neither. All of the request processing will be done in the calling thread, and updating the indexes will be done synchronously within the context of the `RepositoryConnection.execute(ExecutionContext, Request)` method (and obviously on the same thread). This means that the execution of the requests will not return until the indexes have been updated with any changes made by the requests.

  This is equivalent to calling `new SearchableRepositorySource(wrapped,searchEngine,null,false)`

  Parameters:
    `wrapped` - the RepositorySource that is not searchable and queryable
    `searchEngine` - the search engine that is to be used

Method Detail

### getName

    public String getName()

  Get the name for this repository source.

  Specified by:
    `getName` in interface `RepositorySource`
  Returns:
    the name; never null or empty
  See Also:
    `RepositorySource.getName()`

### close

    public void close()

  Signal this source that it is no longer needed and should begin the process of reclaiming or closing all resources that it has acquired. Because `connections` may still be in use, this method may not necessarily close all resources immediately.

  This is a required method, and must be called when this source is no longer needed if one or more `connections` have been obtained since the previous call to this method.

  Note that calling this method also does not preclude `obtaining more connections` after this method is called. If that happens, this source should simply reacquire any resources necessary to provide additional connections, and this method needs to be called once again.

  Specified by:
    `close` in interface `RepositorySource`
  See Also:
    `RepositorySource.close()`

### getCapabilities

    public RepositorySourceCapabilities getCapabilities()

  Get the capabilities for this source.

  Specified by:
    `getCapabilities` in interface `RepositorySource`
  Returns:
    the capabilities for this source; never null
  See Also:
    `RepositorySource.getCapabilities()`

### getConnection

    public RepositoryConnection getConnection()
                                       throws RepositorySourceException

  Get a connection from this source. Even though each RepositorySource need not be thread safe, this method should be safe to be called concurrently by multiple threads.

  Specified by:
    `getConnection` in interface `RepositorySource`
  Returns:
    a connection
  Throws:
    `RepositorySourceException` - if there is a problem obtaining a connection
  See Also:
    `RepositorySource.getConnection()`

### getRetryLimit

    public int getRetryLimit()

  Get the maximum number of retries that may be performed on a given operation when using `connections` created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

  Specified by:
    `getRetryLimit` in interface `RepositorySource`
  Returns:
    the maximum number of allowable retries, or 0 if the source has no limit
  See Also:
    `RepositorySource.getRetryLimit()`

### initialize

    public void initialize(RepositoryContext context)
                    throws RepositorySourceException

  Initialize this source to use the supplied `RepositoryContext`, from which this source can obtain the `configuration` defining this source, `connections` to other `sources`, and the `execution context`.

  This method may be called each time the configuration changes, allowing the source to update itself.

  Specified by:
    `initialize` in interface `RepositorySource`
  Throws:
    `RepositorySourceException`
  See Also:
    `RepositorySource.initialize(org.modeshape.graph.connector.RepositoryContext)`

### searchEngine

    protected final SearchEngine searchEngine()

### updateIndexesAsynchronously

    protected final boolean updateIndexesAsynchronously()

### executeRequestsAsynchronously

    protected final boolean executeRequestsAsynchronously()

### executorService

    protected final ExecutorService executorService()

### delegate

    protected final RepositorySource delegate()

### process

    protected void process(ExecutionContext context,
                           Changes changes)

  Do the work of processing the changes and updating the `searchEngine`. This method may be called while on one of the threads owned by the `executor service` (if `updateIndexesAsynchronously()` returns true), or from the thread `executing` the requests on the `delegate` (if `updateIndexesAsynchronously()` returns false).

  Parameters:
    `context` - the execution context in which the indexes should be updated
    `changes` - the changes; never null

### setRetryLimit

    public void setRetryLimit(int limit)

  Set the maximum number of retries that may be performed on a given operation when using `connections` created by this source. This value does not constitute a minimum number of retries; in fact, the connection user is not required to retry any operations.

  Specified by:
    `setRetryLimit` in interface `RepositorySource`
  Parameters:
    `limit` - the maximum number of allowable retries, or 0 if the source has no limit
  See Also:
    `RepositorySource.setRetryLimit(int)`

### getReference

    public Reference getReference()
                           throws NamingException

  Specified by:
    `getReference` in interface `Referenceable`
  Throws:
    `NamingException`
  See Also:
    `Referenceable.getReference()`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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