| java.lang.Object | |
| ↳ | com.neomades.content.ContentManager |
This manager is responsible for query handling.
A typical implementation is using only one instance of ContentManager
and register it to the Application by calling the
registerContentManager(ContentManager) method.
Query can be posted either directly with the
postQuery(Query) method or using the Event API.
Cache can be disabled by the server if response contains the
HTTP Header "Cache-Control" with "no-store" or
"no-cache" value.
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| String | DEFAULT_NAME | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
ContentManager()
Creates a
ContentManager. | |||||||||||
|
ContentManager(String name)
Creates a
ContentManager with a special name. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| void |
cancelAll(QueryFilter filter)
Cancels all queries matching the given filter.
| ||||||||||
| void |
cancelAll(Object tag)
Cancels all queries with the given tag.
| ||||||||||
| void |
clear()
Removes all parsers, networks, caches.
| ||||||||||
| Cache |
getCacheByType(String cacheType)
Returns the
Cache instance associated with the type given in
parameter | ||||||||||
| Network |
getNetworkByType(String networkType)
Returns the
Network instance associated with the type given in
parameter | ||||||||||
| Parser |
getParserByType(String parserType)
Returns the
Parser instance associated with the type given in
parameter | ||||||||||
| RetryPolicy |
getRetryPolicyByType(String retryPolicyType)
Returns the Retry policy associated with type name given in parameter.
| ||||||||||
| void | onReceiveEvent(Event event) | ||||||||||
| void |
postQuery(Query query)
Posts a query to a Queue.
| ||||||||||
| void |
putCache(String type, Cache cache)
Puts a
Cache with an associated type name. | ||||||||||
| void |
putNetwork(String type, Network network)
Puts a
Network with an associated type name. | ||||||||||
| void |
putParser(String type, Parser parser)
Puts a
Parser with an associated type name. | ||||||||||
| void |
putRetryPolicy(String type, RetryPolicy policy)
Puts a
Parser with an associated type name. | ||||||||||
| void |
removeCache(String type)
Removes a
Cache from this manager. | ||||||||||
| void |
removeNetwork(String type)
Removes a
Network from this manager. | ||||||||||
| void |
removeParser(String type)
Removes a
Parser from this manager. | ||||||||||
| void |
removeRetryPolicy(String type)
Removes a
RetryPolicy from this manager. | ||||||||||
| void |
setDebugEnabled(boolean enabled)
Enables or disables traces inside logs.
| ||||||||||
| void |
setEventBus(EventBus eventBus)
Registers this ContentManager into the eventBus given in parameter and
unregisters it from old eventBus.
| ||||||||||
| void |
start()
Starts managing queries.
| ||||||||||
| void |
stop()
Stops managing queries.
| ||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
com.neomades.event.EventReceiver
| |||||||||||
Creates a ContentManager with a special name.
Don't forget the set the same name inside ContentQuery in order to
send-receive query to the right ContentManager.
Cancels all queries matching the given filter.
| filter | filter all ContentQuery queries.
|
|---|
Cancels all queries with the given tag.
| tag | tag inside ContentQuery
|
|---|
Removes all parsers, networks, caches.
Returns the Retry policy associated with type name given in parameter.
| retryPolicyType | name associated with a RetryPolicy instance. |
|---|
Called by EventBus when an Event has been received.
The EventReceiver should be associated with this eventType. To do
that, the EventReceiver's registration may say what type of event is
associated to.
| event | received event |
|---|
Posts a query to a Queue.
This method is also called when ContentQuery are posted through the
EventBus.
Puts a Cache with an associated type name.
| type | a name to associated with |
|---|---|
| cache | instance to register |
| IllegalArgumentException | if the type has been already set. |
|---|
Puts a Network with an associated type name.
| type | a name to associated with |
|---|---|
| network | instance to register |
| IllegalArgumentException | if the type has been already set. |
|---|
Puts a Parser with an associated type name.
This parser can be used for serialization and de-serialization.
| type | a name to associated with |
|---|---|
| parser | instance to register |
| IllegalArgumentException | if the type has been already set. |
|---|
Puts a Parser with an associated type name.
| type | a name to associated with |
|---|---|
| policy | instance to register |
| IllegalArgumentException | if the type has been already set. |
|---|
Removes a Cache from this manager.
| type | the cache type |
|---|
Removes a Network from this manager.
| type | the network type |
|---|
Removes a Parser from this manager.
| type | the parser type |
|---|
Removes a RetryPolicy from this manager.
| type | the RetryPolicy type |
|---|
Enables or disables traces inside logs.
| enabled | true to print traces. |
|---|
Registers this ContentManager into the eventBus given in parameter and unregisters it from old eventBus.
By default, the eventBus is the Application event
bus.
Starts managing queries.
A queue of Queries, pool of threads for Cache and pool of threads for Network are initialized.
Queries will be received by EventBus used by the Application or by
the postQuery(Query) method.
Stops managing queries.
Stops queries queue, pools of threads.