public File getBootFile ( ) { if ( bootFile == null ) { synchronized ( this ) { if ( bootFile == null ) { if ( bootFileReset ) { //Reset the done bootup and the sequence, so that the old file we are reloading from // overwrites the main file on successful boot, and history is reset as when booting new doneBootup . set ( false ) ; sequence . set ( 0 ) ; } // If it's a reload with no new boot file name and we're persisting our config, we boot from mainFile, // as that's where we persist if ( bootFileReset && ! interactionPolicy . isReadOnly ( ) && newReloadBootFileName == null ) { // we boot from mainFile bootFile = mainFile ; } else { // It's either first boot, or a reload where we're not persisting our config or with a new boot file. // So we need to figure out which file we're meant to boot from String bootFileName = this . bootFileName ; if ( newReloadBootFileName != null ) { //A non-null new boot file on reload takes precedence over the reloadUsingLast functionality //A new boot file was specified. Use that and reset the new name to null bootFileName = newReloadBootFileName ; newReloadBootFileName = null ; } else if ( interactionPolicy . isReadOnly ( ) && reloadUsingLast ) { //If we were reloaded, and it is not a persistent configuration we want to use the last from the history bootFileName = LAST ; } boolean usingRawFile = bootFileName . equals ( rawFileName ) ; if ( usingRawFile ) { bootFile = mainFile ; } else { bootFile = determineBootFile ( configurationDir , bootFileName ) ; try { bootFile = bootFile . getCanonicalFile ( ) ; } catch ( IOException ioe ) { throw ControllerLogger . ROOT_LOGGER . canonicalBootFileNotFound ( ioe , bootFile ) ; } } if ( ! bootFile . exists ( ) ) { if ( ! usingRawFile ) { // TODO there's no reason usingRawFile should be an exception, // but the test infrastructure stuff is built around an assumption // that ConfigurationFile doesn't fail if test files are not // in the normal spot if ( bootFileReset || interactionPolicy . isRequireExisting ( ) ) { throw ControllerLogger . ROOT_LOGGER . fileNotFound ( bootFile . getAbsolutePath ( ) ) ; } } // Create it for the NEW and DISCARD cases if ( ! bootFileReset && ! interactionPolicy . isRequireExisting ( ) ) { createBootFile ( bootFile ) ; } } else if ( ! bootFileReset ) { if ( interactionPolicy . isRejectExisting ( ) && bootFile . length ( ) > 0 ) { throw ControllerLogger . ROOT_LOGGER . rejectEmptyConfig ( bootFile . getAbsolutePath ( ) ) ; } else if ( interactionPolicy . isRemoveExisting ( ) && bootFile . length ( ) > 0 ) { if ( ! bootFile . delete ( ) ) { throw ControllerLogger . ROOT_LOGGER . cannotDelete ( bootFile . getAbsoluteFile ( ) ) ; } createBootFile ( bootFile ) ; } } // else after first boot we want the file to exist } } } } return bootFile ; }
Gets the file from which boot operations should be parsed .