You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by sr...@apache.org on 2009/10/28 23:26:09 UTC

svn commit: r830782 - in /felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal: JettyActivator.java JettyConfig.java JettyService.java

Author: srs
Date: Wed Oct 28 22:26:09 2009
New Revision: 830782

URL: http://svn.apache.org/viewvc?rev=830782&view=rev
Log:
FELIX-1704: Added exporting of service properties in Jetty service.

Modified:
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java?rev=830782&r1=830781&r2=830782&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java Wed Oct 28 22:26:09 2009
@@ -27,7 +27,7 @@
         throws Exception
     {
         super.doStart();
-        this.jetty = new JettyService(getBundleContext(), getDispatcherServlet());
+        this.jetty = new JettyService(getBundleContext(), getDispatcherServlet(), getHttpServiceController());
         this.jetty.start();
     }
 

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java?rev=830782&r1=830781&r2=830782&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java Wed Oct 28 22:26:09 2009
@@ -19,6 +19,7 @@
 import org.osgi.framework.BundleContext;
 import java.util.Dictionary;
 import java.util.Properties;
+import java.util.Hashtable;
 
 public final class JettyConfig
 {
@@ -46,7 +47,7 @@
 
     /** Felix specific property to control whether to enable HTTPS. */
     private static final String FELIX_HTTPS_ENABLE = "org.apache.felix.https.enable";
-    private static final String  OSCAR_HTTPS_ENABLE   = "org.ungoverned.osgi.bundle.https.enable";
+    private static final String OSCAR_HTTPS_ENABLE   = "org.ungoverned.osgi.bundle.https.enable";
 
     /** Felix specific property to control whether to enable HTTP. */
     private static final String FELIX_HTTP_ENABLE = "org.apache.felix.http.enable";
@@ -186,4 +187,12 @@
             return defValue;
         }
     }
+
+    public void setServiceProperties(Hashtable<String, Object> props)
+    {
+        props.put(HTTP_PORT, String.valueOf(this.httpPort));
+        props.put(HTTPS_PORT, String.valueOf(this.httpsPort));
+        props.put(FELIX_HTTP_ENABLE, String.valueOf(this.useHttp));
+        props.put(FELIX_HTTPS_ENABLE, String.valueOf(this.useHttps));
+    }
 }

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=830782&r1=830781&r2=830782&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java (original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java Wed Oct 28 22:26:09 2009
@@ -29,10 +29,12 @@
 import org.mortbay.jetty.servlet.*;
 import org.mortbay.log.Log;
 import org.apache.felix.http.base.internal.DispatcherServlet;
+import org.apache.felix.http.base.internal.HttpServiceController;
 import org.apache.felix.http.base.internal.logger.SystemLogger;
 
 import java.util.Properties;
 import java.util.Dictionary;
+import java.util.Hashtable;
 
 public final class JettyService
     implements ManagedService, Runnable
@@ -47,12 +49,14 @@
     private ServiceRegistration configServiceReg;
     private Server server;
     private DispatcherServlet dispatcher;
+    private final HttpServiceController controller;
 
-    public JettyService(BundleContext context, DispatcherServlet dispatcher)
+    public JettyService(BundleContext context, DispatcherServlet dispatcher, HttpServiceController controller)
     {
         this.context = context;
         this.config = new JettyConfig(this.context);
         this.dispatcher = dispatcher;
+        this.controller = controller;
     }
     
     public void start()
@@ -85,10 +89,18 @@
         }
     }
 
+    private void publishServiceProperties()
+    {
+        Hashtable<String, Object> props = new Hashtable<String, Object>();
+        this.config.setServiceProperties(props);
+        this.controller.setProperties(props);
+    }
+
     public void updated(Dictionary props)
         throws ConfigurationException
     {
         this.config.update(props);
+
         if (this.running && (this.thread != null)) {
             this.thread.interrupt();
         }
@@ -131,6 +143,7 @@
         context.addServlet(new ServletHolder(this.dispatcher), "/*");
 
         this.server.start();
+        publishServiceProperties();
         SystemLogger.info("Started jetty " + Server.getVersion() + " at port " + this.config.getHttpPort());
     }