refactor java backend to use more dependency injection