Class MRUBundleFileList
java.lang.Object
org.eclipse.osgi.storage.bundlefile.MRUBundleFileList
- All Implemented Interfaces:
EventDispatcher<Object,
Object, BundleFile>
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.
-
Constructor Summary
ConstructorDescriptionMRUBundleFileList
(int fileLimit, org.eclipse.osgi.internal.debug.Debug debug) -
Method Summary
Modifier and TypeMethodDescriptionboolean
add
(BundleFile bundleFile) Adds a BundleFile which is about to be opened to the MRU list.void
final void
dispatchEvent
(Object eventListener, Object listenerObject, int eventAction, BundleFile eventObject) This method is called once for each listener.boolean
isClosing
(BundleFile bundleFile) Returns true if this MRUBundleFileList is currently closing the specified bundle file on the current thread.boolean
boolean
remove
(BundleFile bundleFile) Removes a bundle file which is about to be closedvoid
shutdown()
Closes the bundle file closer thread for the MRU listvoid
use
(BundleFile bundleFile) Increments the use stamp of a bundle file
-
Constructor Details
-
MRUBundleFileList
public MRUBundleFileList(int fileLimit, org.eclipse.osgi.internal.debug.Debug debug)
-
-
Method Details
-
add
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.- Returns:
- true if back pressure is needed
-
remove
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
Increments the use stamp of a bundle file- Parameters:
bundleFile
- the bundle file to increment the use stamp for
-
dispatchEvent
public final void dispatchEvent(Object eventListener, Object listenerObject, int eventAction, BundleFile 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 interfaceEventDispatcher<Object,
Object, BundleFile> - Parameters:
eventListener
- This is the key in the Map.Entry for the listener. The implementation of this method must cast it to the appropriate listener class for the event to be delivered and the appropriate listener method must then be called.listenerObject
- This is the value in the Map.Entry for the listener.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.
-
applyBackpressure
public void applyBackpressure() -
shutdown
public void shutdown()Closes the bundle file closer thread for the MRU list -
isClosing
Returns true if this MRUBundleFileList is currently closing the specified bundle file on the current thread.- Parameters:
bundleFile
- the bundle file- Returns:
- true if the bundle file is being closed on the current thread
-
isEnabled
public boolean isEnabled()
-