Class QueryListenerWrapper

java.lang.Object
com.streambase.liveview.client.QueryListenerWrapper
All Implemented Interfaces:
Query, QueryListener, Closeable, AutoCloseable, EventListener

public class QueryListenerWrapper extends Object implements QueryListener, Query
This class is used by LiveViewMultiConnectionImpl to wrap BOTH the queryListener that the user passes in to an execQuery, AND the Query that is passed back to him. We need the former so that we can intercept the close command that comes from the server going down -- we don't actually close the query, we just save it so that it can be failed over to a new server. We need to wrap the Query so that we can intercept with the client calls close on his own. In that case, we want to actually close the query, plus we want to remove this query from our list of ones that need to be reconnected to any new server.
  • Constructor Details

    • QueryListenerWrapper

      public QueryListenerWrapper(com.streambase.liveview.client.internal.ws.LiveViewMultiConnectionImpl liveViewMultiConnectionImpl, QueryConfig config, QueryListener qListener)
      Parameters:
      config -
      qListener -
      liveViewMultiConnectionImpl -
  • Method Details

    • getConfig

      public QueryConfig getConfig()
      Description copied from interface: Query
      Returns a QueryConfig object that contains fully parsed pieces like table, predicate, groupByExprs, etc. as well as the query string.
      Specified by:
      getConfig in interface Query
      Returns:
      the config
    • tupleAdded

      public void tupleAdded(TupleAddedEvent event)
      Description copied from interface: QueryListener
      Event when a new tuple is added to the result.
      Specified by:
      tupleAdded in interface QueryListener
      Parameters:
      event - add event
    • tupleUpdated

      public void tupleUpdated(TupleUpdatedEvent event)
      Description copied from interface: QueryListener
      Event when an existing tuple in the result is updated.
      Specified by:
      tupleUpdated in interface QueryListener
      Parameters:
      event - update event
    • tupleRemoved

      public void tupleRemoved(TupleRemovedEvent event)
      Description copied from interface: QueryListener
      Event when an existing tuple is removed from the result.
      Specified by:
      tupleRemoved in interface QueryListener
      Parameters:
      event - remove event
    • snapshotBegin

      public void snapshotBegin(BeginSnapshotEvent event)
      Description copied from interface: QueryListener
      Event to indicate the start of the result snapshot. This is the first method called when a query starts returning results, but this method is also called to indicate a reset (a complete restart of the query.)
      Specified by:
      snapshotBegin in interface QueryListener
      Parameters:
      event - snapshot begin
    • snapshotEnd

      public void snapshotEnd(EndSnapshotEvent event)
      Description copied from interface: QueryListener
      Event to indicate the query snapshot is complete.
      Specified by:
      snapshotEnd in interface QueryListener
      Parameters:
      event - snapshot end
    • deleteBegin

      public void deleteBegin(BeginDeleteEvent event)
      Description copied from interface: QueryListener
      Event to indicate the start of delete query.
      Specified by:
      deleteBegin in interface QueryListener
      Parameters:
      event - delete begin
    • deleteEnd

      public void deleteEnd(EndDeleteEvent event)
      Description copied from interface: QueryListener
      Event to indicate the delete query is complete.
      Specified by:
      deleteEnd in interface QueryListener
      Parameters:
      event - delete end
    • exceptionRaised

      public void exceptionRaised(QueryExceptionEvent event)
      Description copied from interface: QueryListener
      Event when an exception occurs during the query. Since 1.3, reaching the row limit is considered an exception.
      Specified by:
      exceptionRaised in interface QueryListener
      Parameters:
      event - exception event
    • queryClosed

      public void queryClosed(QueryClosedEvent event)
      Description copied from interface: QueryListener
      Event when a query being listened to is closed.
      Specified by:
      queryClosed in interface QueryListener
      Parameters:
      event - query closed event
    • getFields

      public List<Schema.Field> getFields()
      Description copied from interface: Query
      Returns a list describing the fields of the tuples that will be returned by this Query. An empty list may be returned if the result fields are unknown.
      Specified by:
      getFields in interface Query
      Returns:
      The fields describing the tuples that will be returned.
    • getKeyFields

      public List<Schema.Field> getKeyFields()
      Description copied from interface: Query
      Returns a list of fields describing the primary key for this table. These fields will come from the same schema as getFields, which come from the schema used to create tuples when they arrive, so they will be suitable for calling getXxx against the tuple.
      Specified by:
      getKeyFields in interface Query
      Returns:
      The fields describing the key of the tuples returned, or null if the key is simply a Long that is not part of the data record.
    • close

      public void close()
      Description copied from interface: Query
      Closes the client and server resources associated with this Query. This call may block while it connects to the server to unregister the query.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface Query
    • isOpen

      public boolean isOpen()
      Description copied from interface: Query
      If this is false, either you've already gotten a QueryClosed event or you're about to get one.
      Specified by:
      isOpen in interface Query
      Returns:
      Query is still active and might return data.
    • getQueryId

      public short getQueryId()
      Description copied from interface: Query
      This will match the queryId on the events.
      Specified by:
      getQueryId in interface Query
      Returns:
      the query ID for the query.
    • getRealQuery

      public Query getRealQuery()
    • setRealQuery

      public void setRealQuery(Query realQuery)
      Parameters:
      realQuery - the realQuery to set
    • getSchema

      public Schema getSchema()
      Getter for the Schema for the query.
      Returns:
      Schema
    • setSchema

      public void setSchema(Schema schema)
      Setter for the Schema for the query.
      Parameters:
      schema - the Schema to set