Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] [prov] directory watcher


For the most part the DirectoryWatcher is very similar to what Peter did originally.  That is, it just polls using a configurable delay.  It certainly could be extended to hook the filesystem to get change notifications.  We have all the required infrastructure in the resources plugins so it should be relatively easy.

The DirectoryWatcher also notices changes (based on File.lastModified()) and file deletions.  The "JARListener" translates file timestamp changes into BundleContext.update() and file deletions into BundleContext.uninstall().  In some cases a file might be locked (e.g., if you installed a bundle by reference: and a classloader has it open).  In that case you can "virtually delete" the file by adding a sibling file of the same name but with ".del" appended.  The DirectoryWatcher will notice this and process the base file (the one without .del) as though it had been removed (e.g., the corresponding bundle would be uninstalled).  Then, at the end of each polling cycle the DirectoryWatcher attempts to delete all "virtually deleted" base files as well as the corresponding delete marker files (.del files).  I'm sure there are holes in the actual implementation but initial testing shows that it works quite handily.

Some notes:
- currently bundles are installed using standard OSGi installBundle().  That is, they are not installed by reference so you end up with two copies of the bundle on disk.  Worse, you get one copy per configuration that used this technique.   We should look at having an option to install by reference.
- The real intention is to have this be a replacement for Update Manager's promiscuous install behaviour.  People have grown quite used to dropping some files in the plugins dir and having them show up in Eclipse on next run.   With p2 that will not happen natively.  With the DirectoryWatcher and a p2 listener, users should be able to identify as many directories as they want and have bundles added and removed from them *dynamically* installed/uninstalled/updated.  So in the end users get enhanced functionality.

Jeff




"Alex Blewitt" <alex.blewitt@xxxxxxxxx>
Sent by: equinox-dev-bounces@xxxxxxxxxxx

08/30/2007 03:58 AM

Please respond to
Equinox development mailing list <equinox-dev@xxxxxxxxxxx>

To
"Equinox development mailing list" <equinox-dev@xxxxxxxxxxx>
cc
Subject
Re: [equinox-dev] [prov] directory watcher





Interesting. Does it periodically scan for changes, or does it hook in
with the underlying file system notifications to receive changes? I
believe that the Win32 resources API has the ability to pick up
changes; it would be good if that worked for other systems too.

Does it do the reverse, uninstalling a bundle if the corresponding
file is deleted?

Alex.

On 30/08/2007, Jeff McAffer <Jeff_McAffer@xxxxxxxxxx> wrote:
>
> I finally did something that has been on my list for quite some time.
>  Inspired by Peter Kriens' FileInstall bundle, I made a DirectoryWatcher
> that, as the name implies, watches a directory and installs, uninstalls,
> configures, ... things that are dropped into/removed from/changed in the
> dir.  The current working support directly calls installBundle() etc but I
> have also been working on one that calls p2 API to effect and install.  The
> design consists of a DirectoryWatcher with which you can register listeners.
>  The listeners then get added, removed and changed events for the files of
> interest in the directory being watched.  It is quite easy to create a new
> listener that does your own thing.
>
> Keeping in mind that this is quite early, take a look at
>         org.eclipse.equinox.p2.directorywatcher
> I have added not this to the PSF files yet as there are some compile errors
> in the provisioning listener as I have not completed enhancing the metadata
> generator to work on individual files rather than directories.  More to come
> later...
>
> Jeff
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>
_______________________________________________
equinox-dev mailing list
equinox-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/equinox-dev


Back to the top