3636import javax .persistence .TemporalType ;
3737
3838import com .cloud .utils .db .GenericDao ;
39+ import com .cloud .utils .db .StateMachine ;
40+ import com .cloud .utils .fsm .FiniteStateObject ;
3941
4042@ Entity
4143@ Table (name ="vm_instance" )
4244@ Inheritance (strategy =InheritanceType .JOINED )
4345@ DiscriminatorColumn (name ="type" , discriminatorType =DiscriminatorType .STRING , length =32 )
44- public class VMInstanceVO implements VirtualMachine {
46+ public class VMInstanceVO implements VirtualMachine , FiniteStateObject < State , VirtualMachine . Event > {
4547 @ Id
4648 @ TableGenerator (name ="vm_instance_sq" , table ="sequence" , pkColumnName ="name" , valueColumnName ="value" , pkColumnValue ="vm_instance_seq" , allocationSize =1 )
4749 @ Column (name ="id" , updatable =false , nullable = false )
@@ -65,7 +67,8 @@ public class VMInstanceVO implements VirtualMachine {
6567 * the state machine needs to go through the DAO object because someone
6668 * else could be updating it as well.
6769 */
68- @ Enumerated (value =EnumType .STRING )
70+ @ Enumerated (value =EnumType .STRING )
71+ @ StateMachine (state =State .class , event =Event .class )
6972 @ Column (name ="state" , updatable =true , nullable =false , length =32 )
7073 private State state = null ;
7174
@@ -249,7 +252,8 @@ public State getState() {
249252 }
250253
251254 // don't use this directly, use VM state machine instead, this method is added for migration tool only
252- public void setState (State state ) {
255+ @ Override
256+ public void setState (State state ) {
253257 this .state = state ;
254258 }
255259
0 commit comments