- Notifications
You must be signed in to change notification settings - Fork0
Netcentric/bundle-namespace-validators
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
ABnd plugin that validates OSGi bundle metadata compliance with configurable namespacing rules. This plugin helps ensure consistent naming conventions and organizational standards across OSGi bundles in enterprise projects. It validates the following aspects of an OSGi bundle
- Export Package - Validates thatexported packages follow naming conventions
- Bundle Symbolic Name - Ensuresbundle symbolic names follow naming conventions
- DS Component Provided Services - Validatesprovided service FQCNs in DS components
- HTTP/Servlet Whiteboard - Validates that HTTP servlets/filters registered viaHTTP/servlet whiteboard are listening to specific paths only
- Sling Servlet/Filter - ValidatesSling servlet paths, resource types, and resource super types as well asSling filter patterns/resource types
- Sling Authentication Handler - Validates aSling Authentication Handler is registered to a specific path only
Validates that all exported packages match a specified regular expression pattern.
Ensures Bundle-SymbolicName headers conform to naming conventions, with support for parameter handling (e.g.,singleton:=true).
Validates that Declarative Services components only provide services whose fully qualified class names match specified patterns.
In addition to explicitly configured patterns, the following services are always allowed by default because they are known to support multi-tenancy or are unlikely to cause namespace clashes:
javax.servlet.Servletjakarta.servlet.Servletjavax.servlet.Filterjakarta.servlet.Filterorg.apache.sling.api.adapter.AdapterFactoryorg.apache.sling.rewriter.TransformerFactorycom.adobe.granite.workflow.exec.WorkflowProcesscom.day.cq.workflow.exec.WorkflowProcessorg.apache.sling.auth.core.spi.AuthenticationHandler
For DS components implementingjavax.servlet.Servlet orjakarta.servlet.Servlet, validates
osgi.http.whiteboard.servlet.pattern- Servlet pattern
For DS components implementingjavax.servlet.Filter orjakarta.servlet.Filter, validates
osgi.http.whiteboard.filter.pattern- Servlet filter pattern
For DS components implementingjavax.servlet.Servlet orjakarta.servlet.Servlet, validates:
sling.servlet.paths- Servlet path patternssling.servlet.resourceTypes- Resource type patternssling.servlet.resourceSuperType- Resource super type patterns
For DS components implementingjavax.servlet.Filter orjakarta.servlet.Filter, validates:
sling.filter.pattern- Servlet filter patternssling.filter.resourceTypes- Resource type patterns
For DS components implementingorg.apache.sling.auth.core.spi.AuthenticationHandler validates propertypath.
The configuration differs slightly depending on which Maven plugin is being used.In generalBnd's -plugin instruction is being used.
| Parameter | Type | Description |
|---|---|---|
allowedExportPackagePatterns | Pattern[] | Regular expression(s) for validating exported package names |
allowedBundleSymbolicNamePatterns | Pattern[] | Regular expression(s) for validating Bundle-SymbolicName header |
allowedServiceClassPatterns | Pattern[] | Regular expression(s) for validating provided service FQCNs of DS components |
allowedHttpWhiteboardServletPatterns | Pattern[] | Regular expression(s) for validating HTTP Whiteboard servlet patterns (osgi.http.whiteboard.servlet.pattern) |
allowedHttpWhiteboardFilterPatterns | Pattern[] | Regular expression(s) for validating HTTP Whiteboard filter patterns (osgi.http.whiteboard.filter.pattern) |
allowedSlingServletPathsPatterns | Pattern[] | Regular expression(s) for validating Sling servlet paths (sling.servlet.paths) |
allowedSlingServletResourceTypesPatterns | Pattern[] | Regular expression(s) for validating Sling servlet resource types (sling.servlet.resourceTypes) |
allowedSlingServletResourceSuperTypePatterns | Pattern[] | Regular expression(s) for validating Sling servlet resource super types (sling.servlet.resourceSuperType) |
allowedSlingFilterPatterns | Pattern[] | Regular expression(s) for validating Sling filter patterns (sling.filter.pattern) |
allowedSlingFilterResourceTypesPatterns | Pattern[] | Regular expression(s) for validating Sling filter resource types (sling.filter.resourceTypes) |
allowedSlingAuthenticationHandlerPathPatterns | Pattern[] | Regular expression(s) for validating Sling Authentication Handler's path property (path) |
Each parameter may take multipleregular expression patterns separated by comma. That makes the comma itself unusable within the regular expression pattern itself, however this shouldn't be necessary there.All parameters are optional. If not set the according property/name/header is not validated.
In general you add this artifact as plugin dependency to the Maven plugin. Then you can configure with the options outlined above.
<plugin> <groupId>biz.aQute.bnd</groupId> <artifactId>bnd-maven-plugin</artifactId> <version>7.1.0</version> <extensions>true</extensions> <configuration> <bnd><![CDATA[ Bundle-Name: My OSGi Bundle Bundle-SymbolicName: com.mycompany.bundles.mybundle Export-Package: \ com.mycompany.api.*,\ com.mycompany.services.* -plugin.namespace: biz.netcentric.osgi.bnd.NamespaceValidatorsPlugin; \ allowedExportPackagePattern="com\\.mycompany\\.myproject\\..**"; \ allowedBundleSymbolicNamePatterns="com\\.mycompany\\.bundles\\..*"; \ allowedServiceClassPatterns="com\\.mycompany\\.myproject\\..*"; \ allowedSlingServletPathsPattern="/bin/myproject/.*"; \ allowedSlingServletResourceTypesPatterns="/apps/myproject/.*"; \ allowedSlingServletResourceSuperTypePattern="/apps/myproject/.*";]]></bnd> </configuration> <dependencies> <dependency> <groupId>biz.netcentric.osgi.bnd</groupId> <artifactId>bundle-namespace-validators</artifactId> <version>1.0.0</version> </dependency> </dependencies></plugin>
- Java 8 or higher (builds with Java 21, targets Java 8)
- Maven 3.9.0 or higher
- Bnd 6.0.0 or higher (i.e.
bnd-maven-plugin6.0.0+ ormaven-bundle-plugin5.1.4+)
This project is licensed under the Eclipse Public License 2.0 - see theLICENSE for details.
- AEM Content Package Namespace Validators - Content package validation
- Bnd Tools - OSGi development tools
- Apache Sling - Web framework for the JVM
About
Bnd plugin validating that the OSGi metadata complies with certain namespacing rules
Resources
Uh oh!
There was an error while loading.Please reload this page.