Package Import
The JS Registry provides several ways to import packages. They are called scanners and define, how package metadata is imported, where imported bundles are located and how the sources are accessed. All scanners can be configured with their own refresh period to be executed periodically.
The different scanners can be configured in the file WEB-INF/classes/spring-jsregistry-config.xml
.
Editing this file is not recommended.
DirectoryScanner
The DirectoryScanner scans given directories for packages. By default it imports package metadata into the JS Registry. The package sources are referenced from their directory.
The DirectoryScanner also offers a mode to import the sources into the database, but without deleting the existing packages from the directory.
Changes are detected and packages are re-imported.
This mode is activated by jsregistry.directoryscanner.registerAsFileLocation
, which has to be set to false
.
By default, the DirectoryScanner scans the /js
folder in the webapp, but can be configured to scan other directories as well.
To scan an additional root folder for packages, the list of directories to be scanned can be extended in the section directoriesToScan
.
See the following code sample:
<util:list id="directoriesToScan">
<!-- default js directory -->
<bean class="de.conterra.jsregistry.support.DirectoryInfo"
p:identifier="webapp_js"
p:directory="${jsregistry.directoryscanner.folder}"
p:url="${jsregistry.directoryscanner.url}"
p:includes="${jsregistry.directoryscanner.includes}"
p:excludes="${jsregistry.directoryscanner.excludes}"
/>
<!-- add custom directory location -->
<bean class="de.conterra.jsregistry.support.DirectoryInfo"
p:identifier="custom_directory"
p:directory="C:\\custom-packages"
p:url=""
p:includes="**"
p:excludes=""
/>
</util:list>
Since map.apps 4.0, the /js
folder in the shipped version does not contain packages anymore and is therefore still scanned by the DirectoryScanner, but without any further import action.
The packages are now located at WEB-INF/bundle-import
and are scanned by the ArchiveScanner.
ArchiveScanner
The ArchiveScanner scans a given directory for archives (*.jar
, *.zip
) that contain one or multiple packages.
By default, this directory is the WEB-INF/bundle-import
directory of the webapp.
The ArchiveScanner offers two modes on how to handle the detected packages.
The modes are controlled by the property jsregistry.archivescanner.importByReference
which is true
by default.
Given jsregistry.archivescanner.importByReference
is set to true
, the ArchiveScanner imports only the package metadata by using the ClasspathScanner described in the following.
The sources remain in the archives in the directory and are referenced from there.
A file META-INF/js-registry-packs.properties
must be present inside the archives like defined by the ClasspathScanner.
The second mode extracts the archive to a temporary folder and imports the metadata and sources of each bundle into the database. After an import is successful, the imported archive is deleted from the directory.
The list of directories to be scanned can be extended in the section archiveDirectoriesToScan
.
See the following code sample:
<util:list id="archiveDirectoriesToScan">
<bean class="de.conterra.jsregistry.support.DirectoryInfo"
p:identifier="webapp_bundle_import"
p:directory="${jsregistry.archivescanner.folder}" />
<!-- add custom directory location -->
<bean class="de.conterra.jsregistry.support.DirectoryInfo"
p:identifier="custom_directory"
p:directory="C:\\custom-packages"
/>
</util:list>
ClasspathScanner
The ClasspathScanner is scanning the archives from the classpath for packages.
The metadata from detected packages is imported into the JS Registry.
The sources are referenced from the archives in the classpath.
To let the scanner find the required packages, it searchs for META-INF/js-registry-packs.properties
files inside the JAR archives.
A js-registry-packs.properties
file has the following content:
# a comment
packages=<path to bundle inside jar>,<path to second bundle inside jar>
# for example:
packages=bundles/my-bundle,bundles/my-test