in core/servicemix-core/src/main/java/org/apache/servicemix/jbi/framework/AutoDeploymentService.java [550:599]
protected static File unpackLocation(File tmpRoot, String location) throws DeploymentException {
File tmpDir = null;
File file = null;
try {
if (location.startsWith(filePrefix)) {
String os = System.getProperty("os.name");
if (os.startsWith("Windows")) {
location = location.replace('\\', '/');
location = location.replaceAll(" ", "%20");
}
URI uri = new URI(location);
file = new File(uri);
} else {
file = new File(location);
}
if (file.isDirectory()) {
LOGGER.debug("Deploying an exploded jar/zip, we will create a temporary jar for it.");
// If we have a directory then we should move it over
File newFile = new File(tmpRoot.getAbsolutePath() + "/exploded.jar");
newFile.delete();
FileUtil.zipDir(file.getAbsolutePath(), newFile.getAbsolutePath());
file = newFile;
LOGGER.debug("Deployment will now work from {}", file.getAbsolutePath());
}
if (!file.exists()) {
// assume it's a URL
try {
URL url = new URL(location);
String fileName = url.getFile();
if (fileName == null) {
throw new DeploymentException("Location: " + location + " is not an archive");
}
file = FileUtil.unpackArchive(url, tmpRoot);
} catch (MalformedURLException e) {
throw new DeploymentException(e);
}
}
if (FileUtil.archiveContainsEntry(file, DescriptorFactory.DESCRIPTOR_FILE)) {
tmpDir = FileUtil.createUniqueDirectory(tmpRoot, file.getName());
FileUtil.unpackArchive(file, tmpDir);
LOGGER.debug("Unpacked archive {} to {}", location, tmpDir);
}
} catch (IOException e) {
throw new DeploymentException(e);
} catch (URISyntaxException ex) {
throw new DeploymentException(ex);
}
return tmpDir;
}