[jboss-osgi-commits] JBoss-OSGI SVN: r91507 - in projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky: runtime/osgi and 1 other directory.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Jul 21 15:30:45 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-07-21 15:30:45 -0400 (Tue, 21 Jul 2009)
New Revision: 91507

Added:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java
Removed:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java
Modified:
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
   projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
Log:
Remove duplicate LogServiceTracker reference

Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java (from rev 91504, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskyLogService.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.husky.internal;
+
+//$Id$
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+import org.osgi.util.tracker.ServiceTracker;
+
+/**
+ * A combined ServiceTracker/LogService that bundles can use to access the registered LogService.
+ * 
+ * If a LogService is registered, the LogServiceTracker delegates to that LogService.
+ * If there is no LogService registered, the LogServiceTracker delegates to the {@link HuskySystemLog} 
+ * 
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 11-Apr-2009
+ */
+public class HuskyLogService extends ServiceTracker implements LogService
+{
+   private LogService log;
+   
+   public HuskyLogService(BundleContext context)
+   {
+      super(context, LogService.class.getName(), null);
+      log = new HuskySystemLog(context);
+      open();
+   }
+
+   @Override
+   public Object addingService(ServiceReference reference)
+   {
+      log = (LogService)super.addingService(reference);
+      return log;
+   }
+
+   @Override
+   public void removedService(ServiceReference reference, Object service)
+   {
+      super.removedService(reference, service);
+      log = new HuskySystemLog(context);
+   }
+
+   public void log(int level, String message)
+   {
+      log.log(level, message);
+   }
+
+   public void log(int level, String message, Throwable exception)
+   {
+      log.log(level, message, exception);
+   }
+
+   public void log(ServiceReference sr, int level, String message)
+   {
+      log.log(sr, level, message);
+   }
+
+   public void log(ServiceReference sr, int level, String message, Throwable exception)
+   {
+      log.log(sr, level, message, exception);
+   }
+}
\ No newline at end of file

Copied: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java (from rev 91504, projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java)
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java	                        (rev 0)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/HuskySystemLog.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -0,0 +1,115 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.osgi.husky.internal;
+
+//$Id$
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.log.LogService;
+
+/**
+ * A basic LogService that writes to System.out
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 11-Apr-2009
+ */
+class HuskySystemLog implements LogService
+{
+   private BundleContext context;
+   
+   public HuskySystemLog(BundleContext context)
+   {
+      this.context = context;
+   }
+
+   public void log(int level, String message)
+   {
+      logInternal(null, level, message, null);
+   }
+
+   public void log(int level, String message, Throwable exception)
+   {
+      logInternal(null, level, message, exception);
+   }
+
+   public void log(ServiceReference sr, int level, String message)
+   {
+      logInternal(sr, level, message, null);
+   }
+
+   public void log(ServiceReference sr, int level, String message, Throwable exception)
+   {
+      logInternal(sr, level, message, exception);
+   }
+
+   private void logInternal(ServiceReference sref, int level, String message, Throwable exception)
+   {
+      long time = System.currentTimeMillis();
+      Bundle bundle = context.getBundle();
+      
+      String bndStr = bundle.getSymbolicName();
+      
+      String srefStr = null;
+      if (sref != null && sref.getBundle() != null)
+         srefStr = sref.getBundle().getSymbolicName();
+      
+      String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
+      String l = " " + logLevel(level);
+      String s = srefStr != null ? ",sref=" + srefStr : "";
+      String b = ",bnd=" + bndStr;
+      String m = ",msg=" + message;
+      String e = exception != null ? ",ex=" + exception : "";
+      
+      System.out.println("[" + t + l + b + s + m + e + "]");
+
+      if (exception != null)
+         exception.printStackTrace(System.out);
+   }
+
+   private String logLevel(int level)
+   {
+      String logLevel;
+      switch (level)
+      {
+         case LogService.LOG_DEBUG:
+            logLevel = "DEBUG";
+            break;
+         case LogService.LOG_INFO:
+            logLevel = "INFO";
+            break;
+         case LogService.LOG_WARNING:
+            logLevel = "WARN";
+            break;
+         case LogService.LOG_ERROR:
+            logLevel = "ERROR";
+            break;
+         default:
+            logLevel = "Level=" + level;
+      }
+      return logLevel;
+   }
+}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java	2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/LogServiceTracker.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.husky.internal;
-
-//$Id$
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-import org.osgi.util.tracker.ServiceTracker;
-
-/**
- * A combined ServiceTracker/LogService that bundles can use to access the registered LogService.
- * 
- * If a LogService is registered, the LogServiceTracker delegates to that LogService.
- * If there is no LogService registered, the LogServiceTracker delegates to the {@link SystemLogService} 
- * 
- * 
- * @author thomas.diesler at jboss.com
- * @since 11-Apr-2009
- */
-public class LogServiceTracker extends ServiceTracker implements LogService
-{
-   private LogService log;
-   
-   public LogServiceTracker(BundleContext context)
-   {
-      super(context, LogService.class.getName(), null);
-      log = new SystemLogService(context);
-      open();
-   }
-
-   @Override
-   public Object addingService(ServiceReference reference)
-   {
-      log = (LogService)super.addingService(reference);
-      return log;
-   }
-
-   @Override
-   public void removedService(ServiceReference reference, Object service)
-   {
-      super.removedService(reference, service);
-      log = new SystemLogService(context);
-   }
-
-   public void log(int level, String message)
-   {
-      log.log(level, message);
-   }
-
-   public void log(int level, String message, Throwable exception)
-   {
-      log.log(level, message, exception);
-   }
-
-   public void log(ServiceReference sr, int level, String message)
-   {
-      log.log(sr, level, message);
-   }
-
-   public void log(ServiceReference sr, int level, String message, Throwable exception)
-   {
-      log.log(sr, level, message, exception);
-   }
-}
\ No newline at end of file

Deleted: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java	2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/internal/SystemLogService.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.osgi.husky.internal;
-
-//$Id$
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.log.LogService;
-
-/**
- * A basic LogService that writes to System.out
- * 
- * @author thomas.diesler at jboss.com
- * @since 11-Apr-2009
- */
-public class SystemLogService implements LogService
-{
-   private BundleContext context;
-   
-   public SystemLogService(BundleContext context)
-   {
-      this.context = context;
-   }
-
-   public void log(int level, String message)
-   {
-      logInternal(null, level, message, null);
-   }
-
-   public void log(int level, String message, Throwable exception)
-   {
-      logInternal(null, level, message, exception);
-   }
-
-   public void log(ServiceReference sr, int level, String message)
-   {
-      logInternal(sr, level, message, null);
-   }
-
-   public void log(ServiceReference sr, int level, String message, Throwable exception)
-   {
-      logInternal(sr, level, message, exception);
-   }
-
-   private void logInternal(ServiceReference sref, int level, String message, Throwable exception)
-   {
-      long time = System.currentTimeMillis();
-      Bundle bundle = context.getBundle();
-      
-      String bndStr = bundle.getSymbolicName();
-      
-      String srefStr = null;
-      if (sref != null && sref.getBundle() != null)
-         srefStr = sref.getBundle().getSymbolicName();
-      
-      String t = new SimpleDateFormat("dd-MMM-yyyy HH:mm.ss.SSS").format(new Date(time));
-      String l = " " + logLevel(level);
-      String s = srefStr != null ? ",sref=" + srefStr : "";
-      String b = ",bnd=" + bndStr;
-      String m = ",msg=" + message;
-      String e = exception != null ? ",ex=" + exception : "";
-      
-      System.out.println("[" + t + l + b + s + m + e + "]");
-
-      if (exception != null)
-         exception.printStackTrace(System.out);
-   }
-
-   private String logLevel(int level)
-   {
-      String logLevel;
-      switch (level)
-      {
-         case LogService.LOG_DEBUG:
-            logLevel = "DEBUG";
-            break;
-         case LogService.LOG_INFO:
-            logLevel = "INFO";
-            break;
-         case LogService.LOG_WARNING:
-            logLevel = "WARN";
-            break;
-         case LogService.LOG_ERROR:
-            logLevel = "ERROR";
-            break;
-         default:
-            logLevel = "Level=" + level;
-      }
-      return logLevel;
-   }
-}
\ No newline at end of file

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java	2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/HuskyExtender.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -27,7 +27,7 @@
 import java.util.Arrays;
 import java.util.List;
 
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
 import org.jboss.osgi.husky.runtime.Connector;
 import org.jboss.osgi.husky.runtime.PackageListener;
 import org.jboss.osgi.husky.runtime.junit.JUnitPackageListener;
@@ -56,7 +56,7 @@
 
    public HuskyExtender(BundleContext context)
    {
-      this.log = new LogServiceTracker(context);
+      this.log = new HuskyLogService(context);
       this.context = context;
    }
 

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/JMXConnector.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -31,7 +31,7 @@
 import javax.management.ObjectName;
 
 import org.jboss.osgi.husky.internal.AbstractConnector;
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
 import org.jboss.osgi.husky.runtime.Connector;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -68,7 +68,7 @@
 
    public JMXConnector(BundleContext context)
    {
-      this.log = new LogServiceTracker(context);
+      this.log = new HuskyLogService(context);
       this.context = context;
    }
 

Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java	2009-07-21 19:27:55 UTC (rev 91506)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/husky/runtime/osgi/SocketConnector.java	2009-07-21 19:30:45 UTC (rev 91507)
@@ -31,7 +31,7 @@
 import java.util.Properties;
 
 import org.jboss.osgi.husky.internal.AbstractConnector;
-import org.jboss.osgi.husky.internal.LogServiceTracker;
+import org.jboss.osgi.husky.internal.HuskyLogService;
 import org.jboss.osgi.husky.internal.Util;
 import org.jboss.osgi.husky.runtime.Connector;
 import org.osgi.framework.BundleContext;
@@ -63,7 +63,7 @@
 
    public SocketConnector(BundleContext context)
    {
-      this.log = new LogServiceTracker(context);
+      this.log = new HuskyLogService(context);
       this.context = context;
    }
 



More information about the jboss-osgi-commits mailing list