com.buglabs.osgi.filesystem.init
Class AbstractFileMonitor

java.lang.Object
  extended by com.buglabs.osgi.filesystem.init.AbstractFileMonitor
All Implemented Interfaces:
FileMonitor
Direct Known Subclasses:
InstalledBundleMonitor, RunLevelFileMonitor

public abstract class AbstractFileMonitor
extends java.lang.Object
implements FileMonitor

Abstract base class for FileMonitors. Common functionality for install-only and run level monitors.


Field Summary
protected  Bundle bundle
           
protected  BundleContext context
           
protected  java.io.File file
           
protected  LogService log
           
protected  boolean originalFile
           
 
Constructor Summary
AbstractFileMonitor(java.io.File f, BundleContext context)
           
 
Method Summary
protected  java.lang.String createBundleURI(java.lang.String path)
          Given a java.io.File, return the OSGi-style file path URI.
protected  boolean fileChanged(java.io.File f)
           
protected  boolean fileDeleted(java.io.File file)
          Check to see if file removed from filesystem, if so, uninstall bundle and return true, or false otherwise.
 java.io.File getFile()
           
abstract  boolean update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

file

protected final java.io.File file

context

protected final BundleContext context

bundle

protected Bundle bundle

log

protected LogService log

originalFile

protected boolean originalFile
Constructor Detail

AbstractFileMonitor

public AbstractFileMonitor(java.io.File f,
                           BundleContext context)
                    throws java.io.IOException,
                           BundleException
Throws:
java.io.IOException
BundleException
Method Detail

fileChanged

protected boolean fileChanged(java.io.File f)
Returns:
true if the modified time has changes since object creation or last time fileChanged() returned true.

createBundleURI

protected java.lang.String createBundleURI(java.lang.String path)
Given a java.io.File, return the OSGi-style file path URI.

Parameters:
path -
Returns:

update

public abstract boolean update()
                        throws java.lang.Exception
Specified by:
update in interface FileMonitor
Returns:
true if update occurred successfully, false if the bundle has been removed from the system.
Throws:
java.lang.Exception

fileDeleted

protected boolean fileDeleted(java.io.File file)
Check to see if file removed from filesystem, if so, uninstall bundle and return true, or false otherwise.

Parameters:
file -
Returns:
Throws:
BundleException

getFile

public java.io.File getFile()
Specified by:
getFile in interface FileMonitor
Returns:
absolute path of file.