Tabnine Logo
URL.setURLStreamHandlerFactory
Code IndexAdd Tabnine to your IDE (free)

How to use
setURLStreamHandlerFactory
method
in
java.net.URL

Best Java code snippets using java.net.URL.setURLStreamHandlerFactory (Showing top 20 results out of 828)

origin: stackoverflow.com

URL.setURLStreamHandlerFactory(new CustomURLStreamHandlerFactory());
origin: google/agera

@BeforeClass
public static void onlyOnce() throws Throwable {
 mockHttpURLConnection = mock(HttpURLConnection.class);
 URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
  @Override
  public URLStreamHandler createURLStreamHandler(final String s) {
   return s.equals(TEST_PROTOCOL) ? new URLStreamHandler() {
    @Override
    protected URLConnection openConnection(final URL url) throws IOException {
     return mockHttpURLConnection;
    }
   } : null;
  }
 });
}
origin: 4thline/cling

URL.setURLStreamHandlerFactory(
  (URLStreamHandlerFactory) Class.forName(
    "org.fourthline.cling.transport.impl.FixedSunURLStreamHandler"
origin: org.springframework.boot/spring-boot

URL.setURLStreamHandlerFactory(new WarUrlStreamHandlerFactory());
origin: org.apache.logging.log4j/log4j-core

  @Override
  public void evaluate() throws Throwable {
    Field factoryField = null;
    int matches = 0;
    URLStreamHandlerFactory oldFactory = null;
    for (final Field field : URL.class.getDeclaredFields()) {
      if (URLStreamHandlerFactory.class.equals(field.getType())) {
        factoryField = field;
        matches++;
        factoryField.setAccessible(true);
        oldFactory = (URLStreamHandlerFactory) factoryField.get(null);
        break;
      }
    }
    Assert.assertNotNull("java.net URL does not declare a java.net.URLStreamHandlerFactory field",
        factoryField);
    Assert.assertEquals("java.net.URL declares multiple java.net.URLStreamHandlerFactory fields.", 1,
        matches); // FIXME There is a break in the loop so always 0 or 1
    URL.setURLStreamHandlerFactory(newURLStreamHandlerFactory);
    try {
      base.evaluate();
    } finally {
      clearURLHandlers();
      factoryField.set(null, null);
      URL.setURLStreamHandlerFactory(oldFactory);
    }
  }
};
origin: mulesoft/mule

/**
 * Install an instance of this class as UrlStreamHandlerFactory. This may be done exactly once as {@link URL} will throw an
 * {@link Error} on subsequent invocations.
 * <p>
 * This method takes care that multiple invocations are possible, but the UrlStreamHandlerFactory is installed only once.
 */
public static synchronized void installUrlStreamHandlerFactory() {
 /*
  * When running under surefire, this class will be loaded by different class loaders and will be running in multiple "main"
  * thread objects. Thus, there is no way for this class to register a globally available variable to store the info whether
  * our custom UrlStreamHandlerFactory was already registered.
  * 
  * The only way to accomplish this is to catch the Error that is thrown by URL when trying to re-register the custom
  * UrlStreamHandlerFactory.
  */
 try {
  URL.setURLStreamHandlerFactory(new MuleUrlStreamHandlerFactory());
 } catch (Error err) {
  if (log.isDebugEnabled()) {
   log.debug("Custom MuleUrlStreamHandlerFactory already registered", err);
  }
 }
}
origin: apache/tika

/**
 * Starts a forked server process using the standard input and output
 * streams for communication with the parent process. Any attempts by
 * stray code to read from standard input or write to standard output
 * is redirected to avoid interfering with the communication channel.
 * 
 * @param args command line arguments, ignored
 * @throws Exception if the server could not be started
 */
public static void main(String[] args) throws Exception {
  long serverPulseMillis = Long.parseLong(args[0]);
  long serverParseTimeoutMillis = Long.parseLong(args[1]);
  long serverWaitTimeoutMillis = Long.parseLong(args[2]);
  URL.setURLStreamHandlerFactory(new MemoryURLStreamHandlerFactory());
  ForkServer server = new ForkServer(System.in, System.out,
      serverPulseMillis, serverParseTimeoutMillis, serverWaitTimeoutMillis);
  System.setIn(new ByteArrayInputStream(new byte[0]));
  System.setOut(System.err);
  Thread watchdog = new Thread(server, "Tika Watchdog");
  watchdog.setDaemon(true);
  watchdog.start();
  server.processRequests();
}
origin: kingthy/TVRemoteIME

URL.setURLStreamHandlerFactory(
  (URLStreamHandlerFactory) Class.forName(
    "org.fourthline.cling.transport.impl.FixedSunURLStreamHandler"
origin: org.apache.tomcat/tomcat-catalina

private TomcatURLStreamHandlerFactory(boolean register) {
  // Hide default constructor
  // Singleton pattern to ensure there is only one instance of this
  // factory
  this.registered = register;
  if (register) {
    URL.setURLStreamHandlerFactory(this);
  }
}
origin: rancher/cattle

public synchronized void register() {
  if (!registered) {
    URL.setURLStreamHandlerFactory(this);
    registered = true;
  }
}
origin: alipay/sofa-ark

/**
 * Reset any cached handlers just in case a jar protocol has already been used. We
 * reset the handler by trying to set a null {@link URLStreamHandlerFactory} which
 * should have no effect other than clearing the handlers cache.
 */
private static void resetCachedUrlHandlers() {
  try {
    URL.setURLStreamHandlerFactory(null);
  } catch (Error ex) {
    // Ignore
  }
}
origin: codefollower/Tomcat-Research

private TomcatURLStreamHandlerFactory(boolean register) {
  // Hide default constructor
  // Singleton pattern to ensure there is only one instance of this
  // factory
  this.registered = register;
  if (register) {
    URL.setURLStreamHandlerFactory(this);
  }
}
origin: OpenNMS/opennms

/**
 * <p>initialize</p>
 * Initializing the URL Factory
 */
public static void initialize() {
  try {
    URL.setURLStreamHandlerFactory(genericUrlFactory);
  } catch (Error exception) {
    // ignore error concerning resetting the URLStreamHandlerFactory
  }
}
origin: org.opennms/opennms-util

/**
 * <p>initialize</p>
 * Initializing the URL Factory
 */
public static void initialize() {
  try {
    URL.setURLStreamHandlerFactory(genericUrlFactory);
  } catch (Error exception) {
    // ignore error concerning resetting the URLStreamHandlerFactory
  }
}
origin: org.jboss.jbossas/jboss-as-main

  public Void run()
  {
   URL.setURLStreamHandlerFactory(ushf);
   return null;
  }
});
origin: io.joshworks/snappy-loader

/**
 * Reset any cached handlers just in case a jar protocol has already been used. We
 * reset the handler by trying to set a null {@link URLStreamHandlerFactory} which
 * should have no effect other than clearing the handlers cache.
 */
private static void resetCachedUrlHandlers() {
  try {
    URL.setURLStreamHandlerFactory(null);
  } catch (Error ex) {
    // Ignore
  }
}
origin: stackoverflow.com

 public static String unsetURLStreamHandlerFactory() {
  try {
    Field f = URL.class.getDeclaredField("factory");
    f.setAccessible(true);
    Object curFac = f.get(null);
    f.set(null, null);
    URL.setURLStreamHandlerFactory(null);
    return curFac.getClass().getName();
  } catch (Exception e) {
    return null;
  }
}
origin: robo-code/robocode

public static void register() {
  if (!registered) {
    URL.setURLStreamHandlerFactory(new JarJarURLStreamHandlerFactory());
    registered = true;
  }
}
origin: edu.ucar/cdm

static public void install() {
 try {
  if (!installed) {
   java.net.URL.setURLStreamHandlerFactory( new URLStreamHandlerFactory() );
   installed = true;
  }
 } catch (Error e) {
  log.error("Error installing URLStreamHandlerFactory "+e.getMessage());
  // Log.errorG("Error installing URLStreamHandlerFactory "+e.getMessage());
 }
}
origin: org.apache.camel/camel-hdfs2

protected void initHdfs() {
  try {
    URL.setURLStreamHandlerFactory(new FsUrlStreamHandlerFactory());
  } catch (Throwable e) {
    // ignore as its most likely already set
    LOG.debug("Cannot set URLStreamHandlerFactory due " + e.getMessage() + ". This exception will be ignored.", e);
  }
}
java.netURLsetURLStreamHandlerFactory

Javadoc

Sets the stream handler factory for this VM.

Popular methods of URL

  • <init>
  • openStream
    Opens a connection to this URL and returns anInputStream for reading from that connection. This meth
  • openConnection
    Returns a new connection to the resource referred to by this URL.
  • toString
    Constructs a string representation of this URL. The string is created by calling the toExternalForm
  • getPath
    Gets the path part of this URL.
  • toURI
    Returns a java.net.URI equivalent to this URL. This method functions in the same way as new URI (thi
  • getProtocol
    Gets the protocol name of this URL.
  • getFile
    Gets the file name of this URL. The returned file portion will be the same as getPath(), plus the c
  • toExternalForm
    Constructs a string representation of this URL. The string is created by calling the toExternalForm
  • getHost
    Gets the host name of this URL, if applicable. The format of the host conforms to RFC 2732, i.e. for
  • getPort
    Gets the port number of this URL.
  • getQuery
    Gets the query part of this URL.
  • getPort,
  • getQuery,
  • equals,
  • getRef,
  • getUserInfo,
  • getAuthority,
  • hashCode,
  • getDefaultPort,
  • getContent

Popular in Java

  • Reading from database using SQL prepared statement
  • getExternalFilesDir (Context)
  • onRequestPermissionsResult (Fragment)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • ImageIO (javax.imageio)
  • JTextField (javax.swing)
  • Runner (org.openjdk.jmh.runner)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now