This article discusses dynamic discovery of available Carrot2 components via service extension points.
Many Carrot2 components, including algorithms, language components and
their building blocks, are implemented as
service extension points. While they can be referenced directly using explicit class
names (new LingoClusteringAlgorithm()
), you can also
enumerate and inspect their properties dynamically.
The following code enumerates all available algorithm providers, checks if the given algorithm supports the English language and clusters the same stream of documents repeatedly.
A similar service extension point exists for language component providers, this time we use a facade method that does additional sanity checks for us before returning the result: