Class DocksModel
- java.lang.Object
-
- java.util.Observable
-
- de.uka.ipd.sdq.codegen.simucontroller.dockmodel.DocksModel
-
- All Implemented Interfaces:
org.osgi.service.event.EventHandler
public class DocksModel extends Observable implements org.osgi.service.event.EventHandler
The dock model class is used to store the central model of the simulation docks. A simulation dock is an OSGi service capable of accepting a simulation bundle. It simulates the bundle informing is dock model via OSGi events of its progress. The dock model uses the events to synchronize its view. It also uses remote OSGi events to discover new remote docks.
-
-
Constructor Summary
Constructors Constructor Description DocksModel(org.osgi.framework.BundleContext context)
Constructor of the dock model
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
finalize()
Unregister the listenerCollection<DockModel>
getAllDocks()
Returns a collection of all docks currently known in this dock modelDockModel
getBestFreeDock()
Gets the next best free dock from the list of unused docks.DockModel
getDockById(String dockId)
Return the dock status model with of the dock with the given IDprotected DockModel
getDockByURI(ch.ethz.iks.r_osgi.URI uri)
Retrieve a dock status model by the docks URI.List<DockModel>
getLocalDocks()
Return a list of all local docksList<DockModel>
getRemoteDocks()
Return a list of all remote docksvoid
handleEvent(org.osgi.service.event.Event event)
Method to handle OSGi Events sent by the SimulationDock to inform about status updates (non-Javadoc).protected void
removeDock(DockModel dock)
Called by service unregister events to remove the dock from this model-
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
-
-
-
Method Detail
-
finalize
protected void finalize() throws Throwable
Unregister the listener- Overrides:
finalize
in classObject
- Throws:
Throwable
- See Also:
Object.finalize()
-
removeDock
protected void removeDock(DockModel dock)
Called by service unregister events to remove the dock from this model- Parameters:
dock
- The dock which has been removed externally
-
getDockByURI
protected DockModel getDockByURI(ch.ethz.iks.r_osgi.URI uri)
Retrieve a dock status model by the docks URI. Returns null if the dock is unknown or a local dock.- Parameters:
uri
- The URI of the dock to retrieve- Returns:
- The requested dock or null if the dock does not exist or is local
-
getAllDocks
public Collection<DockModel> getAllDocks()
Returns a collection of all docks currently known in this dock model- Returns:
- A collection of all docks currently known in this dock model
-
getBestFreeDock
public DockModel getBestFreeDock() throws InterruptedException
Gets the next best free dock from the list of unused docks. Waits for a dock to become available if all docks are busy. The dock is removed from the list of free docks.- Returns:
- The next best dock available to process a request
- Throws:
InterruptedException
- Execption when the thread is terminated
-
getLocalDocks
public List<DockModel> getLocalDocks()
Return a list of all local docks- Returns:
- A list of local docks
-
getRemoteDocks
public List<DockModel> getRemoteDocks()
Return a list of all remote docks- Returns:
- A list of remote docks
-
handleEvent
public void handleEvent(org.osgi.service.event.Event event)
Method to handle OSGi Events sent by the SimulationDock to inform about status updates (non-Javadoc). The method is not intended to be called directly!- Specified by:
handleEvent
in interfaceorg.osgi.service.event.EventHandler
- See Also:
EventHandler.handleEvent(org.osgi.service.event.Event)
-
-