public PluginInterface findPluginWithId( Class<? extends PluginTypeInterface> pluginType, String pluginId, boolean waitForPluginToBeAvailable ) { PluginInterface pluginInterface = findPluginWithId( pluginType, pluginId ); return waitForPluginToBeAvailable && pluginInterface == null ? waitForPluginToBeAvailable( pluginType, pluginId, WAIT_FOR_PLUGIN_TO_BE_AVAILABLE_LIMIT ) : pluginInterface; }
private PluginInterface waitForPluginToBeAvailable( Class<? extends PluginTypeInterface> pluginType, String pluginId, int waitLimit ) { int timeToSleep = 50; try { Thread.sleep( timeToSleep ); waitLimit -= timeToSleep; } catch ( InterruptedException e ) { log.logError( e.getLocalizedMessage(), e ); Thread.currentThread().interrupt(); return null; } PluginInterface pluginInterface = findPluginWithId( pluginType, pluginId ); return waitLimit <= 0 && pluginInterface == null ? null : pluginInterface != null ? pluginInterface : waitForPluginToBeAvailable( pluginType, pluginId, waitLimit ); } }