felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s..@apache.org
Subject svn commit: r818555 - in /felix/trunk/http: base/src/main/java/org/apache/felix/http/base/internal/ base/src/main/java/org/apache/felix/http/base/internal/context/ base/src/main/java/org/apache/felix/http/base/internal/logger/ base/src/main/java/org/ap...
Date Thu, 24 Sep 2009 17:20:31 GMT
Author: srs
Date: Thu Sep 24 17:20:25 2009
New Revision: 818555

URL: http://svn.apache.org/viewvc?rev=818555&view=rev
Log:
Added more robust logging.

Added:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractHttpActivator.java
      - copied, changed from r818502, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/AbstractLogger.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/ConsoleLogger.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/LogServiceLogger.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/NopLogger.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/SystemLogger.java
Removed:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/util/SystemLogger.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/util/
Modified:
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextManager.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
    felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
    felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
    felix/trunk/http/bundle/pom.xml
    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/JettyLogger.java
    felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyService.java
    felix/trunk/http/whiteboard/pom.xml
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerImpl.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpContextManager.java
    felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
Thu Sep 24 17:20:25 2009
@@ -18,38 +18,26 @@
 
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
-import org.apache.felix.http.base.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
+import org.apache.felix.http.base.internal.logger.LogServiceLogger;
 
 public abstract class AbstractActivator
     implements BundleActivator
 {
     private BundleContext context;
-    private DispatcherServlet dispatcher;
-    private HttpServiceController controller;
+    private LogServiceLogger logger;
 
     protected final BundleContext getBundleContext()
     {
         return this.context;
     }
 
-    protected final DispatcherServlet getDispatcherServlet()
-    {
-        return this.dispatcher;
-    }
-
-    protected final HttpServiceController getHttpServiceController()
-    {
-        return this.controller;
-    }
-
     public final void start(BundleContext context)
         throws Exception
     {
         this.context = context;
-        this.controller = new HttpServiceController(this.context);
-        this.dispatcher = new DispatcherServlet(this.controller);
-
-        SystemLogger.get().open(context);
+        this.logger = new LogServiceLogger(context);
+        SystemLogger.setLogService(this.logger);
         doStart();
     }
 
@@ -57,10 +45,7 @@
         throws Exception
     {
         doStop();
-
-        this.controller.unregister();
-        this.dispatcher.destroy();
-        SystemLogger.get().close();
+        this.logger.close();
     }
 
     protected abstract void doStart()

Copied: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractHttpActivator.java
(from r818502, felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java)
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractHttpActivator.java?p2=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractHttpActivator.java&p1=felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java&r1=818502&r2=818555&rev=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractActivator.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/AbstractHttpActivator.java
Thu Sep 24 17:20:25 2009
@@ -16,22 +16,12 @@
  */
 package org.apache.felix.http.base.internal;
 
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.apache.felix.http.base.internal.util.SystemLogger;
-
-public abstract class AbstractActivator
-    implements BundleActivator
+public abstract class AbstractHttpActivator
+    extends AbstractActivator
 {
-    private BundleContext context;
     private DispatcherServlet dispatcher;
     private HttpServiceController controller;
 
-    protected final BundleContext getBundleContext()
-    {
-        return this.context;
-    }
-
     protected final DispatcherServlet getDispatcherServlet()
     {
         return this.dispatcher;
@@ -42,30 +32,17 @@
         return this.controller;
     }
 
-    public final void start(BundleContext context)
+    protected void doStart()
         throws Exception
     {
-        this.context = context;
-        this.controller = new HttpServiceController(this.context);
+        this.controller = new HttpServiceController(getBundleContext());
         this.dispatcher = new DispatcherServlet(this.controller);
-
-        SystemLogger.get().open(context);
-        doStart();
     }
 
-    public final void stop(BundleContext context)
+    protected void doStop()
         throws Exception
     {
-        doStop();
-
         this.controller.unregister();
         this.dispatcher.destroy();
-        SystemLogger.get().close();
     }
-
-    protected abstract void doStart()
-        throws Exception;
-
-    protected abstract void doStop()
-        throws Exception;   
 }

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextImpl.java
Thu Sep 24 17:20:25 2009
@@ -19,7 +19,7 @@
 import org.osgi.service.http.HttpContext;
 import org.osgi.framework.Bundle;
 import org.apache.felix.http.base.internal.util.MimeTypes;
-import org.apache.felix.http.base.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 
 import javax.servlet.ServletContext;
 import javax.servlet.RequestDispatcher;
@@ -178,17 +178,17 @@
 
     public void log(String message)
     {
-        SystemLogger.get().info(message);
+        SystemLogger.info(message);
     }
 
     public void log(Exception cause, String message)
     {
-        SystemLogger.get().error(message, cause);
+        SystemLogger.error(message, cause);
     }
 
     public void log(String message, Throwable cause)
     {
-        SystemLogger.get().error(message, cause);
+        SystemLogger.error(message, cause);
     }
 
     public String getServletContextName()

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextManager.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextManager.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/context/ServletContextManager.java
Thu Sep 24 17:20:25 2009
@@ -18,7 +18,6 @@
 
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpContext;
-
 import javax.servlet.ServletContext;
 import java.util.Map;
 import java.util.HashMap;

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/AbstractLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/AbstractLogger.java?rev=818555&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/AbstractLogger.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/AbstractLogger.java
Thu Sep 24 17:20:25 2009
@@ -0,0 +1,23 @@
+package org.apache.felix.http.base.internal.logger;
+
+import org.osgi.service.log.LogService;
+import org.osgi.framework.ServiceReference;
+
+public abstract class AbstractLogger
+    implements LogService
+{
+    public final void log(int level, String message)
+    {
+        log(null, level, message, null);
+    }
+
+    public final void log(int level, String message, Throwable cause)
+    {
+        log(null, level, message, cause);
+    }
+
+    public final void log(ServiceReference ref, int level, String message)
+    {
+        log(ref, level, message, null);
+    }
+}

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/ConsoleLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/ConsoleLogger.java?rev=818555&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/ConsoleLogger.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/ConsoleLogger.java
Thu Sep 24 17:20:25 2009
@@ -0,0 +1,49 @@
+package org.apache.felix.http.base.internal.logger;
+
+import org.osgi.framework.ServiceReference;
+import java.io.PrintStream;
+
+public final class ConsoleLogger
+    extends AbstractLogger
+{
+    private final PrintStream out;
+
+    public ConsoleLogger()
+    {
+        this(System.out);
+    }
+
+    public ConsoleLogger(PrintStream out)
+    {
+        this.out = out;
+    }
+
+    public void log(ServiceReference ref, int level, String message, Throwable cause)
+    {
+        StringBuffer str = new StringBuffer();
+        switch (level) {
+            case LOG_DEBUG:
+                str.append("[DEBUG] ");
+                break;
+            case LOG_INFO:
+                str.append("[INFO] ");
+                break;
+            case LOG_WARNING:
+                str.append("[WARNING] ");
+                break;
+            case LOG_ERROR:
+                str.append("[ERROR] ");
+                break;
+        }
+
+        if (ref != null) {
+            str.append("(").append(ref.toString()).append(") ");
+        }
+
+        str.append(message);
+        this.out.println(str.toString());
+        if (cause != null) {
+            cause.printStackTrace(this.out);
+        }
+    }
+}

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/LogServiceLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/LogServiceLogger.java?rev=818555&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/LogServiceLogger.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/LogServiceLogger.java
Thu Sep 24 17:20:25 2009
@@ -0,0 +1,35 @@
+package org.apache.felix.http.base.internal.logger;
+
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+public final class LogServiceLogger
+    extends AbstractLogger
+{
+    private final ConsoleLogger consoleLogger;
+    private final ServiceTracker tracker;
+
+    public LogServiceLogger(BundleContext context)
+    {
+        this.consoleLogger = new ConsoleLogger();
+        this.tracker = new ServiceTracker(context, LogService.class.getName(), null);
+        this.tracker.open();
+    }
+
+    public void close()
+    {
+        this.tracker.close();
+    }
+
+    public void log(ServiceReference ref, int level, String message, Throwable cause)
+    {
+        LogService log = (LogService)this.tracker.getService();
+        if (log != null) {
+            log.log(ref, level, message, cause);
+        } else {
+            this.consoleLogger.log(ref, level, message, cause);
+        }
+    }
+}

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/NopLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/NopLogger.java?rev=818555&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/NopLogger.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/NopLogger.java
Thu Sep 24 17:20:25 2009
@@ -0,0 +1,12 @@
+package org.apache.felix.http.base.internal.logger;
+
+import org.osgi.framework.ServiceReference;
+
+public final class NopLogger
+    extends AbstractLogger
+{
+    public void log(ServiceReference ref, int level, String message, Throwable cause)
+    {
+        // Do nothing
+    }
+}

Added: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/SystemLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/SystemLogger.java?rev=818555&view=auto
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/SystemLogger.java
(added)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/logger/SystemLogger.java
Thu Sep 24 17:20:25 2009
@@ -0,0 +1,41 @@
+package org.apache.felix.http.base.internal.logger;
+
+import org.osgi.service.log.LogService;
+
+public final class SystemLogger
+{
+    private final static LogService NOP = new NopLogger();
+    private static LogService LOGGER;
+
+    public static void setLogService(LogService service)
+    {
+        if (LOGGER == null) {
+            LOGGER = service;
+        }
+    }
+
+    private static LogService getLogger()
+    {
+        return LOGGER != null ? LOGGER : NOP;
+    }
+    
+    public static void debug(String message)
+    {
+        getLogger().log(LogService.LOG_DEBUG, message);
+    }
+
+    public static void info(String message)
+    {
+        getLogger().log(LogService.LOG_INFO, message);
+    }
+
+    public static void warning(String message, Throwable cause)
+    {
+        getLogger().log(LogService.LOG_WARNING, message, cause);
+    }
+
+    public static void error(String message, Throwable cause)
+    {
+        getLogger().log(LogService.LOG_ERROR, message, cause);
+    }
+}

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceFactory.java
Thu Sep 24 17:20:25 2009
@@ -20,7 +20,6 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceRegistration;
 import org.apache.felix.http.base.internal.handler.HandlerRegistry;
-
 import javax.servlet.ServletContext;
 
 public final class HttpServiceFactory
@@ -37,7 +36,7 @@
 
     public Object getService(Bundle bundle, ServiceRegistration reg)
     {
-        return new HttpServiceImpl(this.context, this.handlerRegistry, bundle);
+        return new HttpServiceImpl(bundle, this.context, this.handlerRegistry);
     }
 
     public void ungetService(Bundle bundle, ServiceRegistration reg, Object service)

Modified: felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
(original)
+++ felix/trunk/http/base/src/main/java/org/apache/felix/http/base/internal/service/HttpServiceImpl.java
Thu Sep 24 17:20:25 2009
@@ -22,7 +22,7 @@
 import org.apache.felix.http.base.internal.handler.HandlerRegistry;
 import org.apache.felix.http.base.internal.handler.FilterHandler;
 import org.apache.felix.http.base.internal.handler.ServletHandler;
-import org.apache.felix.http.base.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import org.osgi.service.http.HttpContext;
 import org.osgi.service.http.NamespaceException;
 import org.osgi.framework.Bundle;
@@ -42,13 +42,13 @@
     private final HashSet<Filter> localFilters;
     private final ServletContextManager contextManager;
 
-    public HttpServiceImpl(ServletContext context, HandlerRegistry handlerRegistry, Bundle
bundle)
+    public HttpServiceImpl(Bundle bundle, ServletContext context, HandlerRegistry handlerRegistry)
     {
         this.bundle = bundle;
         this.handlerRegistry = handlerRegistry;
         this.localServlets = new HashSet<Servlet>();
         this.localFilters = new HashSet<Filter>();
-        this.contextManager = new ServletContextManager(bundle, context);
+        this.contextManager = new ServletContextManager(this.bundle, context);
     }
 
     private ExtServletContext getServletContext(HttpContext context)
@@ -109,7 +109,7 @@
             Servlet servlet = new ResourceServlet(name);
             registerServlet(alias, servlet, null, context);
         } catch (ServletException e) {
-            SystemLogger.get().error("Failed to register resources", e);
+            SystemLogger.error("Failed to register resources", e);
         }
     }
 

Modified: felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
(original)
+++ felix/trunk/http/bridge/src/main/java/org/apache/felix/http/bridge/internal/BridgeActivator.java
Thu Sep 24 17:20:25 2009
@@ -18,24 +18,20 @@
 
 import javax.servlet.http.HttpServlet;
 import java.util.Hashtable;
-import org.apache.felix.http.base.internal.AbstractActivator;
+import org.apache.felix.http.base.internal.AbstractHttpActivator;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 
 public final class BridgeActivator
-    extends AbstractActivator
+    extends AbstractHttpActivator
 {
     @Override
     protected void doStart()
         throws Exception
     {
+        super.doStart();
         Hashtable<String, Object> props = new Hashtable<String, Object>();
         props.put("http.felix.dispatcher", getDispatcherServlet().getClass().getName());
         getBundleContext().registerService(HttpServlet.class.getName(), getDispatcherServlet(),
props);
-    }
-
-    @Override
-    protected void doStop()
-        throws Exception
-    {
-        // Do nothing
+        SystemLogger.info("Started bridged http service");
     }
 }

Modified: felix/trunk/http/bundle/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/bundle/pom.xml?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/bundle/pom.xml (original)
+++ felix/trunk/http/bundle/pom.xml Thu Sep 24 17:20:25 2009
@@ -27,7 +27,7 @@
         <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <name>Apache Felix Http Bridge</name>
+    <name>Apache Felix Http Bundle</name>
     <artifactId>org.apache.felix.http.bundle</artifactId>
     <packaging>bundle</packaging>
 

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=818555&r1=818554&r2=818555&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
Thu Sep 24 17:20:25 2009
@@ -16,16 +16,17 @@
  */
 package org.apache.felix.http.jetty.internal;
 
-import org.apache.felix.http.base.internal.AbstractActivator;
+import org.apache.felix.http.base.internal.AbstractHttpActivator;
 
 public final class JettyActivator
-    extends AbstractActivator 
+    extends AbstractHttpActivator 
 {
     private JettyService jetty;
 
     protected void doStart()
         throws Exception
     {
+        super.doStart();
         this.jetty = new JettyService(getBundleContext(), getDispatcherServlet());
         this.jetty.start();
     }
@@ -34,5 +35,6 @@
         throws Exception
     {
         this.jetty.stop();
+        super.doStop();
     }
 }

Modified: felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
(original)
+++ felix/trunk/http/jetty/src/main/java/org/apache/felix/http/jetty/internal/JettyLogger.java
Thu Sep 24 17:20:25 2009
@@ -17,8 +17,7 @@
 package org.apache.felix.http.jetty.internal;
 
 import org.mortbay.log.Logger;
