Skip to content

Conversation

@ppkarwasz
Copy link
Contributor

The current factory pattern used with the AbstractManager registry is unnecessarily complex. It relies on:

  • Stateless factory classes to create managers of each type,
  • Separate FactoryData parameter objects to pass construction data

What this PR does

This PR simplifies the registry factory mechanism by:

  • Replacing the factory classes with inline lambda factories
  • Allowing stateful factory lambdas, removing boilerplate FactoryData classes in most cases
  • Keeping factory logic localized and easier to follow within the registry call site

This is a pure refactoring, it does not change behavior. It improves code readability and maintainability by reducing indirection and eliminating unnecessary types.

Notes

FactoryData parameter objects are still used where necessary:

  • RollingFileManager and RollingRandomAccessFileManager still require parameter objects since they update state on each retrieval, not just during initialization.
  • Other managers still pass Configuration through ConfigurationFactoryData to access getLoggerContext(), which remains useful.

Checklist

🧪 Tests (select one)

  • I have added or updated tests to cover my changes.
  • No additional tests are needed for this change.

📝 Changelog (select one)

  • I added a changelog entry in src/changelog/.2.x.x. (See Changelog Entry File Guide).
  • This is a trivial change and does not require a changelog entry.

The current factory pattern used with the `AbstractManager` registry is unnecessarily complex. It relies on:

* **Stateless factory classes** to create managers of each type,
* **Separate `FactoryData` parameter objects** to pass construction data

#### What this PR does

This PR simplifies the registry factory mechanism by:

* Replacing the factory classes with **inline lambda factories**
* Allowing **stateful factory lambdas**, removing boilerplate `FactoryData` classes in most cases
* Keeping factory logic **localized and easier to follow** within the registry call site

This is a **pure refactoring**, it does not change behavior. It improves code readability and maintainability by reducing indirection and eliminating unnecessary types.

#### Notes

`FactoryData` parameter objects are still used where necessary:

* **`RollingFileManager`** and **`RollingRandomAccessFileManager`** still require parameter objects since they update state on each retrieval, not just during initialization.
* Other managers still pass `Configuration` through `ConfigurationFactoryData` to access `getLoggerContext()`, which remains useful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant