AbsaOSS / AbsaOSS/hyperdrive

Identify component factories by identifier string

Offen
#99 0 Kommentare 1 Reaktion 1 zugewiesene Person Zugewiesen an @kevinwallimann Auf GitHub ansehen
enhancement
Vorherrschende Sprache
Scala
Sterne
47
Forks
14
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**Description**
Currently, component factories are loaded in `ClassLoaderUtils` given their fully qualified classnames. The classname is passed by the configuration. (e.g. `component.writer`)

That means that components don't have the possibility to be refactored (renaming, moving to a different package) without introducing a breaking change which would require updating any existing configuration that uses that component.

**Tasks**
- Add a method `getIdentifier: String` to the interface `ComponentFactory`. `getClass.getName` may be used as a default value. (so this feature won't be a breaking change)
- Implementing components are responsible for providing a unique identifier. It's advisable to prefix the identifier with a human readable name, because it will be referenced in the configuration, logged, etc..
- Use `getIdentifier` to load the factory in `ClassLoaderUtils`. Currently, it loads the class directly given the class name. This approach doesn't work to efficiently load the factory by the identifier. With #83, component factories can be loaded using the Service Provider Interface (SPI), i.e. with `ServiceLoader`. All factories expose the `getIdentifier` method, that's how it can be found

**Other**
- The same identifier might be used by each component to prefix its configuration properties to avoid name clashes.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.