-
Notifications
You must be signed in to change notification settings - Fork 2
Closed
Description
While XML is a powerful ML, not many people like working with XML. So, there are a few feedbacks on how writing service definition can be improved.
Instead of using XML, we borrow the idea of component scanning from Spring Beans by allowing developers to define the definitions in Python (beside #21).
# the ready-to-go standalone container already implemented
from imagination.standalone import container
container.configure('myapp.config')
container.configure('library_1.config')
# ...
container.configure('library_n.config')from imagination.decorators import config
@config(scan=['myapp.submodule_1', '...', 'myapp.submodule_n'])
class MyAppConfigurationA:
# ...from imagination.decorator.stereotype import component
@component
class Dependency1Class:
# ...from imagination.decorator import auto_wired
from imagination.decorator.stereotype import component, identifier
@auto_wired
@component
@identifier('myapp.service.one')
class Service1:
dependency1: Dependency1ClassThis is borrowed the idea from Flask and the presumably discontinued Spring-Python.