FELIX-1704: Added exporting of service properties in Jetty service.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@830782 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
index 791045e..0778de9 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyActivator.java
@@ -27,7 +27,7 @@
         throws Exception
     {
         super.doStart();
-        this.jetty = new JettyService(getBundleContext(), getDispatcherServlet());
+        this.jetty = new JettyService(getBundleContext(), getDispatcherServlet(), getHttpServiceController());
         this.jetty.start();
     }
 
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
index 3251331..194af16 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyConfig.java
@@ -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));
+    }
 }
diff --git a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
index 2e71b07..d7fcee0 100644
--- a/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
+++ b/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
@@ -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());
     }