@Override public void setDefaultUseCaches(boolean defaultusecaches) { jarFileURLConnection.setDefaultUseCaches(defaultusecaches); }
/** * Creates the instance for the OpenmrsClassLoader */ public OpenmrsClassLoader(ClassLoader parent) { super(new URL[0], parent); if (parent instanceof OpenmrsClassLoader) { throw new IllegalArgumentException("Parent must not be OpenmrsClassLoader nor null"); } else if (parent instanceof ModuleClassLoader) { throw new IllegalArgumentException("Parent must not be ModuleClassLoader"); } OpenmrsClassLoaderHolder.INSTANCE = this; if (log.isDebugEnabled()) { log.debug("Creating new OpenmrsClassLoader instance with parent: {}", parent); } //disable caching so the jars aren't locked //if performance is effected, this can be disabled in favor of //copying all opened jars to a temp location //(ala org.apache.catalina.loader.WebappClassLoader antijarlocking) URLConnection urlConnection = new OpenmrsURLConnection(); urlConnection.setDefaultUseCaches(false); }
/** * Downloads the contents of a URL and copies them to a string (Borrowed from oreilly) * * @param url * @return InputStream of contents * @should return a valid input stream for old module urls */ public static InputStream getURLStream(URL url) { InputStream in = null; try { URLConnection uc = url.openConnection(); uc.setDefaultUseCaches(false); uc.setUseCaches(false); uc.setRequestProperty("Cache-Control", "max-age=0,no-cache"); uc.setRequestProperty("Pragma", "no-cache"); log.debug("Logging an attempt to connect to: " + url); in = openConnectionCheckRedirects(uc); } catch (IOException io) { log.warn("io while reading: " + url, io); } return in; }
@Override protected void finalize() throws Throwable { //see http://java.net/jira/browse/JAX_WS-1087 if (doReset) { c.setDefaultUseCaches(true); } } }
public class URLConnectionNoCache extends URLConnection { protected URLConnectionNoCache(URL url) { super(url); setDefaultUseCaches(false); } public void connect() throws IOException { } }
private InputStream openConnectionForUrl(URL url) throws IOException { URLConnection urlConnection = url.openConnection(); urlConnection.setDefaultUseCaches(false); InputStream in = urlConnection.getInputStream(); return in; } }
private static URLConnection openConnection(final URL url) throws IOException{ final URLConnection conn = url.openConnection(); conn.setReadTimeout(3000); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return conn; }
private static URLConnection openConnection(final URL url) throws IOException{ URLConnection conn = url.openConnection(); conn.setReadTimeout(3000); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return conn; }
private static URLConnection openConnection(final URL url) throws IOException{ URLConnection conn = url.openConnection(); conn.setReadTimeout(3000); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return conn; }
private static URLConnection openConnection(final URL url) throws IOException{ final URLConnection conn = url.openConnection(); conn.setReadTimeout(3000); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return conn; }
public InputStream run() throws IOException { URLConnection connection = url.openConnection(); // TUSCANY-2539 // Don't cache connections by default to stop Tuscany locking contribution jar files // done here as this is one of the first places we open a stream and the only way to // set the default is to set it on an instance of URLConnection connection.setDefaultUseCaches(false); connection.setUseCaches(false); return url.openStream(); } });
public InputStream run() throws IOException { URLConnection connection = url.openConnection(); // TUSCANY-2539 // Don't cache connections by default to stop Tuscany locking contribution jar files // done here as this is one of the first places we open a stream and the only way to // set the default is to set it on an instance of URLConnection connection.setDefaultUseCaches(false); connection.setUseCaches(false); return url.openStream(); } });
public static Reader getStream(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return new InputStreamReader(conn.getInputStream()); } }
public static Reader getStream(URL url) throws IOException { URLConnection conn = url.openConnection(); conn.setDefaultUseCaches(false); conn.setUseCaches(false); return new InputStreamReader(conn.getInputStream()); } }
/** * Utility method to set {@link URLConnection#setDefaultUseCaches(boolean)}. */ public static void setDefaultUseCaches(boolean useCaches) throws IOException { LOG.info("Turning off default caching in URLConnection"); final String currentDir = System.getProperty("user.dir"); new File(currentDir).toURI().toURL().openConnection().setDefaultUseCaches(useCaches); } }
/** * Utility method to set {@link URLConnection#setDefaultUseCaches(boolean)}. */ public static void setDefaultUseCaches(boolean useCaches) throws IOException { LOG.info("Turning off default caching in URLConnection"); final String currentDir = System.getProperty("user.dir"); new File(currentDir).toURI().toURL().openConnection().setDefaultUseCaches(useCaches); } }
URL url = new URL("jar:file://dummy.jar!/"); URLConnection uConn = new URLConnection(url) { @Override public void connect() throws IOException { // NOOP } }; uConn.setDefaultUseCaches(false);
public HTTPHelper(URL url) { this.url = url; proxy = null; try { URLConnection conn = openConnection(); conn.setDefaultUseCaches(false); } catch (IOException e) { e.printStackTrace(); } }
public HTTPHelper(URL url) { this.url = url; proxy = null; try { URLConnection conn = openConnection(); conn.setDefaultUseCaches(false); } catch (IOException e) { e.printStackTrace(); } }
@Override public void doOutsideClassLoader(ClassLoaderLeakPreventor preventor) { // This probably does not affect classloaders, but prevents some problems with .jar files try { // URL needs to be well-formed, but does not need to exist new URL("jar:file://dummy.jar!/").openConnection().setDefaultUseCaches(false); } catch (Exception ex) { preventor.error(ex); } } }