/** * @param path * @param tmpWarDir * @throws IOException */ private static void copy(Enumeration<String> paths, File destDir) throws IOException { if (paths != null) { while (paths.hasMoreElements()) { String path = paths.nextElement(); if (path.endsWith("/")) { File targetDir = new File(destDir, FilenameUtils.getName(path.substring(0, path.lastIndexOf("/")))); copy(Activator.getContext().getBundle().getEntryPaths(path), targetDir); } else { URL entry = Activator.getContext().getBundle().getEntry(path); FileUtils.copyInputStreamToFile( entry.openStream(), new File(destDir, FilenameUtils.getName(path))); } } } }
/** * Used in war export to create a services.properties file, which is needed to load services specs * in the war. * * @return the locations of services folders relative to the war dir. */ public static String getServicesDirectoryNames() { StringBuilder locations = new StringBuilder(); Enumeration<String> paths = Activator.getContext().getBundle().getEntryPaths("/war/"); while (paths.hasMoreElements()) { String name = paths.nextElement().replace("war/", ""); if (name.endsWith("services/")) locations.append("/" + name + ";"); } if (locations.length() > 0) locations.deleteCharAt(locations.length() - 1); return locations.toString(); }
/** * Copy the default component packages to war. * * @param path * @throws IOException * @throws Exception */ public static void copyDefaultComponentsAndServices(File tmpWarDir) throws IOException { copy(Activator.getContext().getBundle().getEntryPaths("/war/"), tmpWarDir); }