Adds jar file URL.

@param jarFile
jar file path
199856
private void addJarFileUrl(String jarFile)
    {
        if (jarUrls == null)
        {
            jarUrls = new HashSet<URL>();
        }
        try
        {
            jarUrls.add(new File(jarFile).toURI().toURL());
        }
        catch (MalformedURLException e)
        {
            log.error("Error while mapping jar-file url" + jarFile + "caused by:" + e.getMessage());
            throw new IllegalArgumentException("Invalid jar-file URL:" + jarFile + "Caused by: " + e);
        }
    }
82011
public void addClassPath(String classpath)
  {
    char sep = CauchoUtil.getPathSeparatorChar();
    int head = 0;
    int tail = 0;
    while (head < classpath.length()) {
      tail = classpath.indexOf(sep, head);

      String segment = null;
      if (tail < 0) {
        segment = classpath.substring(head);
        head = classpath.length();
      }
      else {
        segment = classpath.substring(head, tail);
        head = tail + 1;
      }

      if (segment.equals(""))
        continue;
      else if (segment.endsWith(".jar") || segment.endsWith(".zip"))
        addMergePath(JarPath.create(VfsOld.lookup(segment)));
      else
        addMergePath(VfsOld.lookup(segment));
    }
  }
1084930
public void addFile(String path, File file) throws IOException {
    addFile(path, file, null);
  }
263310
public static final void loadAndRegister(File driverJarFile,
                                             String driverClassName)
            throws Exception {
        loadAndRegister(new URL("jar:" + driverJarFile.toURI() + "!/"),
                        driverClassName);
    }
552698
public static boolean isJarURL(URL url) {
        String protocol = url.getProtocol();
        return (URL_PROTOCOL_JAR.equals(protocol) || URL_PROTOCOL_ZIP.equals(protocol) ||
                URL_PROTOCOL_VFSZIP.equals(protocol) || URL_PROTOCOL_WSJAR.equals(protocol));
    }
267185
private void addClassByJar(ClassLoader classLoader, URL url, String packageName, String packageDirName) {
        // 从url中获取jar，然后从此jar包得到一个枚举类，然后进行迭代.
        JarFile jar;
        try {
            jar = ((JarURLConnection) url.openConnection()).getJarFile();
            Enumeration<JarEntry> entries = jar.entries();
            while (entries.hasMoreElements()) {
                // 获取jar里的一个实体 可以是目录 和一些jar包里的其他文件 如META-INF等文件
                JarEntry entry = entries.nextElement();
                String name = entry.getName();
                // 如果是以/开头的,则获取后面的字符串
                if (name.charAt(0) == '/') {
                    name = name.substring(1);
                }

                // 如果前半部分和定义的包名相同.
                if (name.startsWith(packageDirName)) {
                    int index = name.lastIndexOf('/');
                    // 如果以"/"结尾，则是一个包，获取包名并把"/"替换成"."
                    if (index != -1) {
                        packageName = name.substring(0, index).replace('/', '.');
                    }
                    // 如果可以迭代下去 并且是一个包,如果是一个.class文件 而且不是目录
                    if (index != -1 && name.endsWith(".class") && !entry.isDirectory()) {
                        // 去掉后面的".class" 获取真正的类名
                        String className = name.substring(packageName.length() + 1, name.length() - 6);
                        this.addClassByName(classLoader, packageName + '.' + className);
                    }
                }
            }
        } catch (IOException expected) {
            // 此处不打印堆栈信息.
            log.warn("从jar文件中读取class出错.");
        }
    }
759366
private void addFile(File root, File file, String prefix, ZipOutputStream zos) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        ZipEntry jarEntry = new ZipEntry(prefix + normalizePath(root, file));
        zos.putNextEntry(jarEntry);
        StreamUtils.copyStream(fis, zos, false);
        fis.close();
    }
837785
protected void addURL(final URL url) {
    final URL[] newUrls = new URL[this.urls.length + 1];
    System.arraycopy(url, 0, newUrls, 0, this.urls.length);
    newUrls[this.urls.length] = url;
    this.urls = newUrls;
  }
605394
protected URL getNearTemplateURL(String jarFile, String template) {
        if (jarFile != null) {
            Enumeration<URL> urls = IOUtils.getResources(template);
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                if (url.getPath().startsWith(jarFile)) {
                    return url;
                }
            }
        }
        return null;
    }
1206379
public static void addToClasspath(final File file, final ClassLoader classLoader) {
        checkNotNull("file", file);
        try {
            addToClasspath(file.toURI().toURL(), classLoader);
        } catch (final MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
12878
private FileNode moduleFile(URL url) {
        String module;
        int idx;

        module = url.getFile();
        module = Strings.removeLeft(module, "/");
        idx = module.indexOf("/");
        if (idx == -1) {
            throw new RuntimeException("unexpected jre url: " + url);
        }
        module = module.substring(0, idx);
        return file(System.getProperty("java.home")).join("jmods", module + ".jmod");
    }
20936
public void addNameUrl(final String name, final String url) 
	throws IOException {
		doPostMethod(ResourceFileLocationDBServlet.ADD_OPERATION, name, url);
	}
1300612
@Override
    public void addURL(URL url)
    {
        this.finder.addURI(URI.create(url.toExternalForm()));
    }
1217887
public static Path getJarPathFromUrl(URL jarUrl) {
        try {
            String pathString = jarUrl.getPath();
            // for Jar URL, the path is in the form of: file:/path/to/groovy/myJar.jar!/path/to/resource/myResource.txt
            int endIndex = pathString.lastIndexOf("!");
            return Paths.get(new URI(pathString.substring(0, endIndex)));
        } catch (URISyntaxException e) {
            throw new IllegalStateException("Unsupported URL syntax: " + jarUrl.getPath(), e);
        }
    }
928369
public void addJar(Path jar) {
		if (jar == null) {
			throw new IllegalArgumentException();
		}

		if (!userJars.contains(jar)) {
			userJars.add(jar);
		}
	}
223812
public void jarDir(File dirOrFile2Jar, File destJar)
		throws IOException {

		if (dirOrFile2Jar == null || destJar == null) {
			throw new IllegalArgumentException();
		}

		mDestJarName = destJar.getCanonicalPath();
		FileOutputStream fout = new FileOutputStream(destJar);
		JarOutputStream jout = new JarOutputStream(fout);
		//jout.setLevel(0);
		try {
			jarDir(dirOrFile2Jar, jout, null);
		} catch (IOException ioe) {
			throw ioe;
		} finally {
			jout.close();
			fout.close();
		}
	}
229884
public static JarClassLoader loadJar(File jarFile) {
		final JarClassLoader loader = new JarClassLoader();
		loader.addJar(jarFile);
		return loader;
	}