Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
<cs.lang.version>2.6</cs.lang.version>
<cs.commons-io.version>2.4</cs.commons-io.version>
<cs.commons-validator.version>1.4.0</cs.commons-validator.version>
<cs.reflections.version>0.9.8</cs.reflections.version>
<cs.reflections.version>0.9.9</cs.reflections.version>
<cs.java-ipv6.version>0.15</cs.java-ipv6.version>
<cs.replace.properties>build/replace.properties</cs.replace.properties>
<cs.libvirt-java.version>0.5.1</cs.libvirt-java.version>
Expand Down
5 changes: 4 additions & 1 deletion server/src/com/cloud/api/doc/ApiXmlDocWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,15 @@ private static List<String> setAsyncResponses() {
}

public static void main(String[] args) {

Set<Class<?>> cmdClasses = ReflectUtil.getClassesWithAnnotation(APICommand.class, new String[] {"org.apache.cloudstack.api", "com.cloud.api",
"com.cloud.api.commands", "com.globo.globodns.cloudstack.api", "org.apache.cloudstack.network.opendaylight.api",
"com.cloud.api.commands.netapp", "org.apache.cloudstack.api.command.admin.zone", "org.apache.cloudstack.network.contrail.api.command"});

for (Class<?> cmdClass : cmdClasses) {
if(cmdClass.getAnnotation(APICommand.class)==null){
System.out.println("Warning, API Cmd class " + cmdClass.getName() + " has no APICommand annotation ");
continue;
}
String apiName = cmdClass.getAnnotation(APICommand.class).name();
if (s_apiNameCmdClassMap.containsKey(apiName)) {
// handle API cmd separation into admin cmd and user cmd with the common api name
Expand Down
12 changes: 10 additions & 2 deletions utils/src/com/cloud/utils/ReflectUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

import org.apache.log4j.Logger;
import org.reflections.Reflections;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.ClasspathHelper;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.TypeAnnotationsScanner;

import com.google.common.collect.ImmutableSet;

Expand All @@ -45,6 +49,7 @@
public class ReflectUtil {

private static final Logger s_logger = Logger.getLogger(ReflectUtil.class);
private static final Logger logger = Logger.getLogger(Reflections.class);

public static Pair<Class<?>, Field> getAnyField(Class<?> clazz, String fieldName) {
try {
Expand All @@ -65,10 +70,13 @@ public static Pair<Class<?>, Field> getAnyField(Class<?> clazz, String fieldName
public static Set<Class<?>> getClassesWithAnnotation(Class<? extends Annotation> annotation, String[] packageNames) {
Reflections reflections;
Set<Class<?>> classes = new HashSet<Class<?>>();
ConfigurationBuilder builder=new ConfigurationBuilder();
for (String packageName : packageNames) {
reflections = new Reflections(packageName);
classes.addAll(reflections.getTypesAnnotatedWith(annotation));
builder.addUrls(ClasspathHelper.forPackage(packageName));
}
builder.setScanners(new SubTypesScanner(),new TypeAnnotationsScanner());
reflections = new Reflections(builder);
classes.addAll(reflections.getTypesAnnotatedWith(annotation));
return classes;
}

Expand Down