org.openrdf.repository.event.base
Class NotifyingRepositoryConnectionWrapper

java.lang.Object
  extended by org.openrdf.repository.base.RepositoryConnectionBase
      extended by org.openrdf.repository.base.RepositoryConnectionWrapper
          extended by org.openrdf.repository.event.base.NotifyingRepositoryConnectionWrapper
All Implemented Interfaces:
DelegatingRepositoryConnection, NotifyingRepositoryConnection, RepositoryConnection

public class NotifyingRepositoryConnectionWrapper
extends RepositoryConnectionWrapper
implements NotifyingRepositoryConnection

This broadcaster is used by the RepositoryBroadcaster to wrap the delegate repository connection. Listeners are notified of changes after they have occurred.

Author:
James Leigh, Herko ter Horst

Field Summary
 
Fields inherited from class org.openrdf.repository.base.RepositoryConnectionBase
logger
 
Constructor Summary
NotifyingRepositoryConnectionWrapper(Repository repository, RepositoryConnection connection)
           
NotifyingRepositoryConnectionWrapper(Repository repository, RepositoryConnection connection, boolean reportDeltas)
           
 
Method Summary
 void addRepositoryConnectionListener(RepositoryConnectionListener listener)
          Registers a RepositoryConnectionListener 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 removeRepositoryConnectionListener(RepositoryConnectionListener listener)
          Removes a registered RepositoryConnectionListener from this connection.
 void removeWithoutCommit(Resource subj, URI pred, Value obj, Resource... ctx)
           
 boolean reportDeltas()
           
 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.
 void setReportDeltas(boolean reportDeltas)
           
 
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, getRepository, getValueFactory, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, removeWithoutCommit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, 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, getValueFactory, hasStatement, hasStatement, isAutoCommit, isEmpty, isOpen, prepareBooleanQuery, prepareBooleanQuery, prepareGraphQuery, prepareGraphQuery, prepareQuery, prepareQuery, prepareTupleQuery, prepareTupleQuery, remove, remove, remove, remove, size
 

Constructor Detail

NotifyingRepositoryConnectionWrapper

public NotifyingRepositoryConnectionWrapper(Repository repository,
                                            RepositoryConnection connection)

NotifyingRepositoryConnectionWrapper

public NotifyingRepositoryConnectionWrapper(Repository repository,
                                            RepositoryConnection connection,
                                            boolean reportDeltas)
Method Detail

reportDeltas

public boolean reportDeltas()

setReportDeltas

public void setReportDeltas(boolean reportDeltas)

addRepositoryConnectionListener

public void addRepositoryConnectionListener(RepositoryConnectionListener listener)
Registers a RepositoryConnectionListener that will receive notifications of operations that are performed on this connection.

Specified by:
addRepositoryConnectionListener in interface NotifyingRepositoryConnection

removeRepositoryConnectionListener

public void removeRepositoryConnectionListener(RepositoryConnectionListener listener)
Removes a registered RepositoryConnectionListener from this connection.

Specified by:
removeRepositoryConnectionListener in interface NotifyingRepositoryConnection

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 subj,
                                URI pred,
                                Value obj,
                                Resource... ctx)
                         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-2010 Aduna. All Rights Reserved.