-import org.apache.felix.http.base.internal.util.SystemLogger;
-
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import java.util.Map;
 import java.util.HashMap;
 
@@ -65,27 +64,27 @@
 
     public void debug(String msg, Throwable cause)
     {
-        SystemLogger.get().debug(msg);
+        SystemLogger.debug(msg);
     }
 
     public void debug(String msg, Object arg0, Object arg1)
     {
-        SystemLogger.get().debug(format(msg, arg0, arg1));
+        SystemLogger.debug(format(msg, arg0, arg1));
     }
 
     public void info(String msg, Object arg0, Object arg1)
     {
-        SystemLogger.get().info(format(msg, arg0, arg1));
+        SystemLogger.info(format(msg, arg0, arg1));
     }
 
     public void warn(String msg, Throwable cause)
     {
-        SystemLogger.get().warning(msg, cause);
+        SystemLogger.warning(msg, cause);
     }
 
     public void warn( String msg, Object arg0, Object arg1 )
     {
-        SystemLogger.get().warning(format(msg, arg0, arg1), null);
+        SystemLogger.warning(format(msg, arg0, arg1), null);
     }
 
     public String toString()

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=818555&r1=818554&r2=818555&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
Thu Sep 24 17:20:25 2009
@@ -29,8 +29,9 @@
 import org.mortbay.jetty.servlet.*;
 import org.mortbay.log.Log;
 import org.mortbay.log.StdErrLog;
