org.eclipse.rdf4j.repository.event.base

## Class InterceptingRepositoryWrapper

- java.lang.Object
- - org.eclipse.rdf4j.repository.base.RepositoryWrapper
  - - org.eclipse.rdf4j.repository.event.base.InterceptingRepositoryWrapper

- All Implemented Interfaces:
    DelegatingRepository, InterceptingRepository, Repository

      public class InterceptingRepositoryWrapper
      extends RepositoryWrapper
      implements InterceptingRepository

  Wrapper that notifies interceptors of events on Repositories before they happen. Any interceptor can block the operation by returning true from the relevant notification method. To do so will also cause the notification process to stop, i.e. no other interceptors will be notified. The order in which interceptors are notified is unspecified.
  Author:
    Herko ter Horst
  See Also:
    `InterceptingRepositoryConnectionWrapper`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `InterceptingRepositoryWrapper()`
    `InterceptingRepositoryWrapper(Repository delegate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)` Registers a `RepositoryConnectionInterceptor` that will receive notifications of operations that are performed on any connections that are created by this repository.
    `void` | `addRepositoryInterceptor(RepositoryInterceptor interceptor)` Registers a `RepositoryInterceptor` that will receive notifications of operations that are performed on this repository.
    `InterceptingRepositoryConnection` | `getConnection()` Opens a connection to this repository that can be used for querying and updating the contents of the repository.
    `void` | `initialize()` Initializes this repository.
    `void` | `removeRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)` Removes a registered `RepositoryConnectionInterceptor` from this repository.
    `void` | `removeRepositoryInterceptor(RepositoryInterceptor interceptor)` Removes a registered `RepositoryInterceptor` from this repository.
    `void` | `setDataDir(File dataDir)` Set the directory where data and logging for this repository is stored.
    `void` | `shutDown()` Shuts the repository down, releasing any resources that it keeps hold of.

    - ### Methods inherited from class org.eclipse.rdf4j.repository.base.RepositoryWrapper

      `getDataDir, getDelegate, getValueFactory, isInitialized, isWritable, setDelegate, toString`

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

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

    - ### Methods inherited from interface org.eclipse.rdf4j.repository.Repository

      `getDataDir, getValueFactory, init, isInitialized, isWritable`

- - ### Constructor Detail

    - #### InterceptingRepositoryWrapper

          public InterceptingRepositoryWrapper()

    - #### InterceptingRepositoryWrapper

          public InterceptingRepositoryWrapper(Repository delegate)

  - ### Method Detail

    - #### addRepositoryInterceptor

          public void addRepositoryInterceptor(RepositoryInterceptor interceptor)

      Registers a `RepositoryInterceptor` that will receive notifications of operations that are performed on this repository.
      Specified by:
        `addRepositoryInterceptor` in interface `InterceptingRepository`

    - #### removeRepositoryInterceptor

          public void removeRepositoryInterceptor(RepositoryInterceptor interceptor)

      Removes a registered `RepositoryInterceptor` from this repository.
      Specified by:
        `removeRepositoryInterceptor` in interface `InterceptingRepository`

    - #### addRepositoryConnectionInterceptor

          public void addRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)

      Registers a `RepositoryConnectionInterceptor` that will receive notifications of operations that are performed on any connections that are created by this repository.
      Specified by:
        `addRepositoryConnectionInterceptor` in interface `InterceptingRepository`

    - #### removeRepositoryConnectionInterceptor

          public void removeRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)

      Removes a registered `RepositoryConnectionInterceptor` from this repository.
      Specified by:
        `removeRepositoryConnectionInterceptor` in interface `InterceptingRepository`

    - #### getConnection

          public InterceptingRepositoryConnection getConnection()
                                                         throws RepositoryException

      Description copied from interface: `Repository`
      Opens a connection to this repository that can be used for querying and updating the contents of the repository. Created connections need to be closed to make sure that any resources they keep hold of are released. The best way to do this is to use a try-with-resources block, as follows:

           try (RepositoryConnection conn = repository.getConnection()) {
                  // perform operations on the connection
           }

      Note that `RepositoryConnection` is not guaranteed to be thread-safe! The recommended pattern for repository access in a multi-threaded application is to share the Repository object between threads, but have each thread create and use its own `RepositoryConnection`s.
      Specified by:
        `getConnection` in interface `Repository`
      Overrides:
        `getConnection` in class `RepositoryWrapper`
      Returns:
        A connection that allows operations on this repository.
      Throws:
        `RepositoryException` - If something went wrong during the creation of the Connection.

    - #### initialize

          public void initialize()
                          throws RepositoryException

      Description copied from interface: `Repository`
      Initializes this repository.
      Specified by:
        `initialize` in interface `Repository`
      Overrides:
        `initialize` in class `RepositoryWrapper`
      Throws:
        `RepositoryException` - If the initialization failed.

    - #### setDataDir

          public void setDataDir(File dataDir)

      Description copied from interface: `Repository`
      Set the directory where data and logging for this repository is stored.
      Specified by:
        `setDataDir` in interface `Repository`
      Overrides:
        `setDataDir` in class `RepositoryWrapper`
      Parameters:
        `dataDir` - the directory where data for this repository is stored

    - #### shutDown

          public void shutDown()
                        throws RepositoryException

      Description copied from interface: `Repository`
      Shuts the repository down, releasing any resources that it keeps hold of. Once shut down, the repository can no longer be used until it is re-initialized.
      Specified by:
        `shutDown` in interface `Repository`
      Overrides:
        `shutDown` in class `RepositoryWrapper`
      Throws:
        `RepositoryException`

Copyright © 2015-2021 Eclipse Foundation. All Rights Reserved.