org.openrdf.repository.event.base
Class InterceptingRepositoryConnectionWrapper

java.lang.Object
  extended by org.openrdf.repository.base.RepositoryConnectionBase
      extended by org.openrdf.repository.base.RepositoryConnectionWrapper
          extended by org.openrdf.repository.event.base.InterceptingRepositoryConnectionWrapper
All Implemented Interfaces:
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.openrdf.repository.base.RepositoryConnectionBase
logger
 
Constructor Summary
InterceptingRepositoryConnectionWrapper(Repository repository, RepositoryConnection connection)
           
 
Method Summary
 void addRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)
          Registers a RepositoryConnectionInterceptor that will receive notifications of operations that are performed on this connection.
 void addWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts)
           
 void clear(Resource... contexts)
          Removes all statements from a specific contexts in the repository.
 void clearNamespaces()
          Removes all namespace declarations from the repository.
 void close()
          Closes the connection, freeing resources.
 void commit()
          Commits all updates that have been performed as part of this connection sofar.
protected  boolean isDelegatingAdd()
          If true then each add method will call RepositoryConnectionWrapper.addWithoutCommit(Resource, URI, Value, Resource[]).
protected  boolean isDelegatingRemove()
          If true then each remove method will call RepositoryConnectionWrapper.removeWithoutCommit(Resource, URI, Value, Resource[]).
 void removeNamespace(String prefix)
          Removes a namespace declaration by removing the association between a prefix and a namespace name.
 void removeRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)
          Removes a registered RepositoryConnectionInterceptor from this connection.
 void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts)
           
 void rollback()
          Rolls back all updates that have been performed as part of this connection sofar.
 void setAutoCommit(boolean autoCommit)
          Enables or disables auto-commit mode for the connection.
 void setNamespace(String prefix, String name)
          Sets the prefix for a namespace.
 
Methods inherited from class org.openrdf.repository.base.RepositoryConnectionWrapper
add, add, add, add, add, add, add, add, exportStatements, exportStatements, getContextIDs, getDelegate, getNamespace, getNamespaces, getStatements, hasStatement, hasStatement, isAutoCommit, isDelegatingRead, isEmpty, isOpen, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, remove, remove, remove, remove, setDelegate, size
 
Methods inherited from class org.openrdf.repository.base.RepositoryConnectionBase
addInputStreamOrReader, addWithoutCommit, autoCommit, export, finalize, getRepository, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, removeWithoutCommit
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openrdf.repository.RepositoryConnection
add, add, add, add, add, add, add, add, export, exportStatements, getContextIDs, getNamespace, getNamespaces, getRepository, getStatements, hasStatement, hasStatement, isAutoCommit, isEmpty, isOpen, prepareBooleanQuery, prepareBooleanQuery, prepareGraphQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareTupleQuery, remove, remove, remove, remove, 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:
addRepositoryConnectionInterceptor in interface InterceptingRepositoryConnection

removeRepositoryConnectionInterceptor

public void removeRepositoryConnectionInterceptor(RepositoryConnectionInterceptor interceptor)
Removes a registered RepositoryConnectionInterceptor from this connection.

Specified by:
removeRepositoryConnectionInterceptor in interface InterceptingRepositoryConnection

isDelegatingAdd

protected boolean isDelegatingAdd()
Description copied from class: RepositoryConnectionWrapper
If true then each add method will call RepositoryConnectionWrapper.addWithoutCommit(Resource, URI, Value, Resource[]).

Overrides:
isDelegatingAdd in class RepositoryConnectionWrapper
Returns:
false

isDelegatingRemove

protected boolean isDelegatingRemove()
Description copied from class: RepositoryConnectionWrapper
If true then each remove method will call RepositoryConnectionWrapper.removeWithoutCommit(Resource, URI, Value, Resource[]).

Overrides:
isDelegatingRemove in class RepositoryConnectionWrapper
Returns:
false

addWithoutCommit

public void addWithoutCommit(Resource subject,
                             URI predicate,
                             Value object,
                             Resource... contexts)
                      throws RepositoryException
Overrides:
addWithoutCommit in class RepositoryConnectionWrapper
Throws:
RepositoryException

clear

public void clear(Resource... contexts)
           throws RepositoryException
Description copied from interface: RepositoryConnection
Removes all statements from a specific contexts in the repository.

Specified by:
clear in interface RepositoryConnection
Overrides:
clear in class RepositoryConnectionWrapper
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.

close

public void close()
           throws RepositoryException
Description copied from interface: RepositoryConnection
Closes the connection, freeing resources. If the connection is not in autoCommit mode, all non-committed operations will be lost.

Specified by:
close in interface RepositoryConnection
Overrides:
close in class RepositoryConnectionWrapper
Throws:
RepositoryException - If the connection could not be closed.

commit

public void commit()
            throws RepositoryException
Description copied from interface: RepositoryConnection
Commits all updates that have been performed as part of this connection sofar.

Specified by:
commit in interface RepositoryConnection
Overrides:
commit in class RepositoryConnectionWrapper
Throws:
RepositoryException - If the connection could not be committed.

removeWithoutCommit

public void removeWithoutCommit(Resource subject,
                                URI predicate,
                                Value object,
                                Resource... contexts)
                         throws RepositoryException
Overrides:
removeWithoutCommit in class RepositoryConnectionWrapper
Throws:
RepositoryException

removeNamespace

public void removeNamespace(String prefix)
                     throws RepositoryException
Description copied from interface: RepositoryConnection
Removes a namespace declaration by removing the association between a prefix and a namespace name.

Specified by:
removeNamespace in interface RepositoryConnection
Overrides:
removeNamespace in class RepositoryConnectionWrapper
Parameters:
prefix - The namespace prefix of which the assocation with a namespace name is to be removed.
Throws:
RepositoryException - If the namespace prefix could not be removed.

clearNamespaces

public void clearNamespaces()
                     throws RepositoryException
Description copied from interface: RepositoryConnection
Removes all namespace declarations from the repository.

Specified by:
clearNamespaces in interface RepositoryConnection
Overrides:
clearNamespaces in class RepositoryConnectionWrapper
Throws:
RepositoryException - If the namespace declarations could not be removed.

rollback

public void rollback()
              throws RepositoryException
Description copied from interface: RepositoryConnection
Rolls back all updates that have been performed as part of this connection sofar.

Specified by:
rollback in interface RepositoryConnection
Overrides:
rollback in class RepositoryConnectionWrapper
Throws:
RepositoryException - If the connection could not be rolled back.

setAutoCommit

public void setAutoCommit(boolean autoCommit)
                   throws RepositoryException
Description copied from interface: RepositoryConnection
Enables 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 either RepositoryConnection.commit() or RepositoryConnection.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:
setAutoCommit in interface RepositoryConnection
Overrides:
setAutoCommit in class RepositoryConnectionWrapper
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: RepositoryConnection
Sets the prefix for a namespace.

Specified by:
setNamespace in interface RepositoryConnection
Overrides:
setNamespace in class RepositoryConnectionWrapper
Parameters:
prefix - The new prefix.
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.


Copyright © 2001-2007 Aduna. All Rights Reserved.