org.ungoverned.oscar.util
Class DefaultBundleArchive

java.lang.Object
  extended by org.ungoverned.oscar.util.DefaultBundleArchive
All Implemented Interfaces:
BundleArchive

public class DefaultBundleArchive
extends java.lang.Object
implements BundleArchive

This class, combined with DefaultBundleCache, implements the default file system-based bundle cache for Oscar.

See Also:
DefaultBundleCache

Constructor Summary
DefaultBundleArchive(java.io.File dir, long id)
           
DefaultBundleArchive(java.io.File dir, long id, java.lang.String location, java.io.InputStream is)
           
 
Method Summary
protected static boolean deleteDirectoryTree(java.io.File target)
           
 java.lang.String findLibrary(int revision, java.lang.String libName)
           Returns the absolute file path for the specified native library of the specified revision of the bundle associated with this archive.
 BundleActivator getActivator(java.lang.ClassLoader loader)
           Returns the persistent bundle activator of the bundle associated with this archive; this is a non-standard OSGi method that is only called when Oscar is running in non-strict OSGi mode.
 java.lang.String[] getClassPath(int revision)
           Returns an array of Strings that represent the class path of the specified revision of the bundle associated with this archive.
 java.io.File getDataFile(java.lang.String fileName)
           Returns an appropriate data file for the bundle associated with the archive using the supplied file name.
 java.io.File getDirectory()
           
 long getId()
           Returns the identifier of the bundle associated with this archive.
 java.lang.String getLocation()
           Returns the location string of the bundle associated with this archive.
 java.util.Map getManifestHeader(int revision)
           Returns the main attributes of the JAR file manifest header of the specified revision of the bundle associated with this archive.
 int getPersistentState()
           Returns the persistent state of the bundle associated with the archive; this value will be either Bundle.INSTALLED or Bundle.ACTIVE.
 int getRevisionCount()
           Returns the number of revisions of the bundle associated with the archive.
 int getRevisionCountUnchecked()
           
 int getStartLevel()
           Returns the start level of the bundle associated with this archive.
protected  void purge()
           
protected  void remove()
           
 void setActivator(java.lang.Object obj)
           Sets the persistent bundle activator of the bundle associated with this archive; this is a non-standard OSGi method that is only called when Oscar is running in non-strict OSGi mode.
 void setPersistentState(int state)
           Sets the persistent state of the bundle associated with this archive; this value will be either Bundle.INSTALLED or Bundle.ACTIVE.
 void setStartLevel(int level)
           Sets the start level of the bundle associated with this archive.
protected  void update(java.io.InputStream is)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultBundleArchive

public DefaultBundleArchive(java.io.File dir,
                            long id,
                            java.lang.String location,
                            java.io.InputStream is)
                     throws java.lang.Exception
Throws:
java.lang.Exception

DefaultBundleArchive

public DefaultBundleArchive(java.io.File dir,
                            long id)
Method Detail

getDirectory

public java.io.File getDirectory()

getId

public long getId()
Description copied from interface: BundleArchive

Returns the identifier of the bundle associated with this archive.

Specified by:
getId in interface BundleArchive
Returns:
the identifier of the bundle associated with this archive.

getLocation

public java.lang.String getLocation()
                             throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the location string of the bundle associated with this archive.

Specified by:
getLocation in interface BundleArchive
Returns:
the location string of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

getPersistentState

public int getPersistentState()
                       throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the persistent state of the bundle associated with the archive; this value will be either Bundle.INSTALLED or Bundle.ACTIVE.

Specified by:
getPersistentState in interface BundleArchive
Returns:
the persistent state of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

setPersistentState

public void setPersistentState(int state)
                        throws java.lang.Exception
Description copied from interface: BundleArchive

Sets the persistent state of the bundle associated with this archive; this value will be either Bundle.INSTALLED or Bundle.ACTIVE.

Specified by:
setPersistentState in interface BundleArchive
Parameters:
state - the new bundle state to write to the archive.
Throws:
java.lang.Exception - if any error occurs.

