BundleURLScanner

BundleURLScanner

When?

You should use the BundleURLScanner if you wish to implement an extender that is triggered by existence of specific files or directories in bundles.

Examples

Pax Web Extender - War

Pax Web Extender - War uses Pax Swissbox - Extender / BundleURLScanner to trigger web applications registration / unregistration as soon as a WAR bundle gets started or stopped. You can browse the code (hhttps://scm.ops4j.org/repos/ops4j/projects/pax/web-extender/war/src/main/java/org/ops4j/pax/web/extender/war/internal/Activator.java) as a real life example.

WAR extender

The following is an example of how you can implement an extender bundle for war files:

new BundleWatcher<URL>( bundleContext, new BundleURLScanner( "WEB-INF/", "web.xml", false // do not recurse ), new BundleObserver<URL>() { public void addingEntries( Bundle bundle, List<URL> entries ) { // process web xml, as for example parsing and registering servlets } public void removingEntries( Bundle bundle, List<URL> entries ) { // revert processing of web xml } } ).start();