sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r1663879 - in /sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base: impl/Sling.java webapp/SlingBridge.java webapp/SlingServletDelegate.java
Date Wed, 04 Mar 2015 08:01:46 GMT
Author: cziegeler
Date: Wed Mar  4 08:01:45 2015
New Revision: 1663879

URL: http://svn.apache.org/r1663879
Log:
SLING-4390 : webapp deployment: properties in sling.properties overrule web.xml init parameters

Modified:
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingBridge.java
    sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java?rev=1663879&r1=1663878&r2=1663879&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
Wed Mar  4 08:01:45 2015
@@ -707,7 +707,7 @@ public class Sling {
      * object after the system bundle of the framework has been started and
      * before it is being stopped.
      */
-    protected final BundleContext getBundleContext() {
+    public final BundleContext getBundleContext() {
         return this.framework.getBundleContext();
     }
 

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingBridge.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingBridge.java?rev=1663879&r1=1663878&r2=1663879&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingBridge.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingBridge.java
Wed Mar  4 08:01:45 2015
@@ -28,18 +28,33 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
 
 /**
- * The <code>SlingBridge</code> extends the base <code>Sling</code>
class
- * calling the Eclipse Equinox Http Service activator for the proxy servlet to
- * be able to handle requests.
+ * The <code>SlingBridge</code> returns an extended <code>Sling</code>
class
+ * to override any sling properties with context init parameters from
+ * the web application.
+ * In addition, the bundle context is set as a servlet context attribute
  */
-public class SlingBridge extends Sling {
+public class SlingBridge {
 
-    public SlingBridge(Notifiable notifiable, Logger logger,
-            LaunchpadContentProvider resourceProvider, Map<String, String> propOverwrite,
-            ServletContext servletContext)
-            throws BundleException {
-        super(notifiable, logger, resourceProvider, propOverwrite);
-        
-        servletContext.setAttribute(BundleContext.class.getName(), getBundleContext());
+    public static Sling getSlingBridge(final Notifiable notifiable,
+            final Logger logger,
+            final LaunchpadContentProvider resourceProvider,
+            final Map<String, String> propOverwrite,
+            final ServletContext servletContext)
+    throws BundleException {
+        final Sling sling = new Sling(notifiable, logger, resourceProvider, propOverwrite)
{
+
+            @Override
+            protected void loadPropertiesOverride(final Map<String, String> properties)
{
+                if ( propOverwrite != null ) {
+                    properties.putAll(propOverwrite);
+                }
+            }
+
+        };
+
+        servletContext.setAttribute(BundleContext.class.getName(), sling.getBundleContext());
+
+        return sling;
     }
+
 }

Modified: sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java?rev=1663879&r1=1663878&r2=1663879&view=diff
==============================================================================
--- sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
(original)
+++ sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/webapp/SlingServletDelegate.java
Wed Mar  4 08:01:45 2015
@@ -46,6 +46,7 @@ import org.apache.sling.launchpad.base.s
 import org.apache.sling.launchpad.base.shared.SharedConstants;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceEvent;
 import org.osgi.framework.ServiceReference;
 
 /**
@@ -134,10 +135,10 @@ public class SlingServletDelegate extend
     private boolean servletDestroyed = false;
 
     /**
-     * The <code>Felix</code> instance loaded on {@link #init()} and stopped
+     * The OSGI framework instance loaded on {@link #init()} and stopped
      * on {@link #destroy()}.
      */
-    private SlingBridge sling;
+    private Sling sling;
 
     /**
      * The map of delegatee servlets to which requests are delegated. This map
@@ -156,23 +157,28 @@ public class SlingServletDelegate extend
 
     private String slingHome;
 
+    @Override
     public void setNotifiable(Notifiable notifiable) {
         this.notifiable = notifiable;
     }
 
+    @Override
     public void setCommandLine(Map<String, String> args) {
         this.properties = args;
     }
 
+    @Override
     public void setSlingHome(String slingHome) {
         this.slingHome = slingHome;
     }
 
+    @Override
     public boolean start() {
         // might want to log, why we don't start !
         return false;
     }
 
+    @Override
     public void stop() {
         destroy();
     }
@@ -185,10 +191,11 @@ public class SlingServletDelegate extend
      *
      * @throws ServletException if the framework cannot be initialized.
      */
+    @Override
     public final void init() throws ServletException {
         // temporary holders control final setup and ensure proper
         // disposal in case of setup errors
-        SlingBridge tmpSling = null;
+        Sling tmpSling = null;
         Servlet tmpDelegatee = null;
 
         try {
@@ -201,7 +208,7 @@ public class SlingServletDelegate extend
             Logger logger = new ServletContextLogger(getServletContext());
             LaunchpadContentProvider rp = new ServletContextResourceProvider(
                 getServletContext());
-            tmpSling = new SlingBridge(notifiable, logger, rp, props, getServletContext());
+            tmpSling = SlingBridge.getSlingBridge(notifiable, logger, rp, props, getServletContext());
 
             // set up the OSGi HttpService proxy servlet
             tmpDelegatee = new ProxyServlet();
@@ -267,6 +274,7 @@ public class SlingServletDelegate extend
      *             servlet's normal operation occurred
      * @throws IOException if an input or output exception occurs
      */
+    @Override
     public final void service(ServletRequest req, ServletResponse res)
             throws ServletException, IOException {
 
@@ -283,6 +291,7 @@ public class SlingServletDelegate extend
      * Destroys this servlet by shutting down the OSGi framework and hence the
      * delegatee servlet if one is set at all.
      */
+    @Override
     public final void destroy() {
 
         // set the destroyed flag to signal to the startSling method
@@ -520,6 +529,7 @@ public class SlingServletDelegate extend
             return resources.iterator(); // unchecked
         }
 
+        @Override
         public URL getResource(String path) {
             // nothing for empty or null path
             if (path == null || path.length() == 0) {



Mime
View raw message