Java library for initializing an asynchronous dependency

I am working on a project written in Java that has a dependency initiation system written internally. I was looking for a reliable third party library that could manage this, so we don't need to do maintenance on it. So far, my search hasn't helped much. Most of the results came back suggesting Spring, but I don't think that meets our needs.

We need a library:

  • Maintain the "initialization state" of dependencies on the system. This will mean that each "service", as I will call them, has already been created, but can be uninitialized, initialized, initialized. Most of them are solitary.
  • Keep a graph of the dependencies of each service and try to initialize only after all dependencies have been initialized.
  • Most importantly, it should allow asynchronous initialization. When a service is called to initialize, the library should not expect to do so after the call init()

    , but let the service call back. This is because most of the services make calls to our web service as part of their initialization.
  • The system must support uninitialization. eg. If we lose our connection to the web service, or your session ends for one of the services, we should be able to set it uninitialized, invalid whatever depends on it, and queue to reinitialize.
  • The system should be able to analyze the system in its current state, so we can keep track of what is being initialized and what depends on it.

I've already looked at Spring and Guice, and from what I can tell, they won't work because they prevent your dependencies from being in an intermediate initialization state and block the thread if you request an uninitialized object until it's fully built. I'm also not sure if they allow uninitialization.

I am fully aware that this can be a very specific and possibly strange system (it is quite old), so I expect that there can be no alternative to an internal solution.

+3


source to share





All Articles