public void start ( ) throws InvalidStateException , ManagementException { try { // request to change to STARTING final SleeStateChangeRequest startingRequest = new SleeStateChangeRequest ( ) { @ Override public void stateChanged ( SleeState oldState ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( generateMessageWithLogo ( "starting" ) ) ; } notifyStateChange ( oldState , getNewState ( ) ) ; } @ Override public void requestCompleted ( ) { // inner request, executed when the parent completes, to change to RUNNING final SleeStateChangeRequest runningRequest = new SleeStateChangeRequest ( ) { private SleeState oldState ; @ Override public void stateChanged ( SleeState oldState ) { logger . info ( generateMessageWithLogo ( "started" ) ) ; this . oldState = oldState ; } @ Override public void requestCompleted ( ) { notifyStateChange ( oldState , getNewState ( ) ) ; } @ Override public boolean isBlockingRequest ( ) { return true ; } @ Override public SleeState getNewState ( ) { return SleeState . RUNNING ; } } ; try { sleeContainer . setSleeState ( runningRequest ) ; } catch ( Throwable e ) { logger . error ( "Failed to set container in RUNNING state" , e ) ; try { stop ( false ) ; } catch ( Throwable f ) { logger . error ( "Failed to set container in STOPPED state, after failure to set in RUNNING state" , e ) ; } } } @ Override public boolean isBlockingRequest ( ) { // should be false, but the tck doesn't like it return true ; } @ Override public SleeState getNewState ( ) { return SleeState . STARTING ; } } ; sleeContainer . setSleeState ( startingRequest ) ; } catch ( InvalidStateException ex ) { throw ex ; } catch ( Exception ex ) { throw new ManagementException ( ex . getMessage ( ) , ex ) ; } }
Start the SLEE container