Since the SystemLogger
would seem to be an integral part of your class, I would pass it as a constructor argument. Personally, I think it makes it more obvious which collaborators your class needs to be properly initialised. It should also be final.
This also has the benefit of making your class easier to test using mocks. You could use mocks using Autowired
on an attibute, but it would involve more effort (e.g. exposing a setter
- which would be bad, or shoe-horning a mock into the ApplicationContext
).
This may just come down to personal preference, but for what it's worth, the Spring Consultant that led the Core Spring Training I attended recommended not using Autowired
on class members.