public abstract class AbstractSpecFactory<T> extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
AbstractSpecFactory.Query
Holds information used to fetch a spec.
|
protected static class |
AbstractSpecFactory.SpecRetrievalFailedException |
| Constructor and Description |
|---|
AbstractSpecFactory(Class<T> clazz,
ExecutorService executor,
RequestPipeline pipeline,
Cache<Uri,Object> cache,
long refresh) |
| Modifier and Type | Method and Description |
|---|---|
protected T |
fetchFromNetwork(AbstractSpecFactory.Query query)
Retrieves a spec from the network, parses, and adds it to the cache.
|
protected T |
getSpec(AbstractSpecFactory.Query query)
Attempt to fetch a spec, either from cache or from the network.
|
protected abstract T |
parse(String content,
AbstractSpecFactory.Query query)
Parse and return a new spec object from the network.
|
public AbstractSpecFactory(Class<T> clazz, ExecutorService executor, RequestPipeline pipeline, Cache<Uri,Object> cache, long refresh)
clazz - the class for spec objects.executor - for asynchronously updating specspipeline - the request pipeline for fetching new specscache - a cache for parsed spec objectsrefresh - the frequency at which to update specs, independent of cache expiration policyprotected T getSpec(AbstractSpecFactory.Query query) throws GadgetException
query passed here will always be passed, unmodified, to
parse(String, Query). This can be used to carry additional context information
during parsing.GadgetExceptionprotected T fetchFromNetwork(AbstractSpecFactory.Query query) throws AbstractSpecFactory.SpecRetrievalFailedException, GadgetException
protected abstract T parse(String content, AbstractSpecFactory.Query query) throws XmlException, GadgetException
content - the content located at specUriquery - same as was passed getSpec(Query)XmlExceptionGadgetExceptionCopyright © 2007-2012. All Rights Reserved.