HomeDevCentral

Provide reflection bricks to build a service container

This commit has been deleted in the repository: it is no longer reachable from any branch, tag, or ref.

Description

Provide reflection bricks to build a service container

Summary:
How to automatically build a controller with dependency injection?

A solution could be to get a services container with objects
of different types, and a controller with a constructor requiring
the needed services.

A working example of this solution can be found in AcmeApplication,
instantiated in CodeClassTest unit test.

A use case can be to automate in a MVC framework the controllers
instantiation.

This solution requires services to be first initialized and doesn't
allow other topologies like lazy loading directly, but the reflection
classes added can be use as a base to build custom services containers.

For example, a variant of CodeClass::newInstanceFromServices can be
used with a different callable to select and build the dependency
from the type in key.

The scope of this commit is to offer bricks required to create
a service container, not to be a dependency injection framework.

Test Plan:
New unit tests offer full code coverage for added classes.

A proof of concept can be found in AcmeApplication and CodeClassTest.

A real-world test will be to build a service container in Zed.

Reviewers: dereckson

Reviewed By: dereckson

Differential Revision: https://devcentral.nasqueron.org/D3204

Details

Provenance
derecksonAuthored on Jun 19 2023, 22:55
derecksonPushed on Jun 19 2023, 23:14
Reviewer
dereckson
Differential Revision
D3204: Provide reflection bricks to build a service container
Parents
rKOTd1bc2111e0ca: Fix dependency in CallableElement
Branches
Unknown
Tags
Unknown