Class 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 Detail

      • DocksModel

        public DocksModel​(org.osgi.framework.BundleContext context)
        Constructor of the dock model
        Parameters:
        context - The bundle context of the plugin which contains the dock model. Used to interact with OSGi's event service and remote OSGi
    • Method Detail

      • 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 interface org.osgi.service.event.EventHandler
        See Also:
        EventHandler.handleEvent(org.osgi.service.event.Event)
      • getDockById

        public DockModel getDockById​(String dockId)
        Return the dock status model with of the dock with the given ID
        Parameters:
        dockId - ID of the dock to retrieve. The dock with the given ID has to exist
        Returns:
        The model of the requested dock