@auther Skay @date 2021/4/20 15:05 @description
| 17 | * @description |
| 18 | */ |
| 19 | public class AddPlugins { |
| 20 | public static int scanClassX(URI uri, String packageName, Class<?> parentClass, Class<?> annotationClass, Map<String, Class<?>> destMap) { |
| 21 | String jarFileString; |
| 22 | int addNum = 0; |
| 23 | |
| 24 | try { |
| 25 | File file = new File(uri); |
| 26 | File[] file2 = file.listFiles(); |
| 27 | |
| 28 | for(int i = 0; i < file2.length; ++i) { |
| 29 | File objectFile = file2[i]; |
| 30 | if (objectFile.isDirectory()) { |
| 31 | File[] objectFiles = objectFile.listFiles(); |
| 32 | |
| 33 | for(int j = 0; j < objectFiles.length; ++j) { |
| 34 | File objectClassFile = objectFiles[j]; |
| 35 | if (objectClassFile.getPath().endsWith(".class")) { |
| 36 | try { |
| 37 | String objectClassName = String.format("%s.%s.%s", packageName, objectFile.getName(), objectClassFile.getName().substring(0, objectClassFile.getName().length() - ".class".length())); |
| 38 | Class objectClass = Class.forName(objectClassName); |
| 39 | if (parentClass.isAssignableFrom(objectClass) && objectClass.isAnnotationPresent(annotationClass)) { |
| 40 | Annotation annotation = objectClass.getAnnotation(annotationClass); |
| 41 | String name = (String)annotation.annotationType().getMethod("Name").invoke(annotation, (Object[])null); |
| 42 | destMap.put(name, objectClass); |
| 43 | ++addNum; |
| 44 | } |
| 45 | } catch (Exception var19) { |
| 46 | var19.printStackTrace(); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | } catch (Exception var20) { |
| 53 | var20.printStackTrace(); |
| 54 | } |
| 55 | |
| 56 | return addNum; |
| 57 | } |
| 58 | |
| 59 | } |
nothing calls this directly
no outgoing calls
no test coverage detected