}
InputStream is = ClassLoaderFactory.class.getClassLoader().getResourceAsStream(archiveResource);
if (is == null) {
throw new EmsException("Unable to find resource to store [" + archiveResource + "]");
}
// String tmpPath = System.getProperty("java.io.tmpdir");
String jarName = new File(archiveResource).getName();
jarName = jarName.substring(0, jarName.length() - 4);
File tmpFile = File.createTempFile(jarName, ".jar");
tmpFile.deleteOnExit();
FileOutputStream fos = new FileOutputStream(tmpFile);
byte[] buffer = new byte[4096];
int size = is.read(buffer);
while (size != -1) {
fos.write(buffer, 0, size);
size = is.read(buffer);
}
fos.close();
is.close();
jarCache.put(archiveResource, tmpFile);
return tmpFile.toURI().toURL();
} catch (FileNotFoundException e) {
throw new EmsException("Unable to make temporary file store",e);
} catch (IOException e) {
throw new EmsException("Unable to make temporary file store",e);
}
}