List of usage examples for org.springframework.core.io UrlResource getFilename
@Override
public String getFilename()
From source file:com.enonic.cms.core.plugin.container.OsgiContainer.java
private void copyFrameworkJar(final File targetFile) throws Exception { URL location = FrameworkProperties.class.getProtectionDomain().getCodeSource().getLocation(); final String locationFile = location.getFile(); LOG.info("Location of framework.jar : " + locationFile); if (locationFile.endsWith(".jar!/")) // for IBM Websphere 8.5 Liberty Profile {//from www .j a v a2 s . c om String absolutePath = locationFile.substring(0, locationFile.length() - 2); location = new URL(absolutePath); } else if (ResourceUtils.URL_PROTOCOL_VFS.equals(location.getProtocol())) // JBOSS 7.1.1 VFS { final URI uri = ResourceUtils.toURI(location); final UrlResource urlResource = new UrlResource(uri); final File file = urlResource.getFile(); String absolutePath = file.getAbsolutePath(); if (!absolutePath.endsWith(urlResource.getFilename())) { // removing /contents folder from path and adding unpacked jar to path. absolutePath = absolutePath.substring(0, absolutePath.length() - VFS_CONTENTS_FOLDER.length()) + urlResource.getFilename(); } final StringBuilder stringBuilder = new StringBuilder("file:/"); if (!SystemUtils.IS_OS_WINDOWS) // windows already has one slash in path like /c:/Program Files/.... { stringBuilder.append('/'); } stringBuilder.append(absolutePath); location = new URL(stringBuilder.toString()); } LOG.info("Copying " + location.toString() + " to " + targetFile.toString()); Files.copy(Resources.newInputStreamSupplier(location), targetFile); }