public boolean isDeployed(final String path) { return deployedApplications.containsKey(ProvisioningUtil.realLocation(path)); }
public AppInfo getAppInfo(final String path) { return deployedApplications.get(ProvisioningUtil.realLocation(path).iterator().next()); }
public boolean isDeployed(final String path) { return deployedApplications.containsKey(ProvisioningUtil.realLocation(path).iterator().next()); }
protected String filteredCommand() { String val = command; int expandStart; while ((expandStart = val.indexOf("@[classpath:")) >= 0) { final int end = val.indexOf("]", expandStart); if (end < 0) { break; } final String expandable = simpleValue(val.substring(expandStart + "@[classpath:".length(), end)); final List<URL> repos = new ArrayList<>(Files.listJars(ProvisioningUtil.realLocation(expandable))); Collections.sort(repos, (o1, o2) -> o1.toExternalForm().compareTo(o2.toExternalForm())); final StringBuilder cp = new StringBuilder(); for (final URL u : repos) { cp.append(Files.toFile(u)).append(System.getProperty("path.separator")); } if (cp.length() > 0) { cp.setLength(cp.length() - System.getProperty("path.separator").length()); } val = val.substring(0, expandStart) + cp.toString() + (end < val.length() ? val.substring(end + 1) : ""); } return simpleValue(val); }
/** * Takes a raw unparsed string expected to be in jvm classpath syntax * and parses it, producing a collection of URIs representing the absolute * file paths of the classpath to be created. * <p/> * OS specific delimiters are supported. * * @param rawstring unparsed string in "classpath" syntax * @return URI array * @throws IOException if path cannot be resolved or file referenced does not exist */ public static URI[] resolveClasspath(final String rawstring) throws IOException { final FileUtils base = SystemInstance.get().getBase(); final String[] strings = rawstring.contains("mvn:") ? rawstring.split(";") : rawstring.split(File.pathSeparator); final Collection<URI> classpath = new LinkedList<>(); for (final String string : strings) { final Set<String> locations = ProvisioningUtil.realLocation(PropertyPlaceHolderHelper.simpleValue(string)); for (final String location : locations) { final File file = base.getFile(location, false); classpath.add(file.toURI()); } } return classpath.toArray(new URI[classpath.size()]); }
@Override public void undeploy(final String moduleId) throws UndeployException, NoSuchApplicationException { try { assembler.destroyApplication(moduleId); } catch (final NoSuchApplicationException nsae) { try { assembler.destroyApplication(realLocation(moduleId)); } catch (final Exception e) { try { assembler.destroyApplication(new File(moduleId).getAbsolutePath()); } catch (final Exception e2) { try { assembler.destroyApplication(new File(realLocation(moduleId)).getAbsolutePath()); } catch (final Exception e3) { throw nsae; } } } } saveDeployment(new File(moduleId), false); }
private static String fallback(final String rawLocation) { if (rawLocation.startsWith(MVN_PREFIX)) { try { final String repo1Url = quickMvnUrl(rawLocation.substring(MVN_PREFIX.length()).replace(":", "/")); final String real = realLocation(repo1Url); return real; } catch (final MalformedURLException e1) { Logger.getLogger(ProvisioningUtil.class.getName()).severe("Can't find " + rawLocation); } } else { // try url try { final File file = cacheFile(lastPart(rawLocation)); final URL url = new URL(rawLocation); InputStream is = null; try { is = new BufferedInputStream(url.openStream()); IO.copy(is, file); return file.getAbsolutePath(); } finally { IO.close(is); } } catch (final Exception e1) { // no-op } } // if it was not an url that's just a file path return rawLocation; }
@Override public void undeploy(final String moduleId) throws UndeployException, NoSuchApplicationException { AppInfo appInfo = assembler.getAppInfo(moduleId); if (appInfo == null) { appInfo = assembler.getAppInfo(realLocation(moduleId).iterator().next()); if (appInfo == null) { appInfo = assembler.getAppInfo(new File(moduleId).getAbsolutePath()); if (appInfo == null) { appInfo = assembler.getAppInfo(new File(realLocation(moduleId).iterator().next()).getAbsolutePath()); } } } if (appInfo != null) { try { assembler.destroyApplication(appInfo); } finally { if (appInfo.properties.containsKey("save-deployment")) { saveDeployment(new File(moduleId), false); } } } else { throw new NoSuchApplicationException(moduleId); } }
final Set<URL> repos = Files.listJars(ProvisioningUtil.realLocation(location)); toAdd.addAll(repos);
if (toCopy != null) { for (final String lib : toCopy.split(",")) { libToCopy.add(realLocation(lib.trim())); if (toExtract != null) { for (final String zip : toExtract.split(",")) { libToCopy.addAll(extract(realLocation(zip)));
private static Collection<String> extract(final String zip) throws IOException { final File tmp = new File(SystemInstance.get().getBase().getDirectory(), TEMP_DIR); if (!tmp.exists()) { try { Files.mkdirs(tmp); } catch (final Files.FileRuntimeException fre) { // ignored } } final File zipFile = new File(realLocation(zip)); final File extracted = new File(tmp, zipFile.getName().replace(".zip", "")); if (extracted.exists()) { return list(extracted); } else { Files.mkdirs(extracted); } Zips.unzip(zipFile, extracted); return list(extracted); }
final Set<URL> repos = toUrls(ProvisioningUtil.realLocation(location)); toAdd.addAll(repos);
/** * Takes a raw unparsed string expected to be in jvm classpath syntax * and parses it, producing a collection of URIs representing the absolute * file paths of the classpath to be created. * <p/> * OS specific delimiters are supported. * * @param rawstring unparsed string in "classpath" syntax * @return URI array * @throws IOException if path cannot be resolved or file referenced does not exist */ public static URI[] resolveClasspath(final String rawstring) throws IOException { final FileUtils base = SystemInstance.get().getBase(); final String[] strings = rawstring.split(File.pathSeparator); final URI[] classpath = new URI[strings.length]; for (int i = 0; i < strings.length; i++) { final String string = strings[i]; final String pathname = PropertyPlaceHolderHelper.simpleValue(ProvisioningUtil.realLocation(string)); final File file = base.getFile(pathname, false); classpath[i] = file.toURI(); } return classpath; }
final List<URL> urls = new ArrayList<URL>(); for (final String path : paths) { urls.add(new File(PropertyPlaceHolderHelper.value(ProvisioningUtil.realLocation(path))).toURI().normalize().toURL());
final List<URL> urls = new ArrayList<>(); for (final String path : paths) { final Set<String> values = ProvisioningUtil.realLocation(PropertyPlaceHolderHelper.value(path)); for (final String v : values) { urls.add(new File(v).toURI().normalize().toURL());
file = copyBinaries(properties); } else { file = new File(realLocation(rawLocation));
file = copyBinaries(properties); } else { file = new File(realLocation(rawLocation).iterator().next());