Post construction

The @AfterInitialized method is called right after the service is instantiated, and each field is injected.

This feature is useful, when you have a bunch of dependencies of your service, and you don't want to use a constructor, because the initialization would be too robust.

@Service
class CloudController {
    @Inject
    private CloudConnection connection;
    
    @AfterInitialized
    private void init() {
        connection.sendHandshake();
    }
}

Last updated