Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. interface SchedulableState : ContractState {
  2. /**
  3. * Indicate whether there is some activity to be performed at some future point in time with respect to this
  4. * [ContractState], what that activity is and at what point in time it should be initiated.
  5. * This can be used to implement deadlines for payment or processing of financial instruments according to a schedule.
  6. *
  7. * The state has no reference to it's own StateRef, so supply that for use as input to any FlowLogic constructed.
  8. *
  9. * @return null if there is no activity to schedule.
  10. */
  11. fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity?
  12. }
  13.  
  14. class ExampleState(val initiator: Party,
  15. val requestTime: Instant,
  16. val delay: Long) : SchedulableState {
  17. override val contract: Contract get() = DUMMY_PROGRAM_ID
  18. override val participants: List<AbstractParty> get() = listOf(initiator)
  19. override fun nextScheduledActivity(thisStateRef: StateRef, flowLogicRefFactory: FlowLogicRefFactory): ScheduledActivity? {
  20. val responseTime = requestTime.plusSeconds(delay)
  21. val flowRef = flowLogicRefFactory.create(FlowToStart::class.java)
  22. return ScheduledActivity(flowRef, responseTime)
  23. }
  24. }
  25.  
  26. @InitiatingFlow
  27. @SchedulableFlow
  28. class FlowToStart : FlowLogic<Unit>() {
  29. @Suspendable
  30. override fun call() {
  31. // Do stuff.
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement