Resolving, collecting or retrieving paths

Through PathHelper we can resolve or collect paths or retrieving resources even through supported archive files (zip, jar, jmod, ear and war). So we can create a path collection by adding an entry in burningwave.properties file that starts with ‘paths.’ prefix (this is a fundamental requirement to allow PathHelper to load the paths), e.g.:

paths.my-collection=c:/some folder;C:/some folder 2/ some folder 3;
paths.my-collection-2=c:/some folder 4;C:/some folder 6;

These paths could be retrieved through PathHelper.getPaths method and we can find a resource in all configured paths plus the runtime class paths (that is automatically loaded under the entry named ‘paths.main-class-paths’) by using PathHelper.getResource method, e.g.:

ComponentSupplier componentSupplier = ComponentContainer.getInstance();
PathHelper pathHelper = componentSupplier.getPathHelper();
Collection<String> paths = pathHelper.getPaths("paths.my-collection", "paths.my-collection-2"));
//With the code below all configured paths plus runtime class paths will be iterated to search
//the resource called some.jar
FileSystemItem resource = pathHelper.getResource("/../some.jar");
InputStream inputStream = resource.toInputStream();

We can also use placeholder and relative paths, e.g.:

paths.my-collection-3=C:/some folder 2/ some folder 3;
paths.my-jar=${paths.my-collection-3}/../some.jar;

It is also possibile to obtain references to resources of the runtime class paths by using the pre-loaded entry ‘paths.main-class-paths’ (runtime class paths are automatically iterated for searching the path that match the entry), e.g.:

paths.my-jar=${paths.main-class-paths}/../some.jar;

We can also use a FileSystemItem listing (FSIL) expression and, for example, create a path collection of all absolute path of all classes of the runtime class paths:

paths.all-runtime-classes=//${paths.main-class-paths}//allChildren:.*?\.classes;

A FSIL expression encloses in a couple of double slash an absolute path or a placeholdered path collection that will be scanned; after the second double slash we have the listing type that could refear to direct children of scanned paths (‘children‘) or to all nested children of scanned paths (‘allChildren‘); after that and colons we have the regular expression with we are going to filter the absolute paths iterated.