public synchronized static Lifecycle get ( ) { if ( INSTANCE == null ) { Lifecycle instance ; String p = SystemProperties . getString ( "hudson.lifecycle" ) ; if ( p != null ) { try { ClassLoader cl = Jenkins . getInstance ( ) . getPluginManager ( ) . uberClassLoader ; instance = ( Lifecycle ) cl . loadClass ( p ) . newInstance ( ) ; } catch ( InstantiationException e ) { InstantiationError x = new InstantiationError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } catch ( IllegalAccessException e ) { IllegalAccessError x = new IllegalAccessError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } catch ( ClassNotFoundException e ) { NoClassDefFoundError x = new NoClassDefFoundError ( e . getMessage ( ) ) ; x . initCause ( e ) ; throw x ; } } else { if ( Functions . isWindows ( ) ) { instance = new Lifecycle ( ) { @ Override public void verifyRestartable ( ) throws RestartNotSupportedException { throw new RestartNotSupportedException ( "Default Windows lifecycle does not support restart." ) ; } } ; } else if ( System . getenv ( "SMF_FMRI" ) != null && System . getenv ( "SMF_RESTARTER" ) != null ) { // when we are run by Solaris SMF, these environment variables are set. instance = new SolarisSMFLifecycle ( ) ; } else { // if run on Unix, we can do restart try { instance = new UnixLifecycle ( ) ; } catch ( final IOException e ) { LOGGER . log ( Level . WARNING , "Failed to install embedded lifecycle implementation" , e ) ; instance = new Lifecycle ( ) { @ Override public void verifyRestartable ( ) throws RestartNotSupportedException { throw new RestartNotSupportedException ( "Failed to install embedded lifecycle implementation, so cannot restart: " + e , e ) ; } } ; } } } assert instance != null ; INSTANCE = instance ; } return INSTANCE ; }
Gets the singleton instance .