[jboss-cvs] JBossAS SVN: r59417 - in projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform: plugin spi

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 8 08:26:18 EST 2007


Author: alesj
Date: 2007-01-08 08:26:08 -0500 (Mon, 08 Jan 2007)
New Revision: 59417

Added:
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/PlatformWrapper.java
Modified:
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/AbstractBundleAdapter.java
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixBundleAdapter.java
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixPlatform.java
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixWrapper.java
   projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/spi/BundleAdapter.java
Log:
log wrapper, javadocs

Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/AbstractBundleAdapter.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/AbstractBundleAdapter.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/AbstractBundleAdapter.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -23,13 +23,17 @@
 
 import org.jboss.osgi.core.platform.spi.BundleAdapter;
 import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
 
 /**
+ * Simple abstract bundle holder.
+ *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public abstract class AbstractBundleAdapter implements BundleAdapter
 {
    protected Bundle bundle;
+   protected BundleContext bundleContext;
 
    protected AbstractBundleAdapter(Bundle bundle)
    {
@@ -40,6 +44,16 @@
       this.bundle = bundle;
    }
 
+   /**
+    * Provide BundleContext for specific Platform Bundle impl.
+    *
+    * @return lazy bundle context lookup
+    * @throws Exception
+    */
+   protected abstract BundleContext lookupBundleContext() throws Exception;
+
+   //--- adapter's methods
+
    public Long getBundleId()
    {
       return bundle.getBundleId();
@@ -49,4 +63,14 @@
    {
       return bundle;
    }
+
+   public BundleContext getBundleContext() throws Exception
+   {
+      if (bundleContext == null)
+      {
+         bundleContext = lookupBundleContext();
+      }
+      return bundleContext;
+   }
+
 }

Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixBundleAdapter.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixBundleAdapter.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixBundleAdapter.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -27,6 +27,9 @@
 import org.osgi.framework.BundleContext;
 
 /**
+ * Apache Felix impl of adapter.
+ * Accessing private getBundleContext on default package visible BundleImpl.
+ *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public class FelixBundleAdapter extends AbstractBundleAdapter
@@ -38,7 +41,7 @@
       super(bundle);
    }
 
-   public BundleContext getBundleContext() throws Exception
+   protected BundleContext lookupBundleContext() throws Exception
    {
       if (bundleContext == null)
       {
@@ -48,5 +51,5 @@
          bundleContext = (BundleContext) getContext.invoke(bundle);
       }
       return bundleContext;
-   }   
+   }
 }

Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixPlatform.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixPlatform.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixPlatform.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -29,6 +29,8 @@
 import org.osgi.framework.Bundle;
 
 /**
+ * Apache Felix OSGi framework / platform.
+ *  
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public class FelixPlatform implements OSGiPlatform

Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixWrapper.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixWrapper.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/FelixWrapper.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -32,6 +32,8 @@
 import org.jboss.logging.Logger;
 
 /**
+ * Simple wrapper to access protected methods.
+ *
  * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
  */
 public class FelixWrapper extends Felix
@@ -62,16 +64,8 @@
 
    public Bundle installBundle(String location, InputStream is) throws BundleException
    {
-      if (log.isTraceEnabled())
-      {
-         log.trace("Installing bundle from location: " + location);
-      }
       Bundle bundle = super.installBundle(location, is);
       long bundleId = bundle.getBundleId();
-      if (log.isTraceEnabled())
-      {
-         log.trace("Installed bundle with id: " + bundleId);
-      }
       installedBundles.put(bundleId, bundle);
       return bundle;
    }
@@ -82,10 +76,6 @@
       Bundle bundle = installedBundles.get(bundleId);
       if (bundle != null)
       {
-         if (log.isTraceEnabled())
-         {
-            log.trace("Updating bundle with id: " + bundleId);
-         }
          if (inputStream != null)
          {
             bundle.update(inputStream);
@@ -94,10 +84,6 @@
          {
             bundle.update();
          }
-         if (log.isTraceEnabled())
-         {
-            log.trace("Bundle with id: " + bundleId + " updated.");
-         }
       }
       else
       {
@@ -110,15 +96,7 @@
       Bundle bundle = installedBundles.get(bundleId);
       if (bundle != null)
       {
-         if (log.isTraceEnabled())
-         {
-            log.trace("Uninstalling bundle with id: " + bundleId);
-         }
          bundle.uninstall();
-         if (log.isTraceEnabled())
-         {
-            log.trace("Bundle with id: " + bundleId + " unistalled.");
-         }
       }
       else
       {

Added: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/PlatformWrapper.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/PlatformWrapper.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/plugin/PlatformWrapper.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -0,0 +1,122 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.core.platform.plugin;
+
+import java.io.InputStream;
+
+import org.jboss.logging.Logger;
+import org.jboss.osgi.core.platform.spi.BundleAdapter;
+import org.jboss.osgi.core.platform.spi.OSGiPlatform;
+
+/**
+ * Logging wrapper around delegating platform.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class PlatformWrapper implements OSGiPlatform
+{
+   private OSGiPlatform platform;
+   private Logger log;
+
+   public PlatformWrapper(OSGiPlatform platform)
+   {
+      this.platform = platform;
+      log = Logger.getLogger(platform.getClass());
+   }
+
+   public void start() throws Exception
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Starting OSGi platform: " + platform);
+      }
+
+      platform.start();
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("OSGi platform started ...");
+      }
+   }
+
+   public void stop() throws Exception
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Stopping OSGi platform: " + platform);
+      }
+
+      platform.stop();
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("OSGi platform stopped ...");
+      }
+   }
+
+   public BundleAdapter installBundle(String location, InputStream is) throws Exception
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Installing bundle from location: " + location);
+      }
+
+      BundleAdapter bundleAdapter = platform.installBundle(location, is);
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Installed bundle with id: " + bundleAdapter.getBundleId());
+      }
+
+      return bundleAdapter;
+   }
+
+   public void updateBundle(Long bundleId, InputStream is) throws Exception
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Updating bundle with id: " + bundleId);
+      }
+
+      platform.updateBundle(bundleId, is);
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Bundle with id: " + bundleId + " updated.");
+      }
+   }
+
+   public void uninstallBundle(Long bundleId) throws Exception
+   {
+      if (log.isTraceEnabled())
+      {
+         log.trace("Uninstalling bundle with id: " + bundleId);
+      }
+
+      platform.uninstallBundle(bundleId);
+
+      if (log.isTraceEnabled())
+      {
+         log.trace("Bundle with id: " + bundleId + " unistalled.");
+      }
+   }
+}

Modified: projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/spi/BundleAdapter.java
===================================================================
--- projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/spi/BundleAdapter.java	2007-01-08 12:44:54 UTC (rev 59416)
+++ projects/osgi/trunk/core/src/main/org/jboss/osgi/core/platform/spi/BundleAdapter.java	2007-01-08 13:26:08 UTC (rev 59417)
@@ -44,7 +44,7 @@
    Bundle getUnderlyingBundle();
 
    /**
-    * Abstraction if getting the bundle
+    * Abstraction for getting the bundle
     * Different platform have different way of getting the BC.
     * Sometimes there is a 'hack-ish' way of getting this.
     *




More information about the jboss-cvs-commits mailing list