ca.sqlpower.wabit.rs
Interface ResultSetProducer

All Superinterfaces:
ca.sqlpower.object.SPObject, WabitBackgroundWorker, WabitObject
All Known Implementing Classes:
OlapQuery, QueryCache

public interface ResultSetProducer
extends WabitBackgroundWorker

Interface that provides all necessary methods for working with any type of WabitObject that can produce a ResultSet.


Method Summary
 void addResultSetListener(ResultSetListener listener)
          Adds the given listener to this result set producer's list of interested parties.
 java.util.concurrent.Future<ResultSetAndUpdateCountCollection> execute()
          Executes the current query represented by this object, returning the results from the query's execution.
 void removeResultSetListener(ResultSetListener listener)
          Removes the given listener from the listener list.
 
Methods inherited from interface ca.sqlpower.wabit.WabitBackgroundWorker
cancel, isRunning
 
Methods inherited from interface ca.sqlpower.wabit.WabitObject
getParent
 
Methods inherited from interface ca.sqlpower.object.SPObject
addChild, addSPListener, allowsChildren, begin, childPositionOffset, cleanup, commit, generateNewUUID, getChildren, getChildren, getDependencies, getName, getSession, getUUID, removeChild, removeDependency, removeSPListener, rollback, setName, setParent, setUUID
 

Method Detail

execute

java.util.concurrent.Future<ResultSetAndUpdateCountCollection> execute()
                                                                       throws ResultSetProducerException,
                                                                              java.lang.InterruptedException
Executes the current query represented by this object, returning the results from the query's execution.

Every call to this method causes a ResultSetEvent to be fired, whether or not the call simply returns the same cached results as a previous invocation.

If the query is in a state where it can't be executed (because it is not sufficiently configured to issue a sensible query, or because the connection to the data source can't be established), the event will still be fired if it results in a state change from the previous execution attempt. In these cases, the event will deliver a null ResultSet to listeners.

Implementations of ResultSetProducer are allowed to fire the ResultSetEvent while the query is locked against concurrent and/or recursive execution, so it is vitally important that ResultSetListeners do not attempt to re-execute the query in response to any ResultSetEvent. Such behaviour by ResultSetListeners is unsafe in general, and may cause deadlock.

Returns:
The results of executing of the query. If the query is not currently in a state where it can be executed, this method returns null and fires a ResultSetEvent with a null result set.
Throws:
ResultSetProducerException - If there was any problem obtaining the result set
java.lang.InterruptedException - If the calling thread is interrupted while blocked waiting for another call to execute() to complete.

addResultSetListener

void addResultSetListener(@Nonnull
                          ResultSetListener listener)
Adds the given listener to this result set producer's list of interested parties. Each listener on the list receives an event whenever a new result set is available (as a result of the query be executed).

Parameters:
listener - The listener to add (must not be null).

removeResultSetListener

void removeResultSetListener(ResultSetListener listener)
Removes the given listener from the listener list. Has no effect if the given listener was not already on the list.

Parameters:
listener - The listener to remove. Nulls are ignored.


Copyright © 2009. All Rights Reserved.