-import org.apache.felix.http.base.internal.util.SystemLogger;
 import org.apache.felix.http.base.internal.DispatcherServlet;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
+
 import java.util.Properties;
 import java.util.Dictionary;
 
@@ -99,7 +100,7 @@
         try {
             initializeJetty();
         } catch (Exception e) {
-            SystemLogger.get().error("Exception while initializing Jetty.", e);
+            SystemLogger.error("Exception while initializing Jetty.", e);
         }
     }
 
@@ -108,7 +109,7 @@
         try {
             this.server.stop();
         } catch (Exception e) {
-            SystemLogger.get().error("Exception while stopping Jetty.", e);
+            SystemLogger.error("Exception while stopping Jetty.", e);
         }
     }
 

Modified: felix/trunk/http/whiteboard/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/pom.xml?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/pom.xml (original)
+++ felix/trunk/http/whiteboard/pom.xml Thu Sep 24 17:20:25 2009
@@ -42,6 +42,7 @@
                             org.apache.felix.http.whiteboard.internal.WhiteboardActivator
                         </Bundle-Activator>
                         <Private-Package>
+                            org.apache.felix.http.base.*,
                             org.apache.felix.http.whiteboard.*
                         </Private-Package>
                         <Import-Package>
@@ -72,6 +73,12 @@
             <version>${pom.version}</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>${pom.groupId}</groupId>
+            <artifactId>org.apache.felix.http.base</artifactId>
+            <version>${pom.version}</version>
+            <scope>provided</scope>
+        </dependency>        
     </dependencies>
 
 </project>

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/WhiteboardActivator.java
Thu Sep 24 17:20:25 2009
@@ -16,8 +16,6 @@
  */
 package org.apache.felix.http.whiteboard.internal;
 
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
 import org.osgi.util.tracker.ServiceTracker;
 import org.apache.felix.http.whiteboard.internal.tracker.FilterTracker;
 import org.apache.felix.http.whiteboard.internal.tracker.HttpContextTracker;
@@ -25,11 +23,11 @@
 import org.apache.felix.http.whiteboard.internal.tracker.HttpServiceTracker;
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManagerImpl;
 import org.apache.felix.http.whiteboard.internal.manager.ExtenderManager;
-import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.AbstractActivator;
 import java.util.ArrayList;
 
 public final class WhiteboardActivator
-    implements BundleActivator
+    extends AbstractActivator
 {
     private final ArrayList<ServiceTracker> trackers;
     private ExtenderManager manager;
@@ -39,15 +37,14 @@
         this.trackers = new ArrayList<ServiceTracker>();
     }
 
-    public void start(BundleContext context)
+    protected void doStart()
         throws Exception
     {
-        SystemLogger.get().open(context);
         this.manager = new ExtenderManagerImpl();
-        addTracker(new HttpContextTracker(context, this.manager));
-        addTracker(new FilterTracker(context, this.manager));
-        addTracker(new ServletTracker(context, this.manager));
-        addTracker(new HttpServiceTracker(context, this.manager));
+        addTracker(new HttpContextTracker(getBundleContext(), this.manager));
+        addTracker(new FilterTracker(getBundleContext(), this.manager));
+        addTracker(new ServletTracker(getBundleContext(), this.manager));
+        addTracker(new HttpServiceTracker(getBundleContext(), this.manager));
     }
 
     private void addTracker(ServiceTracker tracker)
