Skip to content

Commit d760271

Browse files
committed
ApiDispatcher: Get rid of reflections, reuse utils' ReflectUtil
Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
1 parent 539d94b commit d760271

2 files changed

Lines changed: 3 additions & 18 deletions

File tree

‎server/pom.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@
8080
<classifier>tests</classifier>
8181
<scope>test</scope>
8282
</dependency>
83-
<dependency>
84-
<groupId>org.reflections</groupId>
85-
<artifactId>reflections</artifactId>
86-
<version>0.9.8</version>
87-
</dependency>
8883
</dependencies>
8984
<build>
9085
<defaultGoal>install</defaultGoal>

‎server/src/com/cloud/api/ApiDispatcher.java‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.util.regex.Matcher;
3232

3333
import com.cloud.dao.EntityManager;
34+
import com.cloud.utils.ReflectUtil;
3435
import org.apache.cloudstack.acl.ControlledEntity;
3536
import org.apache.cloudstack.acl.InfrastructureEntity;
3637
import org.apache.cloudstack.acl.Role;
@@ -374,19 +375,8 @@ public static void processParameters(BaseCmd cmd, Map<String, String> params) {
374375
}
375376
}
376377

377-
// Process all the fields of the cmd object using reflection to recursively process super class
378-
Field[] fields = cmd.getClass().getDeclaredFields();
379-
Class<?> superClass = cmd.getClass().getSuperclass();
380-
while (BaseCmd.class.isAssignableFrom(superClass)) {
381-
Field[] superClassFields = superClass.getDeclaredFields();
382-
if (superClassFields != null) {
383-
Field[] tmpFields = new Field[fields.length + superClassFields.length];
384-
System.arraycopy(fields, 0, tmpFields, 0, fields.length);
385-
System.arraycopy(superClassFields, 0, tmpFields, fields.length, superClassFields.length);
386-
fields = tmpFields;
387-
}
388-
superClass = superClass.getSuperclass();
389-
}
378+
Field[] fields = ReflectUtil.getAllFieldsForClass(cmd.getClass(),
379+
new Class<?>[] {BaseCmd.class});
390380

391381
for (Field field : fields) {
392382
PlugService plugServiceAnnotation = field.getAnnotation(PlugService.class);

0 commit comments

Comments
 (0)