Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License"). You may not
   * use this file except in compliance with the License. A copy of the License is
   * located at
   * 
   * http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  * express or implied. See the License for the specific language governing
  * permissions and limitations under the License.
  */
 package com.amazonaws.services.simpleworkflow.flow.worker;
 
Timer doesn't have separate initiation decision as it is started immediately. But from the state machine point of view it is modeled the same as activity with no TimerStarted event used as initiation event.

Author(s):
fateev
 
 
     
     private boolean canceled;
 
         super(id);
         this. = attributes;
     }

    
Used for unit testing
 
         super(idstate);
         this. = attributes;
     }
     
     @Override
     public Decision getDecision() {
         switch () {
         case :
             return createStartTimerDecision();
         case :
             return createCancelTimerDecision();
         default:
             return null;
         }
     }
 
     @Override
     public void handleDecisionTaskStartedEvent() {
         switch () {
         case :
             .add("handleDecisionTaskStartedEvent");
              = .;
             .add(.toString());
             break;
         default:
             super.handleDecisionTaskStartedEvent();
         }
     }
 
     @Override
     public void handleCancellationFailureEvent(HistoryEvent event) {
         switch () {
         case :
             .add("handleCancellationFailureEvent");
              = .;
             .add(.toString());
             break;
         default:
             super.handleCancellationFailureEvent(event);
         }
     }
     
     @Override
     public void cancel(Runnable immediateCancellationCallback) {
          = true;
         immediateCancellationCallback.run();
         super.cancel(null);
     }

    
As timer is canceled immediately there is no need for waiting after cancellation decision was sent.
 
     @Override
     public boolean isDone() {
        return  == . || ;
    }
    private Decision createCancelTimerDecision() {
        tryCancel.setTimerId(.getTimerId());
        Decision decision = new Decision();
        decision.setCancelTimerDecisionAttributes(tryCancel);
        return decision;
    }
    private Decision createStartTimerDecision() {
        Decision decision = new Decision();
        decision.setDecisionType(..toString());
        return decision;
    }
New to GrepCode? Check out our FAQ X