org.modeshape.jcr.query

## Interface CancellableQuery

-     public interface CancellableQuery

  A simple interface that allows tracking an executing query that can be cancelled.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `cancel()` Cancel the query if it is currently running.
    `QueryResults` | `getResults()` Execute the query and get the results.

- - ### Method Detail

    - #### getResults

          QueryResults getResults()
                                  throws QueryCancelledException,
                                         RepositoryException

      Execute the query and get the results. Note that this method can be called by multiple threads, and all will block until the query execution has completed. Subsequent calls to this method will return the same results.
      Returns:
        the query results.
      Throws:
        `QueryCancelledException` - if the query was cancelled
        `RepositoryException` - if there was a problem executing the query

    - #### cancel

          boolean cancel()

      Cancel the query if it is currently running. Note that this method does not block until the query is cancelled; it merely marks the query as being cancelled, and the query will terminate at its next available opportunity. Also, subsequent calls to this method have no affect.
      Returns:
        true if the query was executing and will be cancelled, or false if the query was no longer running (because it had finished successfully or had already been cancelled) and could not be cancelled.

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.