Add support for Resource Tracking to the DataFileProvider infrastructure
------------------------------------------------------------------------

                 Key: STANBOL-374
                 URL: https://issues.apache.org/jira/browse/STANBOL-374
             Project: Stanbol
          Issue Type: New Feature
          Components: Commons
            Reporter: Rupert Westenthaler
            Assignee: Rupert Westenthaler


Currently the DataFileProvider only supports requests for resources. If a 
specific resource is available the caller gets an InputStream for that 
Resource. Otherwise a IOException is thrown.

Here the proposal is to add an new ResourceTracker Service that allows to 
register/unregister ResourceListener instances

    @Service
    ResourceTracker
        /** adds an listener for a resource with that name and a bundle **/
        + void add(ResourceListener listener, String bundleSymbolicName, String 
name)

        /** adds an listener for a resource with a given name **/
        + void add(ResourceListener listener, String name)

        /** removes all resources for that specific listener instance. Useful 
if the listening components gets deactivated. **/
        + void removeAll(ResourceListener listener)

        /** removes listening to that the resource with that name/bundle for 
that listener **/
        + void remove(ResourceListener listener, String bundleSymbolicName, 
String name)

        /** removes listening to that  resource for that listener **/
        + void remove(ResourceListener listener, String name)

   ResourceListener (interface)
        /** Called as soon as a resource gets available. Also called for newly 
registered 
         * resources if the requested resource is already present at the time 
of registration
         * @param resource the name of the available resource
         * @param is the inputstream for that resource
         * @return If <code>true</code> the registration for this event is 
automatically removed.
         * Otherwise the registration is kept and can be used to track if the 
resource get unavailable.
         **/
        + boolean available(String resource, InputStream is)

        /** Called as soon as a previous available resource is no longer 
available 
         * @param resource The name of the unavailable resource
         * @return If <code>true</code>  the registration for this event is 
automatically removed.
         * Otherwise the component receiving this call needs to remove the 
registration them self.
         **/
        +boolean unavailable(String resource)

Implementation:

The suggestion is to

* add this to the "org.apache.stanbol.commons.stanboltools.datafileprovider" 
bundle
* add the "ResourceTracker" and "ResourceListener" interface to the 
"org.apache.stanbol.commons.stanboltools.datafileprovider" package
* add the implementation directly to the 
"org.apache.stanbol.commons.stanboltools.datafileprovider.impl.MainDataFileProvider"
* use an own Thread that calls "getInputStream(...)" for all registered 
resources in fixed intervals (e.g. 5sec) . Computational overhead for the 
periodical polls should be minimal.
* The poll interval should a configurable.

Intended Usage:

* Initially I require this feature to listen for archived Solr indexes copied 
to the /datafiles folders. Currently users need to manually restart the 
Component that manages SolrIndexes after the according file is available.
* This feature will also be handy if we implement a functionality that allows 
to download referenced datafiles via the web, because as soon as the downloads 
completes the components depending on a resource could be notified.
* This feature could also optionally be used to deactivate functionality by 
deleting the corresponding datafiles form the /datafiles folder. (e.g. the 
OpenNLP component loads Language models via the DatafileProvider. Currently the 
are kept in Memory even if the corresponding DataFile is no longer available. 
Even if the user provides an updated version. The old version is still 
available (in-memory) and the new one is only used after a restart of the 
Stanbol environment. This feature would allow to get notified as soon as a 
model is deleted and would trigger an re-initialisation of the model as soon as 
the updated datafile is available again.


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to