private Object getPrivateField(Object object, String field)
     throws SecurityException, NoSuchFieldException, IllegalArgumentException,
         IllegalAccessException {
   Class<?> clazz = object.getClass();
   Field objectField = clazz.getDeclaredField(field);
   objectField.setAccessible(true);
   Object result = objectField.get(object);
   objectField.setAccessible(false);
   return result;
 }
예제 #2
0
 public static void loadMaps(String packageName) {
   Reflections reflections = new Reflections(packageName);
   Set<Class<?>> classes = reflections.getTypesAnnotatedWith(MapConfig.class);
   for (Class<?> clazz : classes) {
     try {
       Object map = clazz.newInstance();
       maps.add((Map) map);
     } catch (Exception e) {
       logger.severe("Unable to load map: " + clazz.getName());
       e.printStackTrace();
     }
   }
 }