/** * Method waits for unit data if the waitForData flag is set. * * @param unitRemote the remote to wait for data. * @param waitForData the flag to decide if the current thread should be * wait for the uni data. * @return the given unit remote. * @throws CouldNotPerformException is thrown if any error occurs during the * wait phase. * @throws InterruptedException is thrown in case the thread is externally * interrupted. */ private static UnitRemote<?> waitForData(final UnitRemote<?> unitRemote, final boolean waitForData) throws CouldNotPerformException, InterruptedException { if (waitForData) { unitRemote.waitForData(); } return unitRemote; }
/** * Method blocks until an initial data message was dataObserverreceived from * every remote controller. * * @throws CouldNotPerformException is thrown if any error occurs. * @throws InterruptedException is thrown in case the thread is externally * interrupted. */ @Override public void waitForData() throws CouldNotPerformException, InterruptedException { if (unitRemoteMap.isEmpty()) { return; } for (UnitRemote remote : unitRemoteMap.values()) { remote.waitForData(); } serviceStateObservable.waitForValue(); }
/** * Method blocks until an initial data message was received from every * remote controller or the given timeout is reached. * * @param timeout maximal time to wait for the main controller data. After * the timeout is reached a TimeoutException is thrown. * @param timeUnit the time unit of the timeout. * @throws CouldNotPerformException is thrown in case the any error occurs, * or if the given timeout is reached. In this case a TimeoutException is * thrown. * @throws InterruptedException is thrown in case the thread is externally * interrupted. */ @Override public void waitForData(final long timeout, final TimeUnit timeUnit) throws CouldNotPerformException, InterruptedException { if (unitRemoteMap.isEmpty()) { return; } //todo reimplement with respect to the given timeout. for (UnitRemote remote : unitRemoteMap.values()) { remote.waitForData(timeout, timeUnit); } serviceStateObservable.waitForValue(timeout, timeUnit); }
public void initObserver() throws CouldNotPerformException, InterruptedException { unitRemote.addDataObserver(dataObserver); unitRemote.addConnectionStateObserver(connectionStateObserver); unitRemote.waitForData(); updateDynamicComponents(); }