Class InterceptingRepositoryConnectionWrapper
- java.lang.Object
-
- org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
-
- org.eclipse.rdf4j.repository.base.RepositoryConnectionWrapper
-
- org.eclipse.rdf4j.repository.event.base.InterceptingRepositoryConnectionWrapper
-
- All Implemented Interfaces:
AutoCloseable,DelegatingRepositoryConnection,InterceptingRepositoryConnection,RepositoryConnection
public class InterceptingRepositoryConnectionWrapper extends RepositoryConnectionWrapper implements InterceptingRepositoryConnection
Wrapper that notifies interceptors of events on RepositoryConnections 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:
InterceptingRepositoryWrapper
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
logger
-
-
Constructor Summary
Constructors Constructor Description InterceptingRepositoryConnectionWrapper(Repository repository, RepositoryConnection connection)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)Registers a RepositoryConnectionInterceptor that will receive notifications of operations that are performed on this connection.voidaddWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts)voidbegin()Begins a new transaction, requiringRepositoryConnection.commit()orRepositoryConnection.rollback()to be called to end the transaction.voidclear(Resource... contexts)Removes all statements from a specific contexts in the repository.voidclearNamespaces()Removes all namespace declarations from the repository.voidclose()Closes the connection, freeing resources.voidcommit()Commits the active transaction.protected booleanisDelegatingAdd()If false then the following add methods will callRepositoryConnectionWrapper.addWithoutCommit(Resource, IRI, Value, Resource[]).protected booleanisDelegatingRemove()If false then the following remove methods will callRepositoryConnectionWrapper.removeWithoutCommit(Resource, IRI, Value, Resource[]).UpdateprepareUpdate(QueryLanguage ql, String update, String baseURI)Prepares an Update operation.voidremoveNamespace(String prefix)Removes a namespace declaration by removing the association between a prefix and a namespace name.voidremoveRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)Removes a registered RepositoryConnectionInterceptor from this connection.voidremoveWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts)voidrollback()Rolls back all updates in the active transaction.voidsetAutoCommit(boolean autoCommit)Deprecated.voidsetNamespace(String prefix, String name)Sets the prefix for a namespace.-
Methods inherited from class org.eclipse.rdf4j.repository.base.RepositoryConnectionWrapper
add, add, add, add, add, add, add, add, begin, begin, exportStatements, exportStatements, getContextIDs, getDelegate, getIsolationLevel, getNamespace, getNamespaces, getStatements, hasStatement, hasStatement, isActive, isAutoCommit, isDelegatingRead, isEmpty, isOpen, prepare, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, remove, remove, remove, remove, setDelegate, setIsolationLevel, setParserConfig, size
-
Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
addWithoutCommit, conditionalCommit, conditionalRollback, export, getParserConfig, getRepository, getValueFactory, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, prepareUpdate, removeWithoutCommit, startLocalTransaction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.eclipse.rdf4j.repository.RepositoryConnection
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, begin, begin, export, exportStatements, getContextIDs, getIsolationLevel, getNamespace, getNamespaces, getParserConfig, getRepository, getStatements, getStatements, getValueFactory, hasStatement, hasStatement, isActive, isAutoCommit, isEmpty, isOpen, prepare, prepareBooleanQuery, prepareBooleanQuery, prepareBooleanQuery, prepareGraphQuery, prepareGraphQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareTupleQuery, prepareTupleQuery, prepareUpdate, prepareUpdate, remove, remove, remove, remove, remove, remove, setIsolationLevel, setParserConfig, size
-
-
-
-
Constructor Detail
-
InterceptingRepositoryConnectionWrapper
public InterceptingRepositoryConnectionWrapper(Repository repository, RepositoryConnection connection)
-
-
Method Detail
-
addRepositoryConnectionInterceptor
public void addRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)
Registers a RepositoryConnectionInterceptor that will receive notifications of operations that are performed on this connection.- Specified by:
addRepositoryConnectionInterceptorin interfaceInterceptingRepositoryConnection
-
removeRepositoryConnectionInterceptor
public void removeRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)
Removes a registered RepositoryConnectionInterceptor from this connection.- Specified by:
removeRepositoryConnectionInterceptorin interfaceInterceptingRepositoryConnection
-
isDelegatingAdd
protected boolean isDelegatingAdd()
Description copied from class:RepositoryConnectionWrapperIf false then the following add methods will callRepositoryConnectionWrapper.addWithoutCommit(Resource, IRI, Value, Resource[]).- Overrides:
isDelegatingAddin classRepositoryConnectionWrapper- Returns:
trueto delegate add methods,falseto callRepositoryConnectionWrapper.addWithoutCommit(Resource, IRI, Value, Resource[])- See Also:
RepositoryConnectionWrapper.add(Iterable, Resource...),RepositoryConnectionWrapper.add(Iteration, Resource...),RepositoryConnectionWrapper.add(Statement, Resource...),RepositoryConnectionWrapper.add(File, String, RDFFormat, Resource...),RepositoryConnectionWrapper.add(InputStream, String, RDFFormat, Resource...),RepositoryConnectionWrapper.add(Reader, String, RDFFormat, Resource...),RepositoryConnectionWrapper.add(Resource, IRI, Value, Resource...),RepositoryConnectionWrapper.add(URL, String, RDFFormat, Resource...)
-
isDelegatingRemove
protected boolean isDelegatingRemove()
Description copied from class:RepositoryConnectionWrapperIf false then the following remove methods will callRepositoryConnectionWrapper.removeWithoutCommit(Resource, IRI, Value, Resource[]).- Overrides:
isDelegatingRemovein classRepositoryConnectionWrapper- Returns:
trueto delegate remove methods,falseto callRepositoryConnectionWrapper.removeWithoutCommit(Resource, IRI, Value, Resource...)- See Also:
RepositoryConnectionWrapper.clear(Resource...),RepositoryConnectionWrapper.remove(Iterable, Resource...),RepositoryConnectionWrapper.remove(Iteration, Resource...),RepositoryConnectionWrapper.remove(Statement, Resource...),RepositoryConnectionWrapper.remove(Resource, IRI, Value, Resource...)
-
addWithoutCommit
public void addWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException
- Overrides:
addWithoutCommitin classRepositoryConnectionWrapper- Throws:
RepositoryException
-
clear
public void clear(Resource... contexts) throws RepositoryException
Description copied from interface:RepositoryConnectionRemoves all statements from a specific contexts in the repository.- Specified by:
clearin interfaceRepositoryConnection- Overrides:
clearin classRepositoryConnectionWrapper- Parameters:
contexts- The context(s) to remove the data from. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
RepositoryException- If the statements could not be removed from the repository, for example because the repository is not writable.
-
begin
public void begin() throws RepositoryExceptionDescription copied from interface:RepositoryConnectionBegins a new transaction, requiringRepositoryConnection.commit()orRepositoryConnection.rollback()to be called to end the transaction. The transaction will use the currently setisolation levelfor this connection.- Specified by:
beginin interfaceRepositoryConnection- Overrides:
beginin classRepositoryConnectionWrapper- Throws:
RepositoryException- If the connection could not start the transaction. One possible reason this may happen is if a transaction is alreadyactiveon the current connection.- See Also:
RepositoryConnection.begin(IsolationLevel),RepositoryConnection.isActive(),RepositoryConnection.commit(),RepositoryConnection.rollback(),RepositoryConnection.setIsolationLevel(IsolationLevel)
-
close
public void close() throws RepositoryExceptionDescription copied from interface:RepositoryConnectionCloses the connection, freeing resources. If atransactionisactiveon the connection, all non-committed operations will be lost by actively callingRepositoryConnection.rollback()on any active transactions.Implementation note: All implementations must override this method if they have any resources that they need to free.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceRepositoryConnection- Overrides:
closein classRepositoryConnectionWrapper- Throws:
RepositoryException- If the connection could not be closed.
-
commit
public void commit() throws RepositoryExceptionDescription copied from interface:RepositoryConnectionCommits the active transaction. This operation ends the active transaction.- Specified by:
commitin interfaceRepositoryConnection- Overrides:
commitin classRepositoryConnectionWrapper- Throws:
UnknownTransactionStateException- if the transaction state can not be determined. This can happen for instance when communication with a repository fails or times out.RepositoryException- If the connection could not be committed, or if the connection does not have an active transaction.- See Also:
RepositoryConnection.isActive(),RepositoryConnection.begin(),RepositoryConnection.rollback(),RepositoryConnection.prepare()
-
removeWithoutCommit
public void removeWithoutCommit(Resource subject, IRI predicate, Value object, Resource... contexts) throws RepositoryException
- Overrides:
removeWithoutCommitin classRepositoryConnectionWrapper- Throws:
RepositoryException
-
removeNamespace
public void removeNamespace(String prefix) throws RepositoryException
Description copied from interface:RepositoryConnectionRemoves a namespace declaration by removing the association between a prefix and a namespace name.- Specified by:
removeNamespacein interfaceRepositoryConnection- Overrides:
removeNamespacein classRepositoryConnectionWrapper- Parameters:
prefix- The namespace prefix, or an empty string in case of the default namespace.- Throws:
RepositoryException- If the namespace prefix could not be removed.
-
clearNamespaces
public void clearNamespaces() throws RepositoryExceptionDescription copied from interface:RepositoryConnectionRemoves all namespace declarations from the repository.- Specified by:
clearNamespacesin interfaceRepositoryConnection- Overrides:
clearNamespacesin classRepositoryConnectionWrapper- Throws:
RepositoryException- If the namespace declarations could not be removed.
-
rollback
public void rollback() throws RepositoryExceptionDescription copied from interface:RepositoryConnectionRolls back all updates in the active transaction. This operation ends the active transaction.- Specified by:
rollbackin interfaceRepositoryConnection- Overrides:
rollbackin classRepositoryConnectionWrapper- Throws:
UnknownTransactionStateException- if the transaction state can not be determined. This can happen for instance when communication with a repository fails or times out.RepositoryException- If the transaction could not be rolled back, or if the connection does not have an active transaction.- See Also:
RepositoryConnection.isActive(),RepositoryConnection.begin(),RepositoryConnection.commit()
-
setAutoCommit
@Deprecated public void setAutoCommit(boolean autoCommit) throws RepositoryException
Deprecated.Description copied from interface:RepositoryConnectionEnables or disables auto-commit mode for the connection. If a connection is in auto-commit mode, then all updates will be executed and committed as individual transactions. Otherwise, the updates are grouped into transactions that are terminated by a call to eitherRepositoryConnection.commit()orRepositoryConnection.rollback(). By default, new connections are in auto-commit mode.NOTE: If this connection is switched to auto-commit mode during a transaction, the transaction is committed.
- Specified by:
setAutoCommitin interfaceRepositoryConnection- Overrides:
setAutoCommitin classRepositoryConnectionWrapper- Throws:
RepositoryException- In case the mode switch failed, for example because a currently active transaction failed to commit.- See Also:
RepositoryConnection.commit()
-
setNamespace
public void setNamespace(String prefix, String name) throws RepositoryException
Description copied from interface:RepositoryConnectionSets the prefix for a namespace.- Specified by:
setNamespacein interfaceRepositoryConnection- Overrides:
setNamespacein classRepositoryConnectionWrapper- Parameters:
prefix- The new prefix, or an empty string in case of the default namespace.name- The namespace name that the prefix maps to.- Throws:
RepositoryException- If the namespace could not be set in the repository, for example because the repository is not writable.
-
prepareUpdate
public Update prepareUpdate(QueryLanguage ql, String update, String baseURI) throws MalformedQueryException, RepositoryException
Description copied from interface:RepositoryConnectionPrepares an Update operation.- Specified by:
prepareUpdatein interfaceRepositoryConnection- Overrides:
prepareUpdatein classRepositoryConnectionWrapper- Parameters:
ql- Thequery languagein which the update operation is formulated.update- The update operation string.baseURI- The base URI to resolve any relative URIs that are in the update against, can be null if the update does not contain any relative URIs.- Returns:
- a
Updateready to be executed on thisRepositoryConnection. - Throws:
MalformedQueryException- If the supplied update operation string is malformed.RepositoryException
-
-