|This page is under construction|
Please help review and edit this page.
Handlers are objects that provide a specialized implementation of a general interface, selected by name. The concrete implementation is chosen at runtime by a registry, among several available choices.
The handler pattern can be interpreted as a special case of the well known strategy pattern, in which the strategy is chosen at runtime based on a single parameter, a name. A typical example would be a set of classes that provide specialized handling for different types of media files.
Handlers are typically obtained from specialized factories called registries. They should not be constructed directly. Handlers that are defined by an extension will typically make use of the ObjectFactory mechanism.
Some well known types of handlers in MediaWiki include:
- content handlers (ContentHandler)
- API modules (ApiBase)
- page actions (Action)
- special pages (SpecialPage)
- media handlers (MediaHandler)
Handlers often have their name end in "Handler", though some types of handlers use their own separate naming convention.
As of August 2020, several instances of the Handler pattern exist in the code base, but the application of the pattern is somewhat post-hoc, and the mechanisms for registering and obtaining handlers are not uniform.