class PluginLoader implements IPluginLoader<Collection<IPath>> {

    @Override
    public void loadPlugin(final Collection<IPath> files)
            throws PluginLoaderException {
        try {
            for (IPath file : files) {
                URL url = new URL("jar:file:" + file.getPath() + "!/");
                this.classLoader.addUrl(url);
            }
        } catch (Throwable e) {
            throw new PluginLoaderException("Malformed file name.", e);
        }

        JarFile jarFile = null;
        String pathToJar = null;
        for (IPath file : files) {
            try {
                pathToJar = file.getPath();
                jarFile = new JarFile(pathToJar);
                Enumeration<JarEntry> iterator = jarFile.entries();
                while (iterator.hasMoreElements()) {
                    JarEntry je = iterator.nextElement();
                    if (je.isDirectory() || !je.getName().endsWith(CLASS_EXTENSION)) {
                        continue;
                    }
                    String className = je.getName().substring(0, je.getName().length() - CLASS_EXTENSION.length());
                    className = className.replace('/', '.');
                    Class clazz;
                    try {
                        clazz = classLoader.loadClass(className);
                    } catch (Throwable e) {
                        // ignoring, because the plugin which class cannot be loaded cannot be loaded
                        continue;
                    }

                    if (IPlugin.class.isAssignableFrom(clazz) && clazz != IPlugin.class) {
                        creator.execute(clazz);
                    }
                }
            } catch (Throwable e) {
                visitor.pluginLoadingFail(pathToJar, e);
                throw new PluginLoaderException("Plugin loading failed: " + pathToJar, e);
            } finally {
                if (null != jarFile) {
                    try {
                        jarFile.close();
                    } catch (IOException e) {
                        //TODO: replace throw by other logic
                        throw new PluginLoaderException("Error on close instance of JarFile .", e);
                    }
                }
            }
        }
    }

    public  PluginLoader(final ClassLoader classLoader, final IAction<Class> action, final IPluginLoaderVisitor<String> visitor);

}