public abstract class ManagedResource extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ManagedResource.ChildResourceSupport
Marker interface to indicate a ManagedResource implementation class also supports
managing child resources at path: /<resource>/{child}
|
Modifier and Type | Field and Description |
---|---|
static String |
INIT_ARGS_JSON_FIELD |
static String |
INITIALIZED_ON_JSON_FIELD |
protected Date |
initializedOn |
protected Date |
lastUpdateSinceInitialization |
static String |
MANAGED_JSON_LIST_FIELD |
static String |
MANAGED_JSON_MAP_FIELD |
protected NamedList<Object> |
managedInitArgs |
protected SolrResourceLoader |
solrResourceLoader |
protected ManagedResourceStorage |
storage |
static String |
UPDATED_SINCE_INIT_JSON_FIELD |
Modifier | Constructor and Description |
---|---|
protected |
ManagedResource(String resourceId,
SolrResourceLoader loader,
ManagedResourceStorage.StorageIO storageIO)
Initializes this managed resource, including setting up JSON-based storage using
the provided storageIO implementation, such as ZK.
|
Modifier and Type | Method and Description |
---|---|
protected abstract Object |
applyUpdatesToManagedData(Object updates)
Called during PUT/POST processing to apply updates to the managed data passed from the client.
|
protected Map<String,Object> |
buildMapToStore(Object managedData)
Builds the JSON object to be stored, containing initArgs and managed data fields.
|
protected Map<String,Object> |
convertNamedListToMap(NamedList<?> args)
Converts a NamedList<?> into an ordered Map for returning as JSON.
|
protected ManagedResourceStorage |
createStorage(ManagedResourceStorage.StorageIO storageIO,
SolrResourceLoader loader)
Potential extension point allowing concrete implementations to supply their own storage
implementation.
|
abstract void |
doDeleteChild(BaseSolrResource endpoint,
String childId)
Called by
RestManager.ManagedEndpoint.delete()
to delete a named part (the given childId) of the
resource at the given endpoint |
abstract void |
doGet(BaseSolrResource endpoint,
String childId)
Called by
RestManager.ManagedEndpoint.get()
to retrieve a named part (the given childId) of the
resource at the given endpoint |
void |
doPost(BaseSolrResource endpoint,
org.restlet.representation.Representation entity,
Object json)
Just calls
doPut(BaseSolrResource,Representation,Object) ;
override to change the behavior of POST handling. |
void |
doPut(BaseSolrResource endpoint,
org.restlet.representation.Representation entity,
Object json)
Applies changes to initArgs or managed data.
|
String |
getInitializedOn()
Returns this resource's initialization timestamp.
|
String |
getResourceId()
Gets the resource ID for this managed resource.
|
SolrResourceLoader |
getResourceLoader()
Returns the resource loader used by this resource.
|
Class<? extends BaseSolrResource> |
getServerResourceClass()
Gets the ServerResource class to register this endpoint with the Rest API router;
in most cases, the default RestManager.ManagedEndpoint class is sufficient but
ManagedResource implementations can override this method if a different ServerResource
class is needed.
|
String |
getUpdatedSinceInitialization()
Returns the timestamp of the most recent update,
or null if this resource has not been updated since initialization.
|
boolean |
hasChangesSinceInitialization()
Returns true if this resource has been changed since initialization.
|
void |
loadManagedDataAndNotify(Collection<ManagedResourceObserver> observers)
Called once during core initialization to get the managed
data loaded from storage and notify observers.
|
protected void |
notifyObserversDuringInit(NamedList<?> args,
Collection<ManagedResourceObserver> observers)
Notifies all registered observers that the ManagedResource is initialized.
|
protected abstract void |
onManagedDataLoadedFromStorage(NamedList<?> managedInitArgs,
Object managedData)
Method called after data has been loaded from storage to give the concrete
implementation a chance to post-process the data.
|
void |
onResourceDeleted()
Called by the RestManager framework after this resource has been deleted
to allow this resource to close and clean-up any resources used by this.
|
protected Object |
processStoredData(Object data)
Processes the stored data.
|
protected void |
reloadFromStorage()
Invoked when this object determines it needs to reload the stored data.
|
void |
storeManagedData(Object managedData)
Persists managed data to the configured storage IO as a JSON object.
|
protected boolean |
updateInitArgs(NamedList<?> updatedArgs)
Called from
doPut(BaseSolrResource,Representation,Object)
to update this resource's init args using the given updatedArgs |
public static final String INIT_ARGS_JSON_FIELD
public static final String MANAGED_JSON_LIST_FIELD
public static final String MANAGED_JSON_MAP_FIELD
public static final String INITIALIZED_ON_JSON_FIELD
public static final String UPDATED_SINCE_INIT_JSON_FIELD
protected final SolrResourceLoader solrResourceLoader
protected final ManagedResourceStorage storage
protected Date initializedOn
protected Date lastUpdateSinceInitialization
protected ManagedResource(String resourceId, SolrResourceLoader loader, ManagedResourceStorage.StorageIO storageIO) throws SolrException
SolrException
public void loadManagedDataAndNotify(Collection<ManagedResourceObserver> observers) throws SolrException
SolrException
protected void notifyObserversDuringInit(NamedList<?> args, Collection<ManagedResourceObserver> observers) throws SolrException
SolrException
protected ManagedResourceStorage createStorage(ManagedResourceStorage.StorageIO storageIO, SolrResourceLoader loader) throws SolrException
SolrException
public SolrResourceLoader getResourceLoader()
public String getResourceId()
public Class<? extends BaseSolrResource> getServerResourceClass()
protected boolean updateInitArgs(NamedList<?> updatedArgs)
doPut(BaseSolrResource,Representation,Object)
to update this resource's init args using the given updatedArgsprotected void reloadFromStorage() throws SolrException
SolrException
protected Object processStoredData(Object data) throws SolrException
SolrException
protected abstract void onManagedDataLoadedFromStorage(NamedList<?> managedInitArgs, Object managedData) throws SolrException
SolrException
public void storeManagedData(Object managedData)
public String getInitializedOn()
public String getUpdatedSinceInitialization()
public boolean hasChangesSinceInitialization()
protected Map<String,Object> buildMapToStore(Object managedData)
protected Map<String,Object> convertNamedListToMap(NamedList<?> args)
public void doPost(BaseSolrResource endpoint, org.restlet.representation.Representation entity, Object json)
doPut(BaseSolrResource,Representation,Object)
;
override to change the behavior of POST handling.public void doPut(BaseSolrResource endpoint, org.restlet.representation.Representation entity, Object json)
public void onResourceDeleted() throws IOException
IOException
- if an error occurs in the underlying storage when
trying to deleteprotected abstract Object applyUpdatesToManagedData(Object updates)
public abstract void doDeleteChild(BaseSolrResource endpoint, String childId)
RestManager.ManagedEndpoint.delete()
to delete a named part (the given childId) of the
resource at the given endpointpublic abstract void doGet(BaseSolrResource endpoint, String childId)
RestManager.ManagedEndpoint.get()
to retrieve a named part (the given childId) of the
resource at the given endpointCopyright © 2000-2019 Apache Software Foundation. All Rights Reserved.