org.eclipse.osgi.baseadaptor.bundlefile
Class MRUBundleFileList

java.lang.Object
  extended by org.eclipse.osgi.baseadaptor.bundlefile.MRUBundleFileList
All Implemented Interfaces:
EventDispatcher

public class MRUBundleFileList
extends java.lang.Object
implements EventDispatcher

A simple/quick/small implementation of an MRU (Most Recently Used) list to keep track of open BundleFiles. The MRU will use the file limit specified by the property "osgi.bundlefile.limit" by default unless the MRU is constructed with a specific file limit.

Since:
3.2

Constructor Summary
MRUBundleFileList()
           
MRUBundleFileList(int fileLimit)
           
 
Method Summary
 void add(BundleFile bundleFile)
          Adds a BundleFile which is about to be opened to the MRU list.
 void dispatchEvent(java.lang.Object eventListener, java.lang.Object listenerObject, int eventAction, java.lang.Object eventObject)
          This method is called once for each listener.
 boolean remove(BundleFile bundleFile)
          Removes a bundle file which is about to be closed
 void shutdown()
          Closes the bundle file closer thread for the MRU list
 void use(BundleFile bundleFile)
          Increments the use stamp of a bundle file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MRUBundleFileList

public MRUBundleFileList()

MRUBundleFileList

public MRUBundleFileList(int fileLimit)
Method Detail

add

public void add(BundleFile bundleFile)
Adds a BundleFile which is about to be opened to the MRU list. If the number of open BundleFiles == the fileLimit then the least recently used BundleFile is closed.

Parameters:
bundleFile - the bundle file about to be opened.

remove

public boolean remove(BundleFile bundleFile)
Removes a bundle file which is about to be closed

Parameters:
bundleFile - the bundle file about to be closed
Returns:
true if the bundleFile existed in the MRU; false otherwise

use

public void use(BundleFile bundleFile)
Increments the use stamp of a bundle file

Parameters:
bundleFile - the bundle file to increment the use stamp for

dispatchEvent

public final void dispatchEvent(java.lang.Object eventListener,
                                java.lang.Object listenerObject,
                                int eventAction,
                                java.lang.Object eventObject)
Description copied from interface: EventDispatcher
This method is called once for each listener. This method must cast the event listener object to the appropriate listener class for the event type and call the appropriate listener method.

The method should properly log/handle any exceptions thrown by the called listener. The EventManager will ignore any Throwable thrown by this method in order to continue delivery of the event to the next listener.

Specified by:
dispatchEvent in interface EventDispatcher
Parameters:
eventListener - This listener must be cast to the appropriate listener class for the event to be delivered and the appropriate listener method must then be called.
listenerObject - This is the optional companion object that was specified when the listener was added to the EventListeners object.
eventAction - This value was passed to the ListenerQueue object via one of its dispatchEvent* method calls. It can provide information (such as which listener method to call) so that the EventDispatcher can complete the delivery of the event to the listener.
eventObject - This object was passed to the ListenerQueue object via one of its dispatchEvent* method calls. This object was created by the event source and is passed to this method. It should contain all the necessary information (such as what event object to pass) so that this method can complete the delivery of the event to the listener. This is typically the actual event object.

shutdown

public void shutdown()
Closes the bundle file closer thread for the MRU list