Ok, let me provide you with some history.
When Spring was first launched we defined all beans in XML; similarly to what
you are doing. However, if you take a closer look, you are not declaring the
“injection” of the properties because the properties are annotated with
“@Inject” in the class.
If we were to do the creation of “storageUtil” only in XML we would use
something like:
```
<bean id="storageUtil" class="com.cloud.storage.StorageUtil" >
<proerty name=”clusterDao” ref=”clusterDao” />
<proerty name=”hostDao” ref=”hostDao” />
<proerty name=”storagePoolDao” ref=”primaryDataStoreDao” />
<proerty name=”vmInstanceDao” ref=”vmInstanceDao” />
<proerty name=”volumeDao” ref=”volumeDao” />
</bean>
```
With time things evolved and annotations started to be used. Spring as other
frameworks adopted it. The annotation form for the “bean” declaration in XML is
“@Component”. There are other alternatives such as the “@Services”,
”@WebComponent”, and others. They are used as markers for beans that play a
role in different layers of the application (Frontend layer, service layer,
database and so on).
The annotation to mark properties that need to be injected are the “@Inject”
and “@Autowired”. In your case, you are not using the “property” element in XML
because you applied the “@Inject” annotation in your class properties.
I do prefer to use either everything in XML or everything in annotation form.
Therefore, you can simply remove this line here, and annotate the class with
“@Component”. Bear in mind that for the annotation to work we need to enable
the annotation scan, but I think ACS is already doing that.
[ Full content available at: https://github.com/apache/cloudstack/pull/2500 ]
This message was relayed via gitbox.apache.org for [email protected]