rafaelweingartner commented on a change in pull request #2500: Restrict the 
number of managed clustered file systems per compute cluster
URL: https://github.com/apache/cloudstack/pull/2500#discussion_r214510710
 
 

 ##########
 File path: 
engine/components-api/src/main/resources/META-INF/cloudstack/core/spring-engine-components-api-core-context.xml
 ##########
 @@ -25,6 +25,6 @@
                       http://www.springframework.org/schema/aop 
http://www.springframework.org/schema/aop/spring-aop.xsd
                       http://www.springframework.org/schema/context
                       
http://www.springframework.org/schema/context/spring-context.xsd";
-                      >                     
-
+                      >
+    <bean id="storageUtil" class="com.cloud.storage.StorageUtil" />
 
 Review comment:
   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.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to