Singletons
Before we move on from the high-level and design theory topic and take a look at implementing extensions in Jenkins, there is one more Java design pattern that we still need to cover—the Singleton pattern.
Singletons are used when you want to ensure that there will only be either zero or one instance of a given class.
Typically, this pattern occurs when you need to control concurrent actions—by ensuring that there is only a maximum of one instance possible, we can be sure that we will not face any concurrency or race conditions, as this class (and its code) will definitely be the only possible instance at any given time. Usually, a Singleton will be used by many different functions, and its purpose is to handle and manage this demand safely.
A common Singleton example is a logging utility. For example, a class that takes a message from several different areas of a system at any point in time. It then opens a log file and appends the message to the file. We wouldn't want two classes...