refactor java backend to use more dependency injection

**please review**
Please do not leave code commented out. Remove it!