[jboss-cvs] JBossAS SVN: r97259 - projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 1 16:08:07 EST 2009


Author: alesj
Date: 2009-12-01 16:08:06 -0500 (Tue, 01 Dec 2009)
New Revision: 97259

Modified:
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
   projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
Log:
Track osgi services in context2deployment registry.

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-12-01 20:55:46 UTC (rev 97258)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java	2009-12-01 21:08:06 UTC (rev 97259)
@@ -436,16 +436,36 @@
       checkValidBundleContext();
 
       OSGiServiceState serviceState = getBundleManager().registerService(this, clazzes, service, properties);
+      afterServiceRegistration(serviceState);
       return serviceState.getRegistration();
    }
 
    /**
+    * After service registration callback.
+    *
+    * @param service the service
+    */
+   protected void afterServiceRegistration(OSGiServiceState service)
+   {
+   }
+
+   /**
+    * Before service unregistration callback.
+    *
+    * @param service the service
+    */
+   protected void beforeServiceUnregistration(OSGiServiceState service)
+   {
+   }
+
+   /**
     * Unregister a service
     * 
     * @param serviceState the service state
     */
    void unregisterService(OSGiServiceState serviceState)
    {
+      beforeServiceUnregistration(serviceState);
       getBundleManager().unregisterService(serviceState);
    }
 

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-12-01 20:55:46 UTC (rev 97258)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java	2009-12-01 21:08:06 UTC (rev 97259)
@@ -310,6 +310,30 @@
    }
 
    /**
+    * Put context to deployment mapping.
+    *
+    * @param context the context
+    * @param unit the deployment
+    * @return previous mapping value
+    */
+   DeploymentUnit putContext(ControllerContext context, DeploymentUnit unit)
+   {
+      return registry.putContext(context, unit);
+   }
+
+   /**
+    * Remove context to deployment mapping.
+    *
+    * @param context the context
+    * @param unit the deployment
+    * @return is previous mapping value same as unit param
+    */
+   DeploymentUnit removeContext(ControllerContext context, DeploymentUnit unit)
+   {
+      return registry.removeContext(context, unit);
+   }
+
+   /**
     * Get bundle for user tracker.
     *
     * @param user the user tracker object

Modified: projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-12-01 20:55:46 UTC (rev 97258)
+++ projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java	2009-12-01 21:08:06 UTC (rev 97259)
@@ -391,6 +391,18 @@
       getBundleManager().uninstallBundle(this);
    }
 
+   @Override
+   protected void afterServiceRegistration(OSGiServiceState service)
+   {
+      getBundleManager().putContext(service, unit);
+   }
+
+   @Override
+   protected void beforeServiceUnregistration(OSGiServiceState service)
+   {
+      getBundleManager().removeContext(service, unit);
+   }
+
    public static OSGiBundleState assertBundleState(Bundle bundle)
    {
       if (bundle == null)




More information about the jboss-cvs-commits mailing list