org.allcolor.yahp.converter
Class CJarLoaderURLStreamHandler

java.lang.Object
  extended by java.net.URLStreamHandler
      extended by org.allcolor.yahp.converter.CJarLoaderURLStreamHandler

public class CJarLoaderURLStreamHandler
extends java.net.URLStreamHandler


Nested Class Summary
static class CJarLoaderURLStreamHandler.CGCCleaner
          This class will clean the preload map entry upon GC
 
Field Summary
private static CJarLoaderURLStreamHandler handler
           
private  java.util.Map preload
          preload byte class map
 
Constructor Summary
CJarLoaderURLStreamHandler()
           
 
Method Summary
 void addClassPreload(java.lang.String path, byte[] array)
          add a class byte representation in the preload map
static CJarLoaderURLStreamHandler getInstance()
           
static byte[] loadByteArray(java.io.InputStream in)
          load the given inputstream in a byte array
static byte[] loadByteArray(java.net.URL urlToResource)
          load the given url in a byte array
protected  java.net.URLConnection openConnection(java.net.URL u)
           
 
Methods inherited from class java.net.URLStreamHandler
equals, getDefaultPort, getHostAddress, hashCode, hostsEqual, openConnection, parseURL, sameFile, setURL, setURL, toExternalForm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

handler

private static CJarLoaderURLStreamHandler handler

preload

private java.util.Map preload
preload byte class map

Constructor Detail

CJarLoaderURLStreamHandler

public CJarLoaderURLStreamHandler()
Method Detail

getInstance

public static CJarLoaderURLStreamHandler getInstance()

addClassPreload

public void addClassPreload(java.lang.String path,
                            byte[] array)
add a class byte representation in the preload map

Parameters:
path - path to the class inside the jar
array - byte representation

loadByteArray

public static final byte[] loadByteArray(java.io.InputStream in)
load the given inputstream in a byte array

Parameters:
in - the stream to load
Returns:
a byte array

loadByteArray

public static final byte[] loadByteArray(java.net.URL urlToResource)
load the given url in a byte array

Parameters:
urlToResource - url to load
Returns:
a byte array

openConnection

protected java.net.URLConnection openConnection(java.net.URL u)
                                         throws java.io.IOException
Specified by:
openConnection in class java.net.URLStreamHandler
Throws:
java.io.IOException