gerrithudsontrigger/src/main/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/GerritAdministrativeMonitor.java
/**
     * Adds this monitor as a connection listener to PluginImpl. If PluginImpl hasn't started yet, a separate Thread
     * will be started that tries again in a little while.
     *
     * @see PluginImpl#addListener(com.sonyericsson.hudson.plugins.gerrit.gerritevents.ConnectionListener)
     */
Adds this monitor as a connection listener to PluginImpl. If PluginImpl hasn't started yet, a separate Thread
will be started that tries again in a little while.


Adds this monitor as a connection listener to PluginImpl . If PluginImpl hasn ' t started yet a separate Thread will be started that tries again in a little while .
protected void addThisAsConnectionListener() {
        if (PluginImpl.getInstance() != null) {
            connected = PluginImpl.getInstance().addListener(this);
            checkGerritVersionFeatures();
        } else {
            Runnable runner = new Runnable() {
                private static final int SLEEP_INTERVAL = 500;
                @Override
                public void run() {
                    while (PluginImpl.getInstance() == null) {
                        try {
                            Thread.sleep(SLEEP_INTERVAL);
                        } catch (InterruptedException ex) {
                            logger.debug("Got interrupted while sleeping...", ex);
                        }
                    }
                    PluginImpl plugin = PluginImpl.getInstance();
                    if (plugin != null) {
                        connected = plugin.addListener(GerritAdministrativeMonitor.this);
                        checkGerritVersionFeatures();
                    } else {
                        logger.error("Unable to register GerritAdministrativeMonitor");
                    }
                }
            };
            Thread thread = new Thread(runner);
            thread.setDaemon(true);
            thread.start();
        }
    }
protected void addThisAsConnectionListener ( ) { if ( PluginImpl . getInstance ( ) != null ) { connected = PluginImpl . getInstance ( ) . addListener ( this ) ; checkGerritVersionFeatures ( ) ; } else { Runnable runner = new Runnable ( ) { private static final int SLEEP_INTERVAL = 500 ; @ Override public void run ( ) { while ( PluginImpl . getInstance ( ) == null ) { try { Thread . sleep ( SLEEP_INTERVAL ) ; } catch ( InterruptedException ex ) { logger . debug ( "Got interrupted while sleeping..." , ex ) ; } } PluginImpl plugin = PluginImpl . getInstance ( ) ; if ( plugin != null ) { connected = plugin . addListener ( GerritAdministrativeMonitor . this ) ; checkGerritVersionFeatures ( ) ; } else { logger . error ( "Unable to register GerritAdministrativeMonitor" ) ; } } } ; Thread thread = new Thread ( runner ) ; thread . setDaemon ( true ) ; thread . start ( ) ; } }
Adds this monitor as a connection listener to PluginImpl.
Adds this monitor as a connection listener to PluginImpl .
//We were created first... let's wait without disrupting the flow.