public class CacheResource extends Object
NamedCache
.Modifier and Type | Field and Description |
---|---|
protected AggregatorRegistry |
m_aggregatorRegistry
Aggregator registry that is used to map the given aggregator name to an EntryAggregator instance.
|
protected NamedCache |
m_cache
NamedCache wrapped by this resource.
|
protected Class |
m_clzKey
Key class for the entries stored in the wrapped cache.
|
protected Class |
m_clzValue
Value class for the entries stored in the wrapped cache.
|
protected int |
m_cMaxResults
Size of the result set this resource is allowed to return.
|
protected KeyConverter |
m_keyConverter
Key converter.
|
protected MarshallerRegistry |
m_marshallerRegistry
Marshaller registry to obtain marshallers from.
|
protected ProcessorRegistry |
m_processorRegistry
a processor registry that is used to map the given processor name to an EntryProcessor instance.
|
protected QueryConfig |
m_queryConfig
Query configuration for this resource.
|
protected QueryEngineRegistry |
m_queryEngineRegistry
Query engine registry to obtain query engines from.
|
protected org.glassfish.hk2.api.ServiceLocator |
m_serviceLocator
The ServiceLocator for this resource.
|
Constructor and Description |
---|
CacheResource(NamedCache cache, Class clzKey, Class clzValue, KeyConverter keyConverter, QueryConfig queryConfig, int cMaxResults)
Construct a new CacheResource.
|
Modifier and Type | Method and Description |
---|---|
org.glassfish.jersey.media.sse.EventOutput |
addListener(boolean fLite, String sQuery)
Register SSE event listener for this cache.
|
javax.ws.rs.core.Response |
aggregate(String sAggr, String sQuery)
Perform an aggregating operation against the entries that satisfy the specified criteria.
|
protected Collection |
executeQuery(String sQuery, 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(int nStart, int cResults, String sSort, PropertySet propertySet, String sQuery)
Return the cache entries that satisfy the given query criteria.
|
Object |
getEntryOrQueryResource(String sKey)
Return a REST sub-resource representing either a configured named query or a single cache entry.
|
EntrySetResource |
getEntrySetResource(String sKeys)
Return a REST sub-resource representing a set of cache entries.
|
javax.ws.rs.core.Response |
getKeys(String sQuery)
Return the keys of cache entries that satisfy the given query criteria.
|
javax.ws.rs.core.Response |
getValues(int nStart, int cResults, String sSort, PropertySet propertySet, String sQuery)
Return the cache values (or a subset of their properties) that satisfy the specified criteria.
|
protected EntryResource |
instantiateEntryResource(NamedCache cache, Object oKey, Class clzValue)
Create an instance of
EntryResource for the specified resource configuration. |
protected EntrySetResource |
instantiateEntrySetResource(NamedCache cache, Set setKeys, Class clzValue)
Create an instance of
EntrySetResource for the specified resource configuration. |
NamedQueryResource |
instantiateNamedQueryResource(NamedCache cache, NamedQuery query, int cMaxResults)
Create an instance of
NamedQueryResource for the specified resource configuration. |
protected Set |
keys(String sQuery)
Returns a set of keys that satisfy the criteria expressed by the query.
|
javax.ws.rs.core.Response |
process(String sProc, String sQuery)
Invoke the specified processor against the entries that satisfy the specified criteria.
|
protected NamedCache m_cache
protected Class m_clzKey
protected Class m_clzValue
protected KeyConverter m_keyConverter
protected int m_cMaxResults
@Inject protected MarshallerRegistry m_marshallerRegistry
protected QueryConfig m_queryConfig
@Inject protected QueryEngineRegistry m_queryEngineRegistry
@Inject protected AggregatorRegistry m_aggregatorRegistry
@Inject protected ProcessorRegistry m_processorRegistry
@Inject protected org.glassfish.hk2.api.ServiceLocator m_serviceLocator
public CacheResource(NamedCache cache, Class clzKey, Class clzValue, KeyConverter keyConverter, QueryConfig queryConfig, int cMaxResults)
cache
- cache to create a resource forclzKey
- key class of the cached entriesclzValue
- value class of the cached entrieskeyConverter
- key converter to usequeryConfig
- query configuration for this resourcecMaxResults
- max size of result set for this resource@GET @Produces(value={"application/json","application/xml"}) public javax.ws.rs.core.Response getValues(@MatrixParam(value="start") @DefaultValue(value="0") int nStart, @MatrixParam(value="count") @DefaultValue(value="-1") int cResults, @MatrixParam(value="sort") String sSort, @MatrixParam(value="p") PropertySet propertySet, @QueryParam(value="q") String sQuery)
nStart
- starting index of result set to be returnedcResults
- size of result set to be returned (page size)sSort
- a string expression that represents orderingpropertySet
- the subset of properties to return for each value (if null, the complete values will be returned)sQuery
- where predicate of Coherence Query Language to filter cache entries. If null, all cache values will be returned@GET @Path(value="entries") @Produces(value={"application/json","application/xml","text/plain"}) public javax.ws.rs.core.Response getEntries(@MatrixParam(value="start") @DefaultValue(value="0") int nStart, @MatrixParam(value="count") @DefaultValue(value="-1") int cResults, @MatrixParam(value="sort") String sSort, @MatrixParam(value="p") PropertySet propertySet, @QueryParam(value="q") String sQuery)
nStart
- starting index of result set to be returnedcResults
- size of result set to be returned (page size)sSort
- a string expression that represents orderingpropertySet
- the subset of properties to return for each value (if null, the complete values will be returned)sQuery
- where predicate of Coherence Query Language to filter cache entries. If null, all cache entries will be returned@GET @Path(value="keys") @Produces(value={"application/json","application/xml","text/plain"}) public javax.ws.rs.core.Response getKeys(@QueryParam(value="q") String sQuery)
sQuery
- query expression@GET @Path(value="{aggr: \\s*(\\w(?:\\w|-)*)\\((.*)\\)}") @Produces(value={"application/json","application/xml","text/plain"}) public javax.ws.rs.core.Response aggregate(@PathParam(value="aggr") String sAggr, @QueryParam(value="q") String sQuery)
sAggr
- name of the aggregatorsQuery
- where predicate of Coherence Query Language to filter cache entries (optional)@POST @Path(value="{proc: \\s*(\\w(?:\\w|-)*)\\((.*)\\)}") @Produces(value={"application/json","application/xml"}) public javax.ws.rs.core.Response process(@PathParam(value="proc") String sProc, @QueryParam(value="q") String sQuery)
sProc
- the name of the processorsQuery
- where predicate of Coherence Query Language to filter cache entries (optional)@GET @Produces(value="text/event-stream") public org.glassfish.jersey.media.sse.EventOutput addListener(@MatrixParam(value="lite") boolean fLite, @QueryParam(value="q") String sQuery)
fLite
- flag specifying whether to register for lite or full eventssQuery
- an optional CohQL filter to register listener on@Path(value="{key: [^/]+}") public Object getEntryOrQueryResource(@PathParam(value="key") String sKey)
sKey
- name of the configured query or referenced entry's key@Path(value="{keys: \\([^\\)]+\\)}") public EntrySetResource getEntrySetResource(@PathParam(value="keys") String sKeys)
sKeys
- keys of the referenced entriesprotected Collection executeQuery(String sQuery, ValueExtractor<Map.Entry,?> extractor, int nStart, int cResults, String sSort)
sQuery
- where predicate of Coherence Query Language to filter cache entries. If null, all cache entries will be returned.extractor
- the extractor to apply to each entry in the result setnStart
- the starting index of result set to be returnedcResults
- the size of result set to be returned (page size)sSort
- a string expression that represents sort orderprotected Set keys(String sQuery)
sQuery
- query used to filter cache entriesprotected EntryResource instantiateEntryResource(NamedCache cache, Object oKey, Class clzValue)
EntryResource
for the specified resource configuration.cache
- cache in which referenced entry is storedoKey
- referenced entry's keyclzValue
- class of the referenced entry's valueprotected EntrySetResource instantiateEntrySetResource(NamedCache cache, Set setKeys, Class clzValue)
EntrySetResource
for the specified resource configuration.cache
- cache that stores the referenced entriessetKeys
- keys of the referenced entriesclzValue
- class of the referenced entries' valuespublic NamedQueryResource instantiateNamedQueryResource(NamedCache cache, NamedQuery query, int cMaxResults)
NamedQueryResource
for the specified resource configuration.cache
- cache to create a resource forquery
- query filtering the cache entriescMaxResults
- max size of result set for this resource