felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1056874 - /felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
Date Sun, 09 Jan 2011 03:05:26 GMT
Author: fmeschbe
Date: Sun Jan  9 03:05:26 2011
New Revision: 1056874

URL: http://svn.apache.org/viewvc?rev=1056874&view=rev
Log:
FELIX-1946: Only startup Jetty if either HTTP or HTTPS is enabled and improve messaging: If
Jetty is not started, say so. If Jetty is started report ports of enabled HTTP and HTTPS services.

Modified:
    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/JettyService.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java?rev=1056874&r1=1056873&r2=1056874&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
Sun Jan  9 03:05:26 2011
@@ -118,34 +118,54 @@ public final class JettyService
 
     private void stopJetty()
     {
-        try {
-            this.server.stop();
-        } catch (Exception e) {
-            SystemLogger.error("Exception while stopping Jetty.", e);
+        if (this.server != null)
+        {
+            try
+            {
+                this.server.stop();
+                this.server = null;
+            }
+            catch (Exception e)
+            {
+                SystemLogger.error("Exception while stopping Jetty.", e);
+            }
         }
     }
 
     private void initializeJetty()
         throws Exception
     {
-        HashUserRealm realm = new HashUserRealm("OSGi HTTP Service Realm");
-        this.server = new Server();
-        this.server.addUserRealm(realm);
+        if (this.config.isUseHttp() || this.config.isUseHttps())
+        {
+            StringBuffer message = new StringBuffer("Started jetty ").append(Server.getVersion()).append("
at port(s)");
+            HashUserRealm realm = new HashUserRealm("OSGi HTTP Service Realm");
+            this.server = new Server();
+            this.server.addUserRealm(realm);
 
-        if (this.config.isUseHttp()) {
-            initializeHttp();
-        }
+            if (this.config.isUseHttp())
+            {
+                initializeHttp();
+                message.append(" HTTP:").append(this.config.getHttpPort());
+            }
 
-        if (this.config.isUseHttps()) {
-            initializeHttps();
-        }
+            if (this.config.isUseHttps())
+            {
+                initializeHttps();
+                message.append(" HTTPS:").append(this.config.getHttpsPort());
+            }
+
+            Context context = new Context(this.server, "/", Context.SESSIONS);
+            context.addServlet(new ServletHolder(this.dispatcher), "/*");
 
-        Context context = new Context(this.server, "/", Context.SESSIONS);
-        context.addServlet(new ServletHolder(this.dispatcher), "/*");
+            this.server.start();
+            SystemLogger.info(message.toString());
+        }
+        else
+        {
+            SystemLogger.info("Jetty not started (HTTP and HTTPS disabled)");
+        }
 
-        this.server.start();
         publishServiceProperties();
-        SystemLogger.info("Started jetty " + Server.getVersion() + " at port " + this.config.getHttpPort());
     }
 
     private void initializeHttp()



Mime
View raw message