@Override public void addJarToPath(final URL jar) throws Exception { this._addJarToPath(jar); rebuild(); }
private boolean useServerClassLoader(final URL jar) { try { final URL url = findResource("META-INF/org.apache.openejb.tomcat/ServerClassLoader", jar); return url != null; } catch (final Exception e) { return false; } }
public TomcatClassPath(ClassLoader classLoader) { this.commonLoader = classLoader; try { addRepositoryMethod = getAddRepositoryMethod(); } catch (Exception tomcat4Exception) { try { addURLMethod = getAddURLMethod(); } catch (Exception tomcat5Exception) { throw new RuntimeException("Failed accessing classloader for Tomcat 5 or 6", tomcat5Exception); } } ClassLoader serverLoader = getServerLoader(getContextClassLoader()); if (serverLoader != null && serverLoader != commonLoader){ this.serverLoader = serverLoader; } else this.serverLoader = null; }
public TomcatClassPath(final ClassLoader classLoader) { this.commonLoader = classLoader; final ClassLoader serverLoader = getServerLoader(getContextClassLoader()); if (serverLoader != null && serverLoader != commonLoader) { this.serverLoader = serverLoader; } else { this.serverLoader = null; } }
public TomcatClassPath() { this(getCommonLoader(getContextClassLoader())); }
protected void rebuild() { try { final Object cp = getURLClassPath((URLClassLoader) getClassLoader()); final Method getURLsMethod = getGetURLsMethod();
@Override public void addJarsToPath(final File dir) throws Exception { final String[] jarNames = dir.list(new java.io.FilenameFilter() { @Override public boolean accept(final File dir, final String name) { return (name.endsWith(".jar") || name.endsWith(".zip")); } }); if (jarNames == null) { return; } for (final String jarName : jarNames) { this.addJarToPath(new File(dir, jarName).toURI().toURL()); } rebuild(); }
@Override public Method run() { try { final Object cp = getURLClassPath((URLClassLoader) getClassLoader()); final Class<?> clazz = cp.getClass(); return clazz.getDeclaredMethod("getURLs", URL.class); } catch (final Exception e) { throw new LoaderRuntimeException(e); } }
public void _addJarToPath(final URL jar) throws Exception { ClassLoader classLoader = commonLoader; if (serverLoader != null && useServerClassLoader(jar)) { classLoader = serverLoader; } getAddRepositoryMethod().invoke(classLoader, jar); }
protected void rebuild() { try { sun.misc.URLClassPath cp = getURLClassPath((URLClassLoader) getCommonLoader()); URL[] urls = cp.getURLs(); if (urls.length < 1) return; StringBuffer path = new StringBuffer(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile())); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile())); path.append(s.getPath()); } System.setProperty("java.class.path", path.toString()); } catch (Exception e) { } }
@SuppressWarnings("checkstyle:needbraces") public static ClassPath createClassPath(final String name) { if (name.equalsIgnoreCase("tomcat")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-common")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-system")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-webapp")) return new WebAppClassPath(); if (name.equalsIgnoreCase("bootstrap")) return new SystemClassPath(); if (name.equalsIgnoreCase("system")) return new SystemClassPath(); if (name.equalsIgnoreCase("thread")) return new ContextClassPath(); if (name.equalsIgnoreCase("context")) return new ContextClassPath(); return new ContextClassPath(); } }
public Method run() { Method method; try { Class clazz = getClassLoader().getClass(); method = clazz.getDeclaredMethod("addRepository", String.class); method.setAccessible(true); return method; } catch (Exception e2) { throw (IllegalStateException) new IllegalStateException("Unable to find or access the addRepository method in StandardClassLoader").initCause(e2); } } });
protected void rebuild() { try { final Object cp = getURLClassPath((URLClassLoader) getClassLoader()); final Method getURLsMethod = getGetURLsMethod();
public TomcatClassPath() { this(getCommonLoader(getContextClassLoader())); }
public void addJarsToPath(File dir) throws Exception { String[] jarNames = dir.list(new java.io.FilenameFilter() { public boolean accept(File dir, String name) { return (name.endsWith(".jar") || name.endsWith(".zip")); } }); if (jarNames == null) { return; } for (String jarName : jarNames) { this.addJarToPath(new File(dir, jarName).toURI().toURL()); } rebuild(); }
@Override public Method run() { try { final Object cp = getURLClassPath((URLClassLoader) getClassLoader()); final Class<?> clazz = cp.getClass(); return clazz.getDeclaredMethod("addURL", URL.class); } catch (final Exception e) { throw new LoaderRuntimeException(e); } }
@SuppressWarnings("checkstyle:needbraces") public static ClassPath createClassPath(final String name) { if (name.equalsIgnoreCase("tomcat")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-common")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-system")) return new TomcatClassPath(); if (name.equalsIgnoreCase("tomcat-webapp")) return new WebAppClassPath(); if (name.equalsIgnoreCase("bootstrap") && isSystemSupported()) return new SystemClassPath(); if (name.equalsIgnoreCase("system") && isSystemSupported()) return new SystemClassPath(); if (name.equalsIgnoreCase("thread")) return new ContextClassPath(); if (name.equalsIgnoreCase("context")) return new ContextClassPath(); return new ContextClassPath(); }
@Override public Method run() { final Method method; try { final Class clazz = getClassLoader().getClass(); method = clazz.getDeclaredMethod("addRepository", String.class); method.setAccessible(true); return method; } catch (final Exception e2) { throw (IllegalStateException) new IllegalStateException("Unable to find or access the addRepository method in StandardClassLoader").initCause(e2); } } });
public TomcatClassPath(final ClassLoader classLoader) { this.commonLoader = classLoader; try { addRepositoryMethod = getAddRepositoryMethod(); } catch (final Exception tomcat4Exception) { try { addURLMethod = getAddURLMethod(); } catch (final Exception tomcat5Exception) { throw new LoaderRuntimeException("Failed accessing classloader for Tomcat 5 or 6", tomcat5Exception); } } final ClassLoader serverLoader = getServerLoader(getContextClassLoader()); if (serverLoader != null && serverLoader != commonLoader) { this.serverLoader = serverLoader; } else { this.serverLoader = null; } }
@Override public void addJarToPath(final URL jar) throws Exception { this._addJarToPath(jar); rebuild(); }