Hi,
based on an off-line discussion, we decided to simply throw warnings within
the getNewBundlesInfo method loop if any of the above mentioned issue(s)
associated with a non-OSGi JAR is/are encountered.

This effectively means unless a particular file added to the dropins folder
is an OSGi JAR, no other file(s) will be written to the bundles.info file
of the particular profile, thus will not be picked up by the Carbon server.
And adding a non-OSGi JAR to the dropins folder will not halt the server
from starting.

On Tue, Apr 26, 2016 at 11:26 AM, Chiranga Alwis <[email protected]> wrote:

> 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
>



-- 
Chiranga Alwis,
Software Engineering Intern,
+94 77 5930497
+94 77 6368208
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to