Now that we've seen how useful other service beans can be in our Java code, let's make it easier to get to those services. The best way to get an instance of the runtime bean, or any other project bean, is to "inject" it into the service class using dependency injection.
Dependency injection is when the bean declares a dependency and the container (for example, Tomcat and Spring) provides or injects that dependency to the bean as part of its initialization. The benefit is that the property is populated for us by the container. We do not need to fetch an instance of the service in code.
In our example,
DbOpsSvc from the
JavaServices project, we also inject
runtimeService into our service class. The
updateCustomerInjected() method ...