Class NamedQueryResource


  • public class NamedQueryResource
    extends Object
    REST resource representing a set of filtered cache entries.
    Author:
    ic 2011.12.03
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      MapEventOutput addListener​(boolean fLite, javax.ws.rs.core.UriInfo uriInfo)
      Register SSE event listener for this named query.
      javax.ws.rs.core.Response aggregate​(javax.ws.rs.core.UriInfo uriInfo, String sAggr)
      Perform an aggregating operation against the entries that belong to the named query.
      protected Collection executeQuery​(javax.ws.rs.core.UriInfo uriInfo, ValueExtractor<Map.Entry,​?> extractor, int nStart, int cResults, String sSort)
      Returns a collection of extracted values for cache entries that satisfy the criteria expressed by the query.
      javax.ws.rs.core.Response getEntries​(javax.ws.rs.core.UriInfo uriInfo, int nStart, int cResults, String sSort, PropertySet propertySet)
      Return the cache entries that satisfy criteria defined by this resource.
      javax.ws.rs.core.Response getKeys​(javax.ws.rs.core.UriInfo uriInfo)
      Return the keys for cache entries that satisfy criteria defined by this resource.
      javax.ws.rs.core.Response getValues​(javax.ws.rs.core.UriInfo uriInfo, int nStart, int cResults, String sSort, PropertySet propertySet)
      Return the cache values that satisfy criteria defined by this resource.
      protected Set keys​(javax.ws.rs.core.UriInfo uriInfo)
      Return the keys of cache entries that satisfy the named query criteria.
      javax.ws.rs.core.Response process​(javax.ws.rs.core.UriInfo uriInfo, String sProc)
      Invoke the specified processor against the entries that belong to the named query.
    • Field Detail

      • m_cache

        protected NamedCache m_cache
        NamedCache wrapped by this resource.
      • m_query

        protected NamedQuery m_query
        Named query responsible to filter cache entries.
      • m_cMaxResults

        protected int m_cMaxResults
        Maximum size of the result set this resource is allowed to return.
      • m_aggregatorRegistry

        @Inject
        protected AggregatorRegistry m_aggregatorRegistry
        Aggregator registry that is used to map the given aggregator name to an EntryAggregator instance.
      • m_processorRegistry

        @Inject
        protected ProcessorRegistry m_processorRegistry
        a processor registry that is used to map the given processor name to an EntryProcessor instance.
    • Constructor Detail

      • NamedQueryResource

        public NamedQueryResource​(NamedCache cache,
                                  NamedQuery query,
                                  int cMaxResults)
        Create a instance of NamedQueryResource.
        Parameters:
        cache - cache to create a resource for
        query - query filtering the cache entries
        cMaxResults - max size of result set for this resource
    • Method Detail

      • aggregate

        @GET
        @Path("{aggr: \\s*(\\w(?:\\w|-)*)\\((.*)\\)}")
        @Produces({"application/json","application/xml","text/plain"})
        public javax.ws.rs.core.Response aggregate​(@Context
                                                   javax.ws.rs.core.UriInfo uriInfo,
                                                   @PathParam("aggr")
                                                   String sAggr)
        Perform an aggregating operation against the entries that belong to the named query.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        sAggr - name of the aggregator
        Returns:
        the result of the aggregation
      • process

        @POST
        @Path("{proc: \\s*(\\w(?:\\w|-)*)\\((.*)\\)}")
        @Produces({"application/json","application/xml"})
        public javax.ws.rs.core.Response process​(@Context
                                                 javax.ws.rs.core.UriInfo uriInfo,
                                                 @PathParam("proc")
                                                 String sProc)
        Invoke the specified processor against the entries that belong to the named query.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        sProc - the name of the processor
        Returns:
        a Map containing the results of invoking the EntryProcessor against the entries that are selected by the given query
      • getValues

        @GET
        public javax.ws.rs.core.Response getValues​(@Context
                                                   javax.ws.rs.core.UriInfo uriInfo,
                                                   @MatrixParam("start") @DefaultValue("0")
                                                   int nStart,
                                                   @MatrixParam("count") @DefaultValue("-1")
                                                   int cResults,
                                                   @MatrixParam("sort")
                                                   String sSort,
                                                   @MatrixParam("p")
                                                   PropertySet propertySet)
        Return the cache values that satisfy criteria defined by this resource.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        nStart - the starting index of result set to be returned
        cResults - the size of result set to be returned (page size)
        sSort - a string expression that represents ordering
        propertySet - properties to return (if null, values will be returned)
        Returns:
        values that satisfy criteria defined by this resource
      • getEntries

        @GET
        @Path("entries")
        @Produces({"application/json","application/xml","text/plain"})
        public javax.ws.rs.core.Response getEntries​(@Context
                                                    javax.ws.rs.core.UriInfo uriInfo,
                                                    @MatrixParam("start") @DefaultValue("0")
                                                    int nStart,
                                                    @MatrixParam("count") @DefaultValue("-1")
                                                    int cResults,
                                                    @MatrixParam("sort")
                                                    String sSort,
                                                    @MatrixParam("p")
                                                    PropertySet propertySet)
        Return the cache entries that satisfy criteria defined by this resource.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        nStart - the starting index of result set to be returned
        cResults - the size of result set to be returned (page size)
        sSort - a string expression that represents ordering
        propertySet - the subset of properties to return for each value (if null, the complete values will be returned)
        Returns:
        the cache entries satisfying criteria defined by this resource
      • getKeys

        @GET
        @Path("keys")
        @Produces({"application/json","application/xml","text/plain"})
        public javax.ws.rs.core.Response getKeys​(@Context
                                                 javax.ws.rs.core.UriInfo uriInfo)
        Return the keys for cache entries that satisfy criteria defined by this resource.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        Returns:
        the keys of the cache entries satisfying criteria defined by this resource
      • addListener

        @GET
        @Produces("text/event-stream")
        public MapEventOutput addListener​(@MatrixParam("lite")
                                          boolean fLite,
                                          @Context
                                          javax.ws.rs.core.UriInfo uriInfo)
        Register SSE event listener for this named query.
        Parameters:
        fLite - flag specifying whether to register for lite or full events
        uriInfo - UriInfo for the invoked resource method
        Returns:
        the EventOutput that will be used to send events to the client
      • executeQuery

        protected Collection executeQuery​(javax.ws.rs.core.UriInfo uriInfo,
                                          ValueExtractor<Map.Entry,​?> extractor,
                                          int nStart,
                                          int cResults,
                                          String sSort)
        Returns a collection of extracted values for cache entries that satisfy the criteria expressed by the query.
        Parameters:
        uriInfo - UriInfo for the invoked resource method
        extractor - the extractor to apply to each entry in the result set
        nStart - the starting index of result set to be returned
        cResults - the size of result set to be returned (page size)
        sSort - a string expression that represents sort order
        Returns:
        the cache entries that satisfy the criteria defined by this named query
      • keys

        protected Set keys​(javax.ws.rs.core.UriInfo uriInfo)
        Return the keys of cache entries that satisfy the named query criteria.
        Parameters:
        uriInfo - UriInfo for invoked resource method
        Returns:
        filtered key set