PicoContainer startup order management

I was instructed to do some refactoring work on how we run applications. Basically, we have a bunch of console applications that depended on the GUI application launch code, causing fake dependencies that have kick-on effects, for which we need to send libraries, and which dependencies require other modules.

So, I wrote a simple startup structure in which I basically just drop empty Runnable objects into the list and then run them in order - and it works.

But I thought: we already have PicoContainer in our project, so all of these things that need to be run at startup can potentially be thrown into PicoContainer, and if they implement Startable, they will start ...

But in some cases we want to indicate the order between them. For example, I don’t want any other component to write to the log before we write a header in the log indicating that the application is starting. I know that I can introduce ordering by introducing dependencies on injections, but in this case it looks like a hack - I will need to add a log header entry as a dependency for every other component that can write to the log, which is not very convenient.

Nevertheless, it seems that it would be nice to control the startup order of PicoContainer, maybe there is another way?

Alternatively, I could just keep it simple and stick to my Runnable list. In the end, it works.

+3
2

/ , , , .

:

1) MyStartable init() Comparable.

2) MyStart, MyStartable.

3) MyStart /

4) MyStart / , .

5) init() MyStartable

, "" , .

+2

? , (picocontainer) , . PicoContainer, , , .

0

Source: https://habr.com/ru/post/1740874/


All Articles