getStartLevel

public int getStartLevel()
                  throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the start level of the bundle associated with this archive.

Specified by:
getStartLevel in interface BundleArchive
Returns:
the start level of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

setStartLevel

public void setStartLevel(int level)
                   throws java.lang.Exception
Description copied from interface: BundleArchive

Sets the start level of the bundle associated with this archive.

Specified by:
setStartLevel in interface BundleArchive
Parameters:
level - the new bundle start level to write to the archive.
Throws:
java.lang.Exception - if any error occurs.

getDataFile

public java.io.File getDataFile(java.lang.String fileName)
                         throws java.lang.Exception
Description copied from interface: BundleArchive

Returns an appropriate data file for the bundle associated with the archive using the supplied file name.

Specified by:
getDataFile in interface BundleArchive
Returns:
a File corresponding to the requested data file for the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

getActivator

public BundleActivator getActivator(java.lang.ClassLoader loader)
                             throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the persistent bundle activator of the bundle associated with this archive; this is a non-standard OSGi method that is only called when Oscar is running in non-strict OSGi mode.

Specified by:
getActivator in interface BundleArchive
Parameters:
loader - the class loader to use when trying to instantiate the bundle activator.
Returns:
the persistent bundle activator of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

setActivator

public void setActivator(java.lang.Object obj)
                  throws java.lang.Exception
Description copied from interface: BundleArchive

Sets the persistent bundle activator of the bundle associated with this archive; this is a non-standard OSGi method that is only called when Oscar is running in non-strict OSGi mode.

Specified by:
setActivator in interface BundleArchive
Parameters:
obj - the new persistent bundle activator to write to the archive.
Throws:
java.lang.Exception - if any error occurs.

getRevisionCount

public int getRevisionCount()
                     throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the number of revisions of the bundle associated with the archive. When a bundle is updated, the previous version of the bundle is maintained along with the new revision until old revisions are purged. The revision count reflects how many revisions of the bundle are currently available in the cache.

Specified by:
getRevisionCount in interface BundleArchive
Returns:
the number of revisions of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

getRevisionCountUnchecked

public int getRevisionCountUnchecked()

getManifestHeader

public java.util.Map getManifestHeader(int revision)
                                throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the main attributes of the JAR file manifest header of the specified revision of the bundle associated with this archive. The returned map should be case insensitive.

Specified by:
getManifestHeader in interface BundleArchive
Parameters:
revision - the specified revision.
Returns:
the case-insensitive JAR file manifest header of the specified revision of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

getClassPath

public java.lang.String[] getClassPath(int revision)
                                throws java.lang.Exception
Description copied from interface: BundleArchive

Returns an array of Strings that represent the class path of the specified revision of the bundle associated with this archive. Currently, these values are restricted to absolute paths in the file system, but this may be lifted in the future (perhaps they should be ResourceSources from the Module Loader.

Specified by:
getClassPath in interface BundleArchive
Parameters:
revision - the specified revision.
Returns:
a String array of the absolute path names that comprise the class path of the specified revision of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

findLibrary

public java.lang.String findLibrary(int revision,
                                    java.lang.String libName)
                             throws java.lang.Exception
Description copied from interface: BundleArchive

Returns the absolute file path for the specified native library of the specified revision of the bundle associated with this archive.

Specified by:
findLibrary in interface BundleArchive
Parameters:
revision - the specified revision.
libName - the name of the library.
Returns:
a String that contains the absolute path name to the requested native library of the specified revision of the bundle associated with this archive.
Throws:
java.lang.Exception - if any error occurs.

deleteDirectoryTree

protected static boolean deleteDirectoryTree(java.io.File target)

update

protected void update(java.io.InputStream is)
               throws java.lang.Exception
Throws:
java.lang.Exception

purge

protected void purge()
              throws java.lang.Exception
Throws:
java.lang.Exception

remove

protected void remove()
               throws java.lang.Exception
Throws:
java.lang.Exception