incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1387008 - in /sling/trunk/contrib/extensions: startup-filter-disabler/ startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/ startup-filter/src/main/java/org/apache/sling/startupfilter/ startup-filter/src/main/...
Date Tue, 18 Sep 2012 06:58:26 GMT
Author: bdelacretaz
Date: Tue Sep 18 06:58:25 2012
New Revision: 1387008

URL: http://svn.apache.org/viewvc?rev=1387008&view=rev
Log:
SLING-2601 - more robust mechanism for disabling StartupFilter, based on the presence of a
disabling service

Added:
    sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
  (with props)
    sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
  (with props)
Removed:
    sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/Activator.java
Modified:
    sling/trunk/contrib/extensions/startup-filter-disabler/pom.xml
    sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java

Modified: sling/trunk/contrib/extensions/startup-filter-disabler/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/startup-filter-disabler/pom.xml?rev=1387008&r1=1387007&r2=1387008&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/startup-filter-disabler/pom.xml (original)
+++ sling/trunk/contrib/extensions/startup-filter-disabler/pom.xml Tue Sep 18 06:58:25 2012
@@ -31,7 +31,7 @@
 
   <name>Apache Sling Startup Filter Disabler</name>
   <description> 
-    The Activator of this bundle disables the Sling Startup Filter.
+    Registers a StartupFilterDisabler to disable the Sling Startup Filter.
     Configure this bundle with a high enough run level to remove the
     startup filter once the system is ready. 
   </description>
@@ -55,7 +55,6 @@
         <configuration>
           <instructions>
             <Private-Package>org.apache.sling.startupfilterdisabler.impl.*</Private-Package>
-            <Bundle-Activator>org.apache.sling.startupfilterdisabler.impl.Activator</Bundle-Activator>
           </instructions>
         </configuration>
       </plugin>
@@ -68,6 +67,10 @@
       <artifactId>org.osgi.core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>

Added: sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java?rev=1387008&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
(added)
+++ sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
Tue Sep 18 06:58:25 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.startupfilterdisabler.impl;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.startupfilter.StartupFilterDisabler;
+
+@Component
+@Service
+/** The StartupFilter will be disabled if this service is active. The idea
+ *  is to start the bundle that contains this service at a run level where
+ *  it is safe to let HTTP requests pass through. 
+ */
+public class StartupFilterDisablerImpl implements StartupFilterDisabler {
+
+    public String getReason() {
+        return this + " is active";
+    }
+
+}

Propchange: sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/extensions/startup-filter-disabler/src/main/java/org/apache/sling/startupfilterdisabler/impl/StartupFilterDisablerImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java?rev=1387008&view=auto
==============================================================================
--- sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
(added)
+++ sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
Tue Sep 18 06:58:25 2012
@@ -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();
+}

Propchange: sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/StartupFilterDisabler.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java?rev=1387008&r1=1387007&r2=1387008&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
(original)
+++ sling/trunk/contrib/extensions/startup-filter/src/main/java/org/apache/sling/startupfilter/impl/StartupFilterImpl.java
Tue Sep 18 06:58:25 2012
@@ -35,8 +35,12 @@ import org.apache.felix.scr.annotations.
 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 implement
     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();



Mime
View raw message