-
Notifications
You must be signed in to change notification settings - Fork 12
Dependency injection
Sven Kubiak edited this page Nov 23, 2018
·
2 revisions
For dependency injections mangoo I/O uses Google Guice.
The simplest use case for dependency injection is to inject a class as a member variable.
@Inject
private MyClass myClass;
You can also grap an instance of a class using the static function of the Application class.
MyClass myClass = Application.getInstance(MyClass.class);
The most recommended approach is to use injection through the constructor.
private Foo foo;
@Inject
public MyClass(Foo foo) {
this.foo = Objects.requireNonNull(foo);
}
mangoo I/O 2015-2024 | [email protected]
- Getting started
- Configuration
- Routing
- Bootstrap
- Controllers
- Dependency injection
- Templating
- Working with JSON
- Persistence
- CORS
- Authentication
- Authorization
- Scheduler
- Async
- Filters
- Forms
- Session
- Flash
- Internationalization
- Caching
- Emails
- Asset management
- Logging
- Debugging
- Testing
- Administration
- Debian init.d script
- Extensions