@@ -56,7 +53,7 @@
         tracker.open();
     }
 
-    public void stop(BundleContext context)
+    protected void doStop()
         throws Exception
     {
         for (ServiceTracker tracker : this.trackers) {
@@ -65,6 +62,5 @@
 
         this.trackers.clear();
         this.manager.unregisterAll();
-        SystemLogger.get().close();
     }
 }

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerImpl.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerImpl.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ExtenderManagerImpl.java
Thu Sep 24 17:20:25 2009
@@ -22,7 +22,7 @@
 import org.osgi.framework.Bundle;
 import org.osgi.framework.Constants;
 import org.apache.felix.http.api.ExtHttpService;
-import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 
 import javax.servlet.Servlet;
 import javax.servlet.Filter;
@@ -141,9 +141,9 @@
     {
         this.httpService = service;
         if (this.httpService instanceof ExtHttpService) {
-            SystemLogger.get().info("Detected extended HttpService. Filters enabled.");
+            SystemLogger.info("Detected extended HttpService. Filters enabled.");
         } else {
-            SystemLogger.get().info("Standard HttpService. Filters disabled.");
+            SystemLogger.info("Standard HttpService. Filters disabled.");
         }
 
         registerAll();

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/FilterMapping.java
Thu Sep 24 17:20:25 2009
@@ -19,7 +19,8 @@
 import org.osgi.service.http.HttpService;
 import org.osgi.service.http.HttpContext;
 import org.apache.felix.http.api.ExtHttpService;
-import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
+
 import javax.servlet.Filter;
 
 public final class FilterMapping
@@ -49,7 +50,7 @@
         try {
             httpService.registerFilter(this.filter, this.pattern, getInitParams(), ranking,
getContext());
         } catch (Exception e) {
-            SystemLogger.get().error("Failed to register filter", e);
+            SystemLogger.error("Failed to register filter", e);
         }
     }
 

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpContextManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpContextManager.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpContextManager.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/HttpContextManager.java
Thu Sep 24 17:20:25 2009
@@ -18,7 +18,7 @@
 
 import org.osgi.framework.Bundle;
 import org.osgi.service.http.HttpContext;
-import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
 import java.util.HashMap;
 
 public final class HttpContextManager
@@ -46,9 +46,9 @@
             context = new DefaultHttpContext(bundle);
             this.idMap.put(id, context);
             this.contextMap.put(context, id);
-            SystemLogger.get().debug("Added context with id [" + contextId + "]");
+            SystemLogger.debug("Added context with id [" + contextId + "]");
         } else {
-            SystemLogger.get().debug("Reusing context with id [" + contextId + "]");    
       
+            SystemLogger.debug("Reusing context with id [" + contextId + "]");          
 
         }
 
         return context;

Modified: felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
URL: http://svn.apache.org/viewvc/felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java?rev=818555&r1=818554&r2=818555&view=diff
==============================================================================
--- felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
(original)
+++ felix/trunk/http/whiteboard/src/main/java/org/apache/felix/http/whiteboard/internal/manager/ServletMapping.java
Thu Sep 24 17:20:25 2009
@@ -18,7 +18,8 @@
 
 import org.osgi.service.http.HttpService;
 import org.osgi.service.http.HttpContext;
-import org.apache.felix.http.whiteboard.internal.util.SystemLogger;
+import org.apache.felix.http.base.internal.logger.SystemLogger;
+
 import javax.servlet.Servlet;
 
 public final class ServletMapping
@@ -39,7 +40,7 @@
         try {
             httpService.registerServlet(this.alias, this.servlet, getInitParams(), getContext());
         } catch (Exception e) {
-            SystemLogger.get().error("Failed to register servlet", e);
+            SystemLogger.error("Failed to register servlet", e);
         }
     }
 



Mime
View raw message