jiveclassloader.java
来自「开源项目openfire的完整源程序」· Java 代码 · 共 66 行
JAVA
66 行
/** * $Revision$ * $Date$ * * Copyright (C) 1999-2005 Jive Software. All rights reserved. * This software is the proprietary information of Jive Software. Use is subject to license terms. */package org.jivesoftware.launcher;import java.io.File;import java.io.FilenameFilter;import java.net.MalformedURLException;import java.net.URL;import java.net.URLClassLoader;/** * A simple classloader to extend the classpath to * include all jars in a lib directory.<p> * <p/> * The new classpath includes all <tt>*.jar</tt> and <tt>*.zip</tt> * archives (zip is commonly used in packaging JDBC drivers). The extended * classpath is used for both the initial startup, as well as loading * plug-in support jars. * * @author Derek DeMoro */class JiveClassLoader extends URLClassLoader { /** * Constructs the classloader. * * @param parent the parent class loader (or null for none). * @param libDir the directory to load jar files from. * @throws java.net.MalformedURLException if the libDir path is not valid. */ JiveClassLoader(ClassLoader parent, File libDir) throws MalformedURLException { super(new URL[]{libDir.toURL()}, parent); File[] jars = libDir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { boolean accept = false; String smallName = name.toLowerCase(); if (smallName.endsWith(".jar")) { accept = true; } else if (smallName.endsWith(".zip")) { accept = true; } return accept; } }); // Do nothing if no jar or zip files were found if (jars == null) { return; } for (int i = 0; i < jars.length; i++) { if (jars[i].isFile()) { addURL(jars[i].toURL()); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?