Class NotifyingRepositoryWrapper
- java.lang.Object
-
- org.eclipse.rdf4j.repository.base.RepositoryWrapper
-
- org.eclipse.rdf4j.repository.event.base.NotifyingRepositoryWrapper
-
- All Implemented Interfaces:
DelegatingRepository,NotifyingRepository,Repository
public class NotifyingRepositoryWrapper extends RepositoryWrapper implements NotifyingRepository
This notifying decorator allows listeners to register with the repository or connection and be notified when events occur.- Author:
- James Leigh, Herko ter Horst, Arjohn Kampman
- See Also:
NotifyingRepositoryConnectionWrapper
-
-
Constructor Summary
Constructors Constructor Description NotifyingRepositoryWrapper()NotifyingRepositoryWrapper(Repository delegate)NotifyingRepositoryWrapper(Repository delegate, boolean defaultReportDeltas)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRepositoryConnectionListener(RepositoryConnectionListener listener)Registers a RepositoryConnectionListener that will receive notifications of operations that are performed on any< connections that are created by this repository.voidaddRepositoryListener(RepositoryListener listener)Registers a RepositoryListener that will receive notifications of operations that are performed on this repository.NotifyingRepositoryConnectiongetConnection()Opens a connection to this repository that can be used for querying and updating the contents of the repository.booleangetDefaultReportDeltas()voidinit()Initializes this repository.voidremoveRepositoryConnectionListener(RepositoryConnectionListener listener)Removes a registered RepositoryConnectionListener from this repository.voidremoveRepositoryListener(RepositoryListener listener)Removes a registered RepositoryListener from this repository.voidsetDataDir(File dataDir)Set the directory where data and logging for this repository is stored.voidsetDefaultReportDeltas(boolean defaultReportDeltas)voidshutDown()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, isInitialized, isWritable
-
-
-
-
Constructor Detail
-
NotifyingRepositoryWrapper
public NotifyingRepositoryWrapper()
-
NotifyingRepositoryWrapper
public NotifyingRepositoryWrapper(Repository delegate)
-
NotifyingRepositoryWrapper
public NotifyingRepositoryWrapper(Repository delegate, boolean defaultReportDeltas)
-
-
Method Detail
-
getDefaultReportDeltas
public boolean getDefaultReportDeltas()
-
setDefaultReportDeltas
public void setDefaultReportDeltas(boolean defaultReportDeltas)
-
addRepositoryListener
public void addRepositoryListener(RepositoryListener listener)
Registers a RepositoryListener that will receive notifications of operations that are performed on this repository.- Specified by:
addRepositoryListenerin interfaceNotifyingRepository
-
removeRepositoryListener
public void removeRepositoryListener(RepositoryListener listener)
Removes a registered RepositoryListener from this repository.- Specified by:
removeRepositoryListenerin interfaceNotifyingRepository
-
addRepositoryConnectionListener
public void addRepositoryConnectionListener(RepositoryConnectionListener listener)
Registers a RepositoryConnectionListener that will receive notifications of operations that are performed on any< connections that are created by this repository.- Specified by:
addRepositoryConnectionListenerin interfaceNotifyingRepository
-
removeRepositoryConnectionListener
public void removeRepositoryConnectionListener(RepositoryConnectionListener listener)
Removes a registered RepositoryConnectionListener from this repository.- Specified by:
removeRepositoryConnectionListenerin interfaceNotifyingRepository
-
getConnection
public NotifyingRepositoryConnection getConnection() throws RepositoryException
Description copied from interface:RepositoryOpens 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
RepositoryConnectionis 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 ownRepositoryConnections.- Specified by:
getConnectionin interfaceNotifyingRepository- Specified by:
getConnectionin interfaceRepository- Overrides:
getConnectionin classRepositoryWrapper- Returns:
- A connection that allows operations on this repository.
- Throws:
RepositoryException- If something went wrong during the creation of the Connection.
-
init
public void init() throws RepositoryExceptionDescription copied from interface:RepositoryInitializes this repository. A repository needs to be initialized before it can be used, however explicitly calling this method is not necessary: the repository will automatically initialize itself if an operation is executed on it that requires it to be initialized.- Specified by:
initin interfaceRepository- Overrides:
initin classRepositoryWrapper- Throws:
RepositoryException- If the initialization failed.
-
setDataDir
public void setDataDir(File dataDir)
Description copied from interface:RepositorySet the directory where data and logging for this repository is stored.- Specified by:
setDataDirin interfaceRepository- Overrides:
setDataDirin classRepositoryWrapper- Parameters:
dataDir- the directory where data for this repository is stored
-
shutDown
public void shutDown() throws RepositoryExceptionDescription copied from interface:RepositoryShuts 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:
shutDownin interfaceRepository- Overrides:
shutDownin classRepositoryWrapper- Throws:
RepositoryException
-
-