This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-apiregions.git


The following commit(s) were added to refs/heads/master by this push:
     new feab4b1  SLING-13174 : Allow to completely disable apiregions via 
framework property
feab4b1 is described below

commit feab4b143eb4265292caf7c43a028d37896ead74
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Fri Apr 17 13:24:06 2026 +0200

    SLING-13174 : Allow to completely disable apiregions via framework property
---
 README.md                                                  | 14 +++++++++-----
 .../apache/sling/feature/apiregions/impl/Activator.java    |  8 ++++++++
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 37fd04c..e99a1aa 100644
--- a/README.md
+++ b/README.md
@@ -24,14 +24,17 @@ the above framework properties:
 
 File locations are either provided as an absolute file path or by URL. The URL 
handling mechanism supports one special pseudo-protocol:
 `classloader://`. URLs specified with this protocol are passed through the 
framework classloader's `getResource()` method to obtain
-the actual URL. 
+the actual URL.
 
 ## Enabling / disabling this component
-The component is enabled by setting the following framework property:
+
+If the framework property `org.apache.sling.feature.apiregions.disable` is set 
to `true` the component is completely disabled.
+
+The checking is enabled by setting the following framework property:
 
     org.apache.sling.feature.apiregions.regions=*
 
-If this framework property is not set the component will be disabled.
+If this framework property is not set the checking will be disabled.
 
 ## Additional Configuration
 
@@ -41,6 +44,7 @@ The following framework properties are also recognised:
 * `sling.feature.apiregions.joinglobal` - a comma-separated list of region 
names. All packages exported by these regions are added to the `global` region.
 
 ## Runtime Configuration
+
 If this component runs in a framework with Configuration Admin present, and it 
is set to be enabled using the framework property, it can be disabled at runtime
 through Configuration Admin configuration.
 
@@ -48,12 +52,12 @@ Runtime configuration supported:
 
 **PID**: `org.apache.sling.feature.apiregions.impl`
 
-Key | Value  
+Key | Value
 --- | ---
 `disable` | if `true` then the API Regions component is disabled. Otherwise 
the component is enabled.
 
 No meta type is defined for this configuration since it's not a typical user 
setting. However, when using the web console
-the configuration can be created using `curl`: 
+the configuration can be created using `curl`:
 
     curl -u <user>:<pass> -X POST -d "apply=true" -d "propertylist=disable" -d 
"disable=true" 
http://localhost:8080/system/console/configMgr/org.apache.sling.feature.apiregions.impl
 
diff --git 
a/src/main/java/org/apache/sling/feature/apiregions/impl/Activator.java 
b/src/main/java/org/apache/sling/feature/apiregions/impl/Activator.java
index 530b255..9ac4dcb 100644
--- a/src/main/java/org/apache/sling/feature/apiregions/impl/Activator.java
+++ b/src/main/java/org/apache/sling/feature/apiregions/impl/Activator.java
@@ -59,6 +59,8 @@ public class Activator implements BundleActivator, 
FrameworkListener {
 
     static final String REGIONS_PROPERTY_NAME = 
"org.apache.sling.feature.apiregions.regions";
 
+    static final String DISABLE_PROPERTY_NAME = 
"org.apache.sling.feature.apiregions.disable";
+
     static final Logger LOG = 
Logger.getLogger(ResolverHookImpl.class.getName());
 
     BundleContext bundleContext;
@@ -73,6 +75,12 @@ public class Activator implements BundleActivator, 
FrameworkListener {
     public synchronized void start(BundleContext context) throws Exception {
         bundleContext = context;
 
+        final boolean disabled = 
Boolean.parseBoolean(context.getProperty(DISABLE_PROPERTY_NAME));
+        if (disabled) {
+            LOG.info("API Regions runtime enforcement component is disabled");
+            return;
+        }
+
         createConfiguration();
 
         registerHook();

Reply via email to