I've just started using clean architecture, It's clean and nice, but I've found a bit confusing use case.

My application should be able to register to update a token after some time, so I handled that by calling a use case that starts a ScheduledExecutorService in a statically managed object, after the time is met, the executor should be able to call another use case, but the problem is that the managed object (which is from the core logic) will be able to call another use case, so the use case will not be called from entry point as a REStful call, it's however called from an object started by another use case.

So, how can I achieve this in a clean way?

  • You are asking how to pass object between different threads?. I don't know why you are worried about restful call? Oct 16, 2019 at 11:44
  • Well no, I don't know from where to call the use case [b], as it's currently called by the thread that is started by use case [a], so here, use cases are calling each other, which is not valid in clean architecture. Oct 16, 2019 at 11:55
  • Are you sure it is not a situation of "Use Case Do X Now" and "Use Case Do X Later" calling the same backing implementation? Oct 16, 2019 at 12:30
  • The situation is that the use case will call a static object that does something, that thing should have a static lifecycle so that I can check for it later if another entry point tries to re-schedule the same part again Oct 16, 2019 at 12:41
  • surely "clean architecture" doesnt care about the details of threads?
    – Ewan
    Oct 16, 2019 at 14:11


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.