List of usage examples for java.net URLClassLoader URLClassLoader
public URLClassLoader(URL[] urls)
From source file:it.scoppelletti.programmerpower.security.DefaultRoleManager.java
/** * Inizializzazione./* www.j a v a2 s . c om*/ */ public void afterPropertiesSet() throws Exception { File dir; URL[] urls = new URL[1]; dir = SharedDataDirectory.getInstance().initResourceDirectory(DefaultRoleManager.class); urls[0] = dir.toURI().toURL(); myLoader = new URLClassLoader(urls); }
From source file:org.gradle.groovy.scripts.DefaultScriptProcessorTest.java
@Before public void setUp() { context.setImposteriser(ClassImposteriser.INSTANCE); scriptCompilationHandlerMock = context.mock(ScriptCompilationHandler.class); testClassLoader = new URLClassLoader(new URL[0]); testScriptFileDir = HelperUtil.makeNewTestDir("projectdir"); testScriptFile = new File(testScriptFileDir, TEST_BUILD_FILE_NAME); testCacheDir = new File(new File(testScriptFileDir, Project.CACHE_DIR_NAME), TEST_BUILD_FILE_NAME); expectedScript = context.mock(ScriptWithSource.class); scriptProcessor = new DefaultScriptProcessor(scriptCompilationHandlerMock, CacheUsage.ON); source = context.mock(ScriptSource.class); context.checking(new Expectations() { {/*w w w. j ava 2 s.c o m*/ allowing(source).getDescription(); will(returnValue("[script source]")); allowing(expectedScript).setSource(source); } }); }
From source file:org.omegat.gui.scripting.ScriptItem.java
public ScriptItem(File scriptFile) { m_file = scriptFile;//from ww w . j a va 2 s. c om if (m_file == null) { return; } try { ClassLoader loader = new URLClassLoader(new URL[] { scriptFile.getParentFile().toURI().toURL() }); String shortName = FilenameUtils.removeExtension(scriptFile.getName()); try { // Try first at the root of the script dir, for compatibility m_res = ResourceBundle.getBundle(shortName, Locale.getDefault(), loader); } catch (MissingResourceException e) { try { // Then inside the /properties dir m_res = ResourceBundle.getBundle(PROPERTIES + shortName, Locale.getDefault(), loader); } catch (MissingResourceException ex) { scanFileForDescription(scriptFile); } } } catch (MalformedURLException e) { /* ignore */ } }
From source file:com.olacabs.fabric.compute.builder.impl.JarScanner.java
private ClassLoader createClassLoader(URL[] urls) { URLClassLoader l = new URLClassLoader(urls); return l; }
From source file:org.onecmdb.web.remote.ClassPathController.java
public void setAdditionURLS(List<String> urlStrings) throws MalformedURLException { List<URL> urls = new ArrayList<URL>(); for (String urlString : urlStrings) { urls.add(new URL(urlString)); getLog().info("Adding additional url <" + urlString + ">"); }//from www.j a va2s . co m this.additionalLoader = new URLClassLoader(urls.toArray(new URL[0])); }
From source file:org.apache.tajo.engine.function.hiveudf.HiveFunctionLoader.java
private static <T> Set<Class<? extends T>> getSubclassesFromJarEntry(URL[] urls, Class<T> targetCls) { Reflections refl = new Reflections( new ConfigurationBuilder().setUrls(urls).addClassLoader(new URLClassLoader(urls))); return refl.getSubTypesOf(targetCls); }
From source file:org.appcelerator.locator.ServiceDirectoryScanner.java
public void start() { if (this.running) { throw new IllegalStateException("already running"); }/*from w ww .jav a 2 s.c o m*/ ClassPool cp = ClassPool.getDefault(); URL serviceDirUrl = null; try { serviceDirUrl = serviceDirectory.toURI().toURL(); } catch (Exception e) { throw new IllegalStateException("cannot convert service dir to url"); } this.loaderCL = new URLClassLoader(new URL[] { serviceDirUrl }); LoaderClassPath lcp = new LoaderClassPath(loaderCL); cp.insertClassPath(lcp); this.running = true; this.scannerThread = new Thread(this, "ServiceDirectoryScanner"); this.scannerThread.start(); LOG.info("Service scanner is running every " + (scanInterval / 1000) + " seconds"); }
From source file:com.hpl.mds.annotations.processors.JCompiler.java
private JCompiler() { try {/*from w w w . j a va 2 s . co m*/ Path outputPath = Paths.get(OUTPUT_DIR); File outputDirFile = outputPath.toFile(); if (outputDirFile.exists()) { FileUtils.cleanDirectory(outputDirFile); } URL url = outputDirFile.toURI().toURL(); CLASS_LOADER = new URLClassLoader(new URL[] { url }); } catch (IOException e) { e.printStackTrace(); } }
From source file:ch.ivyteam.ivy.maven.engine.EngineClassLoaderFactory.java
public URLClassLoader createEngineClassLoader(File engineDirectory) throws IOException { List<File> osgiClasspath = getOsgiBootstrapClasspath(engineDirectory); addToClassPath(osgiClasspath, new File(engineDirectory, "plugins"), new WildcardFileFilter("org.eclipse.osgi_*.jar")); osgiClasspath.add(0, maven.getJar("org.slf4j", "slf4j-api", SLF4J_VERSION)); osgiClasspath.add(0, maven.getJar("org.slf4j", "slf4j-simple", SLF4J_VERSION)); osgiClasspath.add(0, maven.getJar("org.slf4j", "log4j-over-slf4j", SLF4J_VERSION)); return new URLClassLoader(toUrls(osgiClasspath)); }
From source file:org.meerkat.util.sql.SQLDriverLoader.java
/** * loadDriver//from w w w . j a v a 2 s . co m * @param jarDir * @param dbDescription * @param driverClass */ public final void loadDriver(String jarDir, String dbDescription, String driverClass) { // Get the jar name inside the dir String odir = jarDir; File ora_dir = new File(odir); String[] ext = new String[] { "jar" }; List<File> files = (List<File>) FileUtils.listFiles(ora_dir, ext, true); if (files.size() == 0) { log.debug(dbDescription + " JDBC driver jar not available."); } else { try { File fdriver = files.get(0); URL u = new URL("jar:file:" + odir + fdriver.getName() + "!/"); String classname = driverClass; URLClassLoader ucl = new URLClassLoader(new URL[] { u }); Driver d = (Driver) Class.forName(classname, true, ucl).newInstance(); DriverManager.registerDriver(new SQLDriverJar(d)); } catch (Exception e) { log.error(dbDescription + " JDBC driver jar not available."); } } }