[jboss-cvs] JBossAS SVN: r100778 - in projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework: plugins and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 9 17:08:51 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-02-09 17:08:51 -0500 (Tue, 09 Feb 2010)
New Revision: 100778
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
Log:
[JBOSGi-278] Revisit ControllerContext handling
Move some of the context bleed into ServiceManagerPlugin
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-02-09 21:44:00 UTC (rev 100777)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-02-09 22:08:51 UTC (rev 100778)
@@ -525,13 +525,11 @@
checkValidBundleContext();
ServiceManagerPlugin plugin = getBundleManager().getPlugin(ServiceManagerPlugin.class);
OSGiServiceState serviceState = (OSGiServiceState)plugin.registerService(this, clazzes, service, properties);
- afterServiceRegistration(serviceState);
return serviceState.getRegistration();
}
void unregisterService(OSGiServiceState serviceState)
{
- beforeServiceUnregistration(serviceState);
ServiceManagerPlugin plugin = getBundleManager().getPlugin(ServiceManagerPlugin.class);
plugin.unregisterService(serviceState);
}
@@ -543,20 +541,6 @@
return plugin.ungetService(this, reference);
}
- /**
- * After service registration callback.
- */
- protected void afterServiceRegistration(OSGiServiceState service)
- {
- }
-
- /**
- * Before service unregistration callback.
- */
- protected void beforeServiceUnregistration(OSGiServiceState service)
- {
- }
-
boolean ungetContext(ControllerContext context)
{
return removeContextInUse(context);
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-02-09 21:44:00 UTC (rev 100777)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-02-09 22:08:51 UTC (rev 100778)
@@ -30,7 +30,6 @@
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.List;
-import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.jboss.classloading.spi.metadata.ClassLoadingMetaData;
@@ -39,7 +38,7 @@
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData;
import org.jboss.osgi.framework.classloading.OSGiClassLoadingMetaData.FragmentHostMetaData;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
-import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
+import org.jboss.osgi.framework.plugins.ServiceManagerPlugin;
import org.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
@@ -132,13 +131,6 @@
return false;
}
- protected Set<ControllerContext> getRegisteredContexts()
- {
- OSGiBundleManager manager = getBundleManager();
- ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
- return plugin.getRegisteredContexts(this);
- }
-
public Class<?> loadClass(String name) throws ClassNotFoundException
{
checkInstalled();
@@ -314,8 +306,8 @@
Throwable rethrow = null;
if (priorState == Bundle.ACTIVE)
{
- BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
BundleContext bundleContext = getBundleContext();
+ BundleActivator bundleActivator = getDeploymentUnit().getAttachment(BundleActivator.class);
if (bundleActivator != null && bundleContext != null)
{
try
@@ -330,9 +322,8 @@
}
// Any services registered by this bundle must be unregistered
- OSGiBundleManager manager = getBundleManager();
- ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
- plugin.unregisterContexts(this);
+ ServiceManagerPlugin plugin = getBundleManager().getPlugin(ServiceManagerPlugin.class);
+ plugin.unregisterServices(this);
// Any services used by this bundle must be released
for (ControllerContext context : getUsedContexts(this))
@@ -407,20 +398,4 @@
return super.getHeaders(locale);
}
-
- @Override
- protected void afterServiceRegistration(OSGiServiceState service)
- {
- OSGiBundleManager manager = getBundleManager();
- ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
- plugin.putContext(service, getDeploymentUnit());
- }
-
- @Override
- protected void beforeServiceUnregistration(OSGiServiceState service)
- {
- OSGiBundleManager manager = getBundleManager();
- ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
- plugin.removeContext(service, getDeploymentUnit());
- }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java 2010-02-09 21:44:00 UTC (rev 100777)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceReferenceWrapper.java 2010-02-09 22:08:51 UTC (rev 100778)
@@ -49,11 +49,6 @@
this.serviceState = serviceState;
}
- ControllerContext getContext()
- {
- return getServiceState();
- }
-
public Bundle getBundle()
{
return serviceState.getBundle();
@@ -102,13 +97,13 @@
return serviceState.toString();
}
- /**
- * Get the serviceState.
- *
- * @return the serviceState.
- */
OSGiServiceState getServiceState()
{
return serviceState;
}
+
+ ControllerContext getContext()
+ {
+ return getServiceState();
+ }
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-02-09 21:44:00 UTC (rev 100777)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-02-09 22:08:51 UTC (rev 100778)
@@ -86,12 +86,6 @@
super(bundleManager);
}
- @Deprecated
- public void setEnableMDRUsage(boolean mdrUsage)
- {
- log.warn("This flag is no longer supported.");
- }
-
public void start()
{
kernel = getBundleManager().getKernel();
@@ -217,19 +211,29 @@
throw new RuntimeException(t);
}
- FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
- plugin.fireServiceEvent(bundleState, ServiceEvent.REGISTERED, result);
+ if (bundleState instanceof OSGiBundleState)
+ {
+ ControllerContextPlugin plugin = getPlugin(ControllerContextPlugin.class);
+ plugin.putContext(result, ((OSGiBundleState)bundleState).getDeploymentUnit());
+ }
+ FrameworkEventsPlugin eventsPlugin = getPlugin(FrameworkEventsPlugin.class);
+ eventsPlugin.fireServiceEvent(bundleState, ServiceEvent.REGISTERED, result);
+
return result;
}
public void unregisterService(OSGiServiceState serviceState)
{
AbstractBundleState bundleState = serviceState.getBundleState();
-
+ if (bundleState instanceof OSGiBundleState)
+ {
+ ControllerContextPlugin plugin = getPlugin(ControllerContextPlugin.class);
+ plugin.removeContext(serviceState, ((OSGiBundleState)bundleState).getDeploymentUnit());
+ }
+
Controller controller = kernel.getController();
controller.uninstall(serviceState.getName());
-
serviceState.internalUnregister();
FrameworkEventsPlugin plugin = getPlugin(FrameworkEventsPlugin.class);
@@ -249,6 +253,12 @@
return bundleState.removeContextInUse(context);
}
+ public void unregisterServices(AbstractBundleState bundleState)
+ {
+ ControllerContextPlugin plugin = getPlugin(ControllerContextPlugin.class);
+ plugin.unregisterContexts(bundleState);
+ }
+
/**
* Apply OSGi's MDR usage:
* - add/remove system bundle as default context tracker
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-02-09 21:44:00 UTC (rev 100777)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ServiceManagerPlugin.java 2010-02-09 22:08:51 UTC (rev 100778)
@@ -140,4 +140,10 @@
*
*/
void unregisterService(OSGiServiceState serviceState);
+
+ /**
+ * Unregister all services that were registered on behalf of the given bundle.
+ * @param bundleState The bundle that registered the services.
+ */
+ void unregisterServices(AbstractBundleState bundleState);
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list