Class BundleCache


  • public class BundleCache
    extends java.lang.Object

    This class, combined with BundleArchive, and concrete BundleRevision subclasses, implement the Felix bundle cache. It is possible to configure the default behavior of this class by passing properties into Felix' constructor. The configuration properties for this class are (properties starting with "felix" are specific to Felix, while those starting with "org.osgi" are standard OSGi properties):

    • felix.cache.filelimit - The integer value of this string sets an upper limit on how many files the cache will open. The default value is zero, which means there is no limit.
    • org.osgi.framework.storage - Sets the directory to use as the bundle cache; by default bundle cache directory is felix-cache in the current working directory. The value should be a valid directory name. The directory name can be either absolute or relative. Relative directory names are relative to the current working directory. The specified directory will be created if it does not exist.
    • felix.cache.rootdir - Sets the root directory to use to calculate the bundle cache directory for relative directory names. If org.osgi.framework.storage is set to a relative name, by default it is relative to the current working directory. If this property is set, then it will be calculated as being relative to the specified root directory.
    • felix.cache.locking - Enables or disables bundle cache locking, which is used to prevent concurrent access to the bundle cache. This is enabled by default, but on older/smaller JVMs file channel locking is not available; set this property to false to disable it.
    • felix.cache.bufsize - Sets the buffer size to be used by the cache; the default value is 4096. The integer value of this string provides control over the size of the internal buffer of the disk cache for performance reasons.
    • For specific information on how to configure the Felix framework, refer to the Felix framework usage documentation.

    See Also:
    BundleArchive
    • Constructor Summary

      Constructors 
      Constructor Description
      BundleCache​(Logger logger, java.util.Map configMap)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      BundleArchive create​(long id, int startLevel, java.lang.String location, java.io.InputStream is, ModuleConnector connectFactory)  
      void delete()  
      BundleArchive[] getArchives​(ModuleConnector connectFactory)  
      java.io.File getCacheDir()  
      static java.util.Map<java.lang.String,​java.lang.Object> getMainAttributes​(java.util.Map<java.lang.String,​java.lang.Object> headers, java.io.InputStream inputStream, int size)  
      static java.util.Map<java.lang.String,​java.lang.Object> getMainAttributes​(java.util.Map<java.lang.String,​java.lang.Object> headers, java.io.InputStream inputStream, long size)  
      java.io.File getSystemBundleDataFile​(java.lang.String fileName)
      Provides the system bundle access to its private storage area; this special case is necessary since the system bundle is not really a bundle and therefore must be treated in a special way.
      void release()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CACHE_BUFSIZE_PROP

        public static final java.lang.String CACHE_BUFSIZE_PROP
        See Also:
        Constant Field Values
      • CACHE_ROOTDIR_PROP

        public static final java.lang.String CACHE_ROOTDIR_PROP
        See Also:
        Constant Field Values
      • CACHE_LOCKING_PROP

        public static final java.lang.String CACHE_LOCKING_PROP
        See Also:
        Constant Field Values
      • CACHE_FILELIMIT_PROP

        public static final java.lang.String CACHE_FILELIMIT_PROP
        See Also:
        Constant Field Values
    • Constructor Detail

      • BundleCache

        public BundleCache​(Logger logger,
                           java.util.Map configMap)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
    • Method Detail

      • getMainAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getMainAttributes​(java.util.Map<java.lang.String,​java.lang.Object> headers,
                                                                                               java.io.InputStream inputStream,
                                                                                               long size)
                                                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getMainAttributes

        public static java.util.Map<java.lang.String,​java.lang.Object> getMainAttributes​(java.util.Map<java.lang.String,​java.lang.Object> headers,
                                                                                               java.io.InputStream inputStream,
                                                                                               int size)
                                                                                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • release

        public void release()
      • getCacheDir

        public java.io.File getCacheDir()
      • delete

        public void delete()
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getArchives

        public BundleArchive[] getArchives​(ModuleConnector connectFactory)
                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • create

        public BundleArchive create​(long id,
                                    int startLevel,
                                    java.lang.String location,
                                    java.io.InputStream is,
                                    ModuleConnector connectFactory)
                             throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getSystemBundleDataFile

        public java.io.File getSystemBundleDataFile​(java.lang.String fileName)
                                             throws java.lang.Exception
        Provides the system bundle access to its private storage area; this special case is necessary since the system bundle is not really a bundle and therefore must be treated in a special way.
        Parameters:
        fileName - the name of the file in the system bundle's private area.
        Returns:
        a File object corresponding to the specified file name.
        Throws:
        java.lang.Exception - if any error occurs.