Java Code Examples for com.google.common.reflect.ClassPath#ClassInfo

The following examples show how to use com.google.common.reflect.ClassPath#ClassInfo . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CommandClassUtil.java    From canon-sdk-java with MIT License 6 votes vote down vote up
private static Set<? extends Class<? extends CanonCommand>> getCommandClassesInternal() {
        try {
            final ImmutableSet<ClassPath.ClassInfo> allClasses = ClassPath.from(AbstractCanonCommand.class.getClassLoader()).getTopLevelClasses(COMMAND_PACKAGE);

            final Set<? extends Class<?>> classes = allClasses.asList().stream()
                .filter(info -> !info.getSimpleName().endsWith("Test"))
//                .filter(info -> info.getSimpleName().endsWith("Command")) do not put as not all commands end with that
                .map(ClassPath.ClassInfo::load)
                .filter(CanonCommand.class::isAssignableFrom)
                .filter(aClass -> !aClass.isInterface())
                .collect(ImmutableSet.toImmutableSet());
            return (Set<? extends Class<? extends CanonCommand>>) classes;
        } catch (IOException e) {
            throw new IllegalStateException("Failed to read command classes", e);
        }
    }
 
Example 2
Source File: CommandClassUtil.java    From canon-sdk-java with MIT License 6 votes vote down vote up
private static Set<? extends Class<? extends DecoratorCommand>> getDecoratorCommandClassesInternal() {
        try {
            final ImmutableSet<ClassPath.ClassInfo> allClasses = ClassPath.from(AbstractDecoratorCommand.class.getClassLoader()).getTopLevelClasses(DECORATOR_COMMAND_PACKAGE);

            final Set<? extends Class<?>> classes = allClasses.asList().stream()
                .filter(info -> !info.getSimpleName().endsWith("Test"))
//                .filter(info -> info.getSimpleName().endsWith("Command")) do not put as not all commands end with that
                .map(ClassPath.ClassInfo::load)
                .filter(DecoratorCommand.class::isAssignableFrom)
                .filter(aClass -> !aClass.isInterface())
                .collect(ImmutableSet.toImmutableSet());
            return (Set<? extends Class<? extends DecoratorCommand>>) classes;
        } catch (IOException e) {
            throw new IllegalStateException("Failed to read decorator command classes", e);
        }
    }
 
Example 3
Source File: SchemaGenerator.java    From core with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Utility method used to fetch Class list based on a package name.
 * 
 * @param packageName
 *            (should be the package containing your annotated beans.
 */
@SuppressWarnings("rawtypes")
private List<Class> getClasses(String packageName) throws Exception {
    
    logger.debug("Start: Classes in "+ packageName);
    List<Class> classes = new ArrayList<Class>();
    final ClassLoader loader = Thread.currentThread().getContextClassLoader();

       for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) 
       {
           if (info.getName().startsWith(packageName)) 
           {
               final Class<?> clazz = info.load();
               logger.debug(info.getName());
               classes.add(clazz);
           } 
       }
       logger.debug("End: Classes in "+ packageName);
   
       
	return classes;
}
 
Example 4
Source File: BBServer.java    From petscii-bbs with Mozilla Public License 2.0 6 votes vote down vote up
private static List<Class<? extends PetsciiThread>> filterPetsciiThread() {
    List<Class<? extends PetsciiThread>> result = new LinkedList<>();
    final ClassLoader classLoader = BBServer.class.getClassLoader();
    final Set<ClassPath.ClassInfo> classes;
    try {
        classes = ClassPath.from(classLoader).getTopLevelClasses();
    } catch (IOException ioe) {
        return emptyList();
    }
    for (ClassPath.ClassInfo classInfo : classes) {
        try {
            Class c = classInfo.load();
            if (PetsciiThread.class.isAssignableFrom(c) && !c.isAnnotationPresent(Hidden.class))
                result.add(c);
        } catch (LinkageError e) {
            // SKIP
        }
    }
    result.sort(comparing(Class::getSimpleName));
    return result;
}
 
Example 5
Source File: Yaml.java    From java with Apache License 2.0 6 votes vote down vote up
private static void initModelMap() throws IOException {
  initApiGroupMap();
  initApiVersionList();

  ClassPath cp = ClassPath.from(Yaml.class.getClassLoader());
  Set<ClassPath.ClassInfo> allClasses =
      cp.getTopLevelClasses("io.kubernetes.client.openapi.models");

  for (ClassPath.ClassInfo clazz : allClasses) {
    String modelName = "";
    Pair<String, String> nameParts = getApiGroup(clazz.getSimpleName());
    modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";

    nameParts = getApiVersion(nameParts.getRight());
    modelName += nameParts.getLeft() == null ? "" : nameParts.getLeft() + "/";
    modelName += nameParts.getRight();

    classes.put(modelName, clazz.load());
  }
}
 
Example 6
Source File: ModuleManager.java    From PIPE with MIT License 6 votes vote down vote up
/**
 * Finds all the fully qualified (ie: full package names) module classnames
 * by recursively searching the rootDirectories
 *
 * @return
 */
//only load attempt to add .class files
private Collection<Class<? extends GuiModule>> getModuleClasses() {
    Collection<Class<? extends GuiModule>> results = new ArrayList<>();
    try {
        ClassPath classPath = ClassPath.from(this.getClass().getClassLoader());
        ImmutableSet<ClassPath.ClassInfo> set = classPath.getTopLevelClasses(PIPE_GUI_PLUGIN_CONCRETE_PACKAGE);
        for (ClassPath.ClassInfo classInfo : set) {
            Class<?> clazz = classInfo.load();
            if (GuiModule.class.isAssignableFrom(clazz)) {
                results.add((Class<? extends GuiModule>) clazz);
            }
        }
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, e.getMessage());
    }
    return results;
}
 
Example 7
Source File: DocumentationGenerator.java    From cukes with Apache License 2.0 6 votes vote down vote up
private static Map<CukesComponent, Multimap<StepType, StepDefinition>> collectSteps() throws IOException, ClassNotFoundException {
    Map<CukesComponent, Multimap<StepType, StepDefinition>> steps = createStepsStubs();
    ClassPath classPath = ClassPath.from(DocumentationGenerator.class.getClassLoader());
    ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClassesRecursive("lv.ctco.cukes");
    for (ClassPath.ClassInfo classInfo : classes) {
        String className = classInfo.getName();
        Class<?> aClass = Class.forName(className);
        Method[] methods = aClass.getMethods();
        for (Method method : methods) {
            StepType type = StepType.getTypeForMethod(method);
            if (type != null) {
                CukesComponent component = CukesComponent.findByClassName(className);
                steps.get(component).put(type, new StepDefinition(type.getPattern(method), type.getDescription(method)));
            }
        }
    }
    return steps;
}
 
Example 8
Source File: GuavaCollectionBuildersTest.java    From auto with Apache License 2.0 6 votes vote down vote up
@Test
public void testImmutableBuilders() throws Exception {
  ClassPath classPath = ClassPath.from(getClass().getClassLoader());
  ImmutableSet<ClassPath.ClassInfo> classes = classPath.getAllClasses();
  int checked = 0;
  for (ClassPath.ClassInfo classInfo : classes) {
    if (classInfo.getPackageName().equals("com.google.common.collect")
        && classInfo.getSimpleName().startsWith("Immutable")
        && !NON_BUILDABLE_COLLECTIONS.contains(classInfo.getSimpleName())) {
      Class<?> c = Class.forName(classInfo.getName());
      if (Modifier.isPublic(c.getModifiers())) {
        checked++;
        checkImmutableClass(c);
      }
    }
  }
  expect.that(checked).isGreaterThan(10);
}
 
Example 9
Source File: CheckUtil.java    From sonar-checkstyle with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets all checkstyle's modules.
 * @return the set of checkstyle's module classes.
 * @throws IOException if the attempt to read class path resources failed.
 * @see #isCheckstyleModule(Class)
 */
public static Set<Class<?>> getCheckstyleModules() throws IOException {
    final Set<Class<?>> checkstyleModules = new HashSet<>();

    final ClassLoader loader = Thread.currentThread()
            .getContextClassLoader();
    final ClassPath classpath = ClassPath.from(loader);
    final String packageName = "com.puppycrawl.tools.checkstyle";
    final ImmutableSet<ClassPath.ClassInfo> checkstyleClasses = classpath
            .getTopLevelClassesRecursive(packageName);

    for (ClassPath.ClassInfo clazz : checkstyleClasses) {
        final Class<?> loadedClass = clazz.load();
        if (isCheckstyleModule(loadedClass)) {
            checkstyleModules.add(loadedClass);
        }
    }
    return checkstyleModules;
}
 
Example 10
Source File: ClassPathHelper.java    From Poseidon with Apache License 2.0 5 votes vote down vote up
public static Set<ClassPath.ClassInfo> getPackageClasses(ClassLoader classLoader, List<String> packagesToScan) throws IOException {
    ClassPath classpath = ClassPath.from(classLoader);
    Set<ClassPath.ClassInfo> classInfos = new HashSet<>();
    for (String basePackage : packagesToScan) {
        classInfos.addAll(classpath.getTopLevelClassesRecursive(basePackage));
    }
    return classInfos;
}
 
Example 11
Source File: MeterSystem.java    From skywalking with Apache License 2.0 5 votes vote down vote up
public MeterSystem(final ModuleManager manager) {
    this.manager = manager;
    classPool = ClassPool.getDefault();

    ClassPath classpath = null;
    try {
        classpath = ClassPath.from(MeterSystem.class.getClassLoader());
    } catch (IOException e) {
        throw new UnexpectedException("Load class path failure.");
    }
    ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
    for (ClassPath.ClassInfo classInfo : classes) {
        Class<?> functionClass = classInfo.load();

        if (functionClass.isAnnotationPresent(MeterFunction.class)) {
            MeterFunction metricsFunction = functionClass.getAnnotation(MeterFunction.class);
            if (!AcceptableValue.class.isAssignableFrom(functionClass)) {
                throw new IllegalArgumentException(
                    "Function " + functionClass.getCanonicalName() + " doesn't implement AcceptableValue.");
            }
            functionRegister.put(
                metricsFunction.functionName(),
                (Class<? extends MeterFunction>) functionClass
            );
        }
    }
}
 
Example 12
Source File: PluginLibraryHelper.java    From OpenFalcon-SuitAgent with Apache License 2.0 5 votes vote down vote up
/**
 * 注册插件
 */
public synchronized void register(){
    Set<ClassPath.ClassInfo> classInfos;
    try {
        classInfos = ClassPath.from(classLoader).getTopLevelClassesRecursive("com.yiji.falcon");
        for (ClassPath.ClassInfo classInfo : classInfos) {
            String clazzName = classInfo.getName();
            Class clazz = Class.forName(clazzName);
            if(Plugin.class.isAssignableFrom(clazz) &&
                    clazz != Plugin.class &&
                    clazz != JMXPlugin.class &&
                    clazz != JDBCPlugin.class &&
                    clazz != SNMPV3Plugin.class &&
                    clazz != DetectPlugin.class){
                final Plugin plugin = (Plugin) clazz.newInstance();
                //插件初始化操作
                Map<String,String> config = getPluginConfig(plugin);
                //初始化插件配置
                plugin.init(config);

                String avaStr = pluginAvailable(plugin);
                if(avaStr != null){
                    log.warn("插件 {} 无效 : {}",clazz.getName(),avaStr);
                    continue;
                }
                plugins.add(plugin);
                log.info("成功注册插件:{},启动方式:{}",clazzName,plugin.activateType().getDesc());
            }
        }
    } catch (Exception e) {
        log.error("插件注册异常",e);
    }
}
 
Example 13
Source File: MetricsHolder.java    From skywalking with Apache License 2.0 5 votes vote down vote up
public static void init() throws IOException {
    ClassPath classpath = ClassPath.from(MetricsHolder.class.getClassLoader());
    ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
    for (ClassPath.ClassInfo classInfo : classes) {
        Class<?> aClass = classInfo.load();

        if (aClass.isAnnotationPresent(MetricsFunction.class)) {
            MetricsFunction metricsFunction = aClass.getAnnotation(MetricsFunction.class);
            REGISTER.put(
                metricsFunction.functionName(),
                (Class<? extends Metrics>) aClass
            );
        }
    }
}
 
Example 14
Source File: CommandLine.java    From dockerfile-image-update with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Class<?> loadCommand(Set<ClassPath.ClassInfo> allClasses, String command) throws IOException {
    Class<?> runClass = null;
    for (ClassPath.ClassInfo classInfo : allClasses) {
        if (classInfo.getSimpleName().equalsIgnoreCase(command)) {
            runClass = classInfo.load();
        }
    }
    if (runClass == null) {
        throw new IOException("FATAL: Could not execute command.");
    }
    return runClass;
}
 
Example 15
Source File: DispatcherManager.java    From skywalking with Apache License 2.0 5 votes vote down vote up
/**
 * Scan all classes under `org.apache.skywalking` package,
 * <p>
 * If it implement {@link org.apache.skywalking.oap.server.core.analysis.SourceDispatcher}, then, it will be added
 * into this DispatcherManager based on the Source definition.
 */
public void scan() throws IOException, IllegalAccessException, InstantiationException {
    ClassPath classpath = ClassPath.from(this.getClass().getClassLoader());
    ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
    for (ClassPath.ClassInfo classInfo : classes) {
        Class<?> aClass = classInfo.load();

        addIfAsSourceDispatcher(aClass);
    }
}
 
Example 16
Source File: PluginLibraryHelper.java    From SuitAgent with Apache License 2.0 5 votes vote down vote up
/**
 * 注册插件
 */
public synchronized void register(){
    Set<ClassPath.ClassInfo> classInfos;
    try {
        classInfos = ClassPath.from(classLoader).getTopLevelClassesRecursive("com.falcon.suitagent");
        for (ClassPath.ClassInfo classInfo : classInfos) {
            String clazzName = classInfo.getName();
            Class clazz = Class.forName(clazzName);
            if(Plugin.class.isAssignableFrom(clazz) &&
                    clazz != Plugin.class &&
                    clazz != JMXPlugin.class &&
                    clazz != JDBCPlugin.class &&
                    clazz != SNMPV3Plugin.class &&
                    clazz != DetectPlugin.class){
                final Plugin plugin = (Plugin) clazz.newInstance();
                //插件初始化操作
                Map<String,String> config = getPluginConfig(plugin);
                //初始化插件配置
                plugin.init(config);

                String avaStr = pluginAvailable(plugin);
                if(avaStr != null){
                    log.warn("插件 {} 无效 : {}",clazz.getName(),avaStr);
                    continue;
                }
                plugins.add(plugin);
                log.info("成功注册插件:{},启动方式:{}",clazzName,plugin.activateType().getDesc());
            }
        }
    } catch (Exception e) {
        log.error("插件注册异常",e);
    }
}
 
Example 17
Source File: ClassResourceEnumerator.java    From gadgetinspector with MIT License 5 votes vote down vote up
private Collection<ClassResource> getRuntimeClasses() throws IOException {
    // A hacky way to get the current JRE's rt.jar. Depending on the class loader, rt.jar may be in the
    // bootstrap classloader so all the JDK classes will be excluded from classpath scanning with this!
    // However, this only works up to Java 8, since after that Java uses some crazy module magic.
    URL stringClassUrl = Object.class.getResource("String.class");
    URLConnection connection = stringClassUrl.openConnection();
    Collection<ClassResource> result = new ArrayList<>();
    if (connection instanceof JarURLConnection) {
        URL runtimeUrl = ((JarURLConnection) connection).getJarFileURL();
        URLClassLoader classLoader = new URLClassLoader(new URL[]{runtimeUrl});

        for (ClassPath.ClassInfo classInfo : ClassPath.from(classLoader).getAllClasses()) {
            result.add(new ClassLoaderClassResource(classLoader, classInfo.getResourceName()));
        }
        return result;
    }

    // Try finding all the JDK classes using the Java9+ modules method:
    try {
        FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
        Files.walk(fs.getPath("/")).forEach(p -> {
            if (p.toString().toLowerCase().endsWith(".class")) {
                result.add(new PathClassResource(p));
            }
        });
    } catch (ProviderNotFoundException e) {
        // Do nothing; this is expected on versions below Java9
    }

    return result;
}
 
Example 18
Source File: ClassResourceEnumerator.java    From gadgetinspector with MIT License 5 votes vote down vote up
public Collection<ClassResource> getAllClasses() throws IOException {
    Collection<ClassResource> result = new ArrayList<>(getRuntimeClasses());
    for (ClassPath.ClassInfo classInfo : ClassPath.from(classLoader).getAllClasses()) {
        result.add(new ClassLoaderClassResource(classLoader, classInfo.getResourceName()));
    }
    return result;
}
 
Example 19
Source File: EchoPetPlugin.java    From SonarPet with GNU General Public License v3.0 4 votes vote down vote up
@Override
@SneakyThrows(IOException.class)
public void onEnable() {
    EchoPet.setPlugin(this);
    isUsingNetty = CommonReflection.isUsingNetty();

    this.configManager = new YAMLConfigManager(this);
    COMMAND_MANAGER = new CommandManager(this);
    // Make sure that the plugin is running under the correct version to prevent errors

    if (NmsVersion.current() == null || !INMS.isSupported()) {
        EchoPet.LOG.log(ChatColor.RED + "SonarPet " + ChatColor.GOLD
                + this.getDescription().getVersion() + ChatColor.RED
                + " is not compatible with this version of CraftBukkit");
        EchoPet.LOG.log(ChatColor.RED + "Initialisation failed. Please update the plugin.");

        DynamicPluginCommand cmd = new DynamicPluginCommand(this.cmdString, new String[0], "", "",
                new VersionIncompatibleCommand(this, this.cmdString, ChatColor.YELLOW +
                        "SonarPet " + ChatColor.GOLD + this.getDescription().getVersion() + ChatColor.YELLOW + " is not compatible with this version of CraftBukkit. Please update the plugin.",
                        "echopet.pet", ChatColor.YELLOW + "You are not allowed to do that."),
                null, this);
        COMMAND_MANAGER.register(cmd);
        return;
    }
    EntityRegistry entityRegistry;
    if (CitizensEntityRegistryHack.isNeeded()) {
        getLogger().warning("Attempting to inject citizens compatibility hack....");
        entityRegistry = CitizensEntityRegistryHack.createInstance();
        getLogger().warning("Successfully injected citizens compatibility hack!");
    } else {
        //noinspection deprecation // We check for citizens first ;)
        entityRegistry = INMS.getInstance().createDefaultEntityRegistry();
    }
    this.entityRegistry = Objects.requireNonNull(entityRegistry);

    this.loadConfiguration();

    PluginManager manager = getServer().getPluginManager();

    MANAGER = new PetManager();
    SQL_MANAGER = new SqlPetManager();

    if (OPTIONS.useSql()) {
        this.prepareSqlDatabase();
    }

    // Register custom commands
    // Command string based off the string defined in config.yml
    // By default, set to 'pet'
    // PetAdmin command draws from the original, with 'admin' on the end
    this.cmdString = OPTIONS.getCommandString();
    this.adminCmdString = OPTIONS.getCommandString() + "admin";
    DynamicPluginCommand petCmd = new DynamicPluginCommand(this.cmdString, new String[0], "Create and manage your own custom pets.", "Use /" + this.cmdString + " help to see the command list.", new PetCommand(this.cmdString), null, this);
    petCmd.setTabCompleter(new CommandComplete());
    COMMAND_MANAGER.register(petCmd);
    COMMAND_MANAGER.register(new DynamicPluginCommand(this.adminCmdString, new String[0], "Create and manage the pets of other players.", "Use /" + this.adminCmdString + " help to see the command list.", new PetAdminCommand(this.adminCmdString), null, this));

    // Initialize hook classes
    for (ClassPath.ClassInfo hookType : ClassPath.from(getClass().getClassLoader()).getTopLevelClasses("net.techcable.sonarpet.nms.entity.type")) {
        if (!hookType.load().isAnnotationPresent(EntityHook.class)) continue;
        for (EntityHookType type : hookType.load().getAnnotation(EntityHook.class).value()) {
            if (!type.isActive()) continue;
            hookRegistry.registerHookClass(type, hookType.load().asSubclass(IEntityPet.class));
        }
    }

    // Register listeners
    manager.registerEvents(new MenuListener(), this);
    manager.registerEvents(new PetEntityListener(this), this);
    manager.registerEvents(new PetOwnerListener(), this);
    if (VersionNotificationListener.isNeeded()) {
        manager.registerEvents(new VersionNotificationListener(), this);
        PluginVersioning.INSTANCE.sendOutdatedVersionNotification(Bukkit.getConsoleSender());
    }
    //manager.registerEvents(new ChunkListener(), this);

    this.vanishProvider = new VanishProvider(this);
    this.worldGuardProvider = new WorldGuardProvider(this);
}
 
Example 20
Source File: InterfaceToImpl.java    From raml-module-builder with Apache License 2.0 4 votes vote down vote up
/**
 * Return the implementing class.
 *
 * @param implDir
 *          - package name where to search
 * @param interface2check
 *          - class name of the required interface
 * @return implementing class/es
 * @throws IOException
 *           - if the attempt to read class path resources (jar files or directories) failed.
 * @throws ClassNotFoundException
 *           - if no class in implDir implements the interface
 */
public static ArrayList<Class<?>> convert2Impl(String implDir, String interface2check, boolean allowMultiple) throws IOException, ClassNotFoundException {
  ArrayList<Class<?>> impl = new ArrayList<>();
  ArrayList<Class<?>> cachedClazz = clazzCache.get(implDir, interface2check);
  if(cachedClazz != null){
    log.debug("returned " +cachedClazz.size()+" class/es from cache");
    return cachedClazz;
  }
  ClassPath classPath = ClassPath.from(Thread.currentThread().getContextClassLoader());
  ImmutableSet<ClassPath.ClassInfo> classes = classPath.getTopLevelClasses(implDir);
  Class<?> userImpl = null;
  /** iterate over all classes in the org.folio.rest.impl package to find the one implementing the
   * requested interface */
  for (ClassPath.ClassInfo info : classes) {
    if(userImpl != null && impl.size() == 1){
      /** we found a user impl that matches the interface2check, we are done, since we can only have one of these */
      break;
    }
    try {
      Class<?> clazz = Class.forName(info.getName());
      if(!clazz.getSuperclass().getName().equals("java.lang.Object") && clazz.getSuperclass().getInterfaces().length > 0){ //NOSONAR
        /** user defined class which overrides one of the out of the box RMB implementations
         * set the clazz to the interface. find the correct implementation below */
        userImpl = clazz;
        clazz = clazz.getSuperclass();
      }
      /** loop over all interfaces the class implements */
      for (Class<?> anInterface : clazz.getInterfaces()) {
        if (!anInterface.getName().equals(interface2check)) { //NOSONAR
          /**if userImpl != null here then a user impl exists but does not match the requested interface, so set to null*/
          userImpl = null;
          /** class doesnt implement the requested package, continue to check if it implements other packages */
          continue;
        }
        if(userImpl != null){
          /** we are here if we found a user impl (extends) of an RMB existing interface implementation
           *  load the user implementation and remove previous impl if it was added in previous loop iterations
           * there can only be one impl of an override, but we dont know the order we will get from the classloader
           * will the default RMB impl be passed in here or the user implementation - so once we hit a class whose
           * super class extends a generated interface - clear out the previous impl if any from the array and add
           * the user's impl - once found we are done */
          impl.clear();
          impl.add(userImpl);
          break;
        }
        else if (!allowMultiple && impl.size() > 0) {
          throw new RuntimeException("Duplicate implementation of " + interface2check + " in " + implDir + ": " + impl.get(0).getName() + ", "
              + clazz.getName());
        }
        else{
          /** return the class found that implements the requested package */
          impl.add(clazz);
        }
      }
    } catch (ClassNotFoundException e) {
      log.error(e.getMessage(), e);
    }
  }
  if (impl.isEmpty()) {
    throw new ClassNotFoundException("Implementation of " + interface2check + " not found in " + implDir);
  }
  clazzCache.put(implDir, interface2check, impl);
  return impl;
}