You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:25:43 UTC

[sling-org-apache-sling-startupfilter] 08/21: SLING-2601 - more robust mechanism for disabling StartupFilter, based on the presence of a disabling service

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

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

commit 23e1d12f28fa857f71b351478e4b831bb82f4747
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Tue Sep 18 06:58:25 2012 +0000

    SLING-2601 - more robust mechanism for disabling StartupFilter, based on the presence of a disabling service
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1387008 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/startupfilter/StartupFilterDisabler.java | 24 ++++++++++++++++++++++
 .../startupfilter/impl/StartupFilterImpl.java      | 17 +++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java b/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
new file mode 100644
index 0000000..6cfd0f7
--- /dev/null
+++ b/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.sling.startupfilter;
+
+public interface StartupFilterDisabler {
+    /** Indicate why the StartupFilter should be disabled */
+    String getReason();
+}
diff --git a/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java b/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
index a26395f..d1ed6dd 100644
--- a/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
+++ b/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
@@ -35,8 +35,12 @@ import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
 import org.apache.felix.scr.annotations.Service;
 import org.apache.sling.startupfilter.StartupFilter;
+import org.apache.sling.startupfilter.StartupFilterDisabler;
 import org.apache.sling.startupfilter.StartupInfoProvider;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -71,8 +75,21 @@ public class StartupFilterImpl implements StartupFilter, Filter {
     public static final String DEFAULT_MESSAGE_PROP = "default.message";
     private String defaultMessage;
     
+    @Reference(cardinality=ReferenceCardinality.OPTIONAL_UNARY, policy=ReferencePolicy.DYNAMIC)
+    private StartupFilterDisabler startupFilterDisabler;
+    
     /** @inheritDoc */
     public void doFilter(ServletRequest request, ServletResponse sr, FilterChain chain) throws IOException, ServletException {
+        
+        // Disable if a StartupFilterDisabler is present
+        if(startupFilterDisabler!= null) {
+            log.info("StartupFilterDisabler service present, disabling StartupFilter ({})", 
+                    startupFilterDisabler.getReason());
+            disable();
+            chain.doFilter(request, sr);
+            return;
+        }
+        
         updateProviders();
         
         final StringBuilder sb = new StringBuilder();

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.