Hi, I have been working on improving the existing dropins capability within the Carbon-kernel.
In the utility methods I am using for dropins, I have a method which reads in the files of a given source directory and construct OSGi Bundle Information (BundleInfo.java <https://github.com/wso2/carbon-kernel/blob/master/launcher/src/main/java/org/wso2/carbon/launcher/extensions/model/BundleInfo.java>) instances. public static List<BundleInfo> getNewBundlesInfo(Path sourceDirectory) throws IOException { List<BundleInfo> newBundleInfoLines = new ArrayList<>(); if ((sourceDirectory != null) && (Files.exists(sourceDirectory))) { Stream<Path> children = Files.list(sourceDirectory); children.parallel().forEach(child -> { try { logger.log(Level.FINE, "Loading OSGi bundle information from " + child); getNewBundleInfo(child).ifPresent(newBundleInfoLines::add); logger.log(Level.FINE, "Successfully loaded OSGi bundle information from " + child); } catch (IOException e) { throw new RuntimeException("Error when loading the OSGi bundle information from " + child, e); } }); } else { throw new IOException("Invalid OSGi bundle source directory: " + sourceDirectory); } return newBundleInfoLines; } Method getNewBundleInfo takes in a Path object and constructs the new BundleInfo instance if the appropriate conditions are satisfied. private static Optional<BundleInfo> getNewBundleInfo(Path bundlePath) throws IOException This method will throw an IOException in cases such as the following: - if the JAR manifest is not found. - if the OSGi Bundle-SymbolicName or the BundleVersion are not found The method returns Optional.empty() if the file does not have a .jar extension. In the above getNewBundlesInfo method, should I throw an exception when the loop encounters a non-OSGi JAR and stop the flow (currently, a RuntimeException is thrown to halt the processing) or should I continue processing the other directory files by simply issuing a warning when an invalid file is encountered? -- Chiranga Alwis, Software Engineering Intern, +94 77 5930497 +94 77 6368208
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev