[jboss-cvs] JBossAS SVN: r99651 - in projects/jboss-osgi: projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 20 05:44:05 EST 2010
Author: thomas.diesler at jboss.com
Date: 2010-01-20 05:44:03 -0500 (Wed, 20 Jan 2010)
New Revision: 99651
Added:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ControllerContextPluginImpl.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ControllerContextPlugin.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/KernelUtils.java
Removed:
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/servicemix/
Modified:
projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
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/GenericServiceReferenceWrapper.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/MDRUtils.java
projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.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/OSGiServiceState.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/test/resources/bootstrap/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
Log:
Externalize ControllerContextPlugin
Remove all ControllerContext and OSGi service handling from OSGiBundleManager
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/etc/osgitck/jboss-osgi-bootstrap.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -12,7 +12,6 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
<parameter><inject bean="MainDeployer" /></parameter>
- <parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
@@ -54,6 +53,12 @@
********************************
-->
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
+ </bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
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-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/AbstractBundleState.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -552,7 +552,7 @@
boolean ungetContext(ControllerContext context)
{
- return getBundleManager().ungetContext(this, context);
+ return removeContextInUse(context);
}
public void addBundleListener(BundleListener listener)
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ControllerContextPluginImpl.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ControllerContextPluginImpl.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ControllerContextPluginImpl.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -0,0 +1,175 @@
+/*
+ * 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.framework.bundle;
+
+//$Id$
+
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.jar.Attributes.Name;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.structure.spi.DeploymentRegistry;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.logging.Logger;
+import org.jboss.osgi.framework.metadata.OSGiMetaData;
+import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
+import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
+import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * A plugin that manages OSGi services
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 20-Jan-2010
+ */
+public class ControllerContextPluginImpl extends AbstractPlugin implements ControllerContextPlugin
+{
+ // Provide logging
+ final Logger log = Logger.getLogger(ControllerContextPluginImpl.class);
+
+ /** The deployment registry */
+ private DeploymentRegistry registry;
+
+ public ControllerContextPluginImpl(OSGiBundleManager bundleManager, DeploymentRegistry registry)
+ {
+ super(bundleManager);
+
+ if (registry == null)
+ throw new IllegalArgumentException("Null deployment registry");
+
+ this.registry = registry;
+ }
+
+ public DeploymentUnit putContext(ControllerContext context, DeploymentUnit unit)
+ {
+ return registry.putContext(context, unit);
+ }
+
+ public DeploymentUnit removeContext(ControllerContext context, DeploymentUnit unit)
+ {
+ return registry.removeContext(context, unit);
+ }
+
+ public Set<ControllerContext> getRegisteredContext(AbstractDeployedBundleState bundleState)
+ {
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ return registry.getContexts(unit);
+ }
+
+ /**
+ * Get bundle for user tracker.
+ *
+ * @param user the user tracker object
+ * @return bundle state
+ */
+ public AbstractBundleState getBundleForUser(Object user)
+ {
+ if (user instanceof AbstractBundleState)
+ return (AbstractBundleState)user;
+ else if (user instanceof ControllerContext)
+ return getBundleForContext((ControllerContext)user);
+ else
+ throw new IllegalArgumentException("Unknown tracker type: " + user);
+ }
+
+ /**
+ * Get bundle for context.
+ *
+ * @param context the context
+ * @return bundle state
+ */
+ public AbstractBundleState getBundleForContext(ControllerContext context)
+ {
+ if (context instanceof OSGiServiceState)
+ {
+ OSGiServiceState service = (OSGiServiceState)context;
+ return service.getBundleState();
+ }
+
+ OSGiBundleManager bundleManager = getBundleManager();
+ DeploymentUnit unit = registry.getDeployment(context);
+ if (unit != null)
+ {
+ synchronized (unit)
+ {
+ OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
+ if (bundleState == null)
+ {
+ OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
+ if (osgiMetaData == null)
+ {
+ Manifest manifest = unit.getAttachment(Manifest.class);
+ // [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
+ if (manifest == null)
+ manifest = new Manifest();
+ // [TODO] populate some bundle information
+ Attributes attributes = manifest.getMainAttributes();
+ attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
+ osgiMetaData = new AbstractOSGiMetaData(manifest);
+ unit.addAttachment(OSGiMetaData.class, osgiMetaData);
+ }
+
+ try
+ {
+ bundleState = (OSGiBundleState)bundleManager.addDeployment(unit);
+ bundleState.startInternal();
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Cannot dynamically add generic bundle: " + unit, t);
+ }
+ }
+ return bundleState;
+ }
+ }
+
+ return bundleManager.getSystemBundle();
+ }
+
+ /**
+ * Unregister contexts.
+ *
+ * @param bundleState the stopping bundle
+ */
+ public void unregisterContexts(AbstractDeployedBundleState bundleState)
+ {
+ DeploymentUnit unit = bundleState.getDeploymentUnit();
+ Set<ControllerContext> contexts = registry.getContexts(unit);
+ for (ControllerContext context : contexts)
+ {
+ unregisterContext(context);
+ }
+ }
+
+ private void unregisterContext(ControllerContext context)
+ {
+ if (context instanceof ServiceRegistration)
+ {
+ ServiceRegistration service = (ServiceRegistration)context;
+ service.unregister();
+ }
+ }
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ControllerContextPluginImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/GenericServiceReferenceWrapper.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/GenericServiceReferenceWrapper.java 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/GenericServiceReferenceWrapper.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -29,6 +29,8 @@
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.tracker.ContextTracker;
import org.jboss.dependency.spi.tracker.ContextTracking;
+import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
+import org.jboss.osgi.framework.util.KernelUtils;
import org.osgi.framework.Bundle;
/**
@@ -75,7 +77,7 @@
public Bundle getBundle()
{
- if (OSGiBundleManager.isUnregistered(context))
+ if (KernelUtils.isUnregistered(context))
return null;
return bundleState.getBundleInternal();
@@ -91,11 +93,13 @@
return null;
OSGiBundleManager manager = bundleState.getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+
Set<Object> users = ct.getUsers(context);
Set<Bundle> bundles = new HashSet<Bundle>();
for (Object user : users)
{
- AbstractBundleState abs = manager.getBundleForUser(user);
+ AbstractBundleState abs = plugin.getBundleForUser(user);
bundles.add(abs.getBundleInternal());
}
if (bundles.isEmpty() == false)
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/MDRUtils.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/MDRUtils.java 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/MDRUtils.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -31,6 +31,8 @@
import org.jboss.metadata.spi.MetaData;
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.ScopeLevel;
+import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
+import org.jboss.osgi.framework.util.KernelUtils;
import org.jboss.util.collection.Iterators;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
@@ -144,7 +146,7 @@
if (bundleState == otherBundle)
return true;
- if (OSGiBundleManager.isUnregistered(context))
+ if (KernelUtils.isUnregistered(context))
return false;
return isAssignableTo(bundleState, otherBundle, className);
@@ -256,11 +258,13 @@
throw new IllegalArgumentException("Null bundle state");
OSGiBundleManager manager = bundleState.getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+
// context's bundle
- AbstractBundleState other = manager.getBundleForContext(context);
+ AbstractBundleState other = plugin.getBundleForContext(context);
if (bundleState == other)
return true;
- if (OSGiBundleManager.isUnregistered(context))
+ if (KernelUtils.isUnregistered(context))
return false;
String[] classes = getProperty(context, Constants.OBJECTCLASS, String[].class);
@@ -293,8 +297,8 @@
throw new IllegalArgumentException("Null class name");
OSGiBundleManager manager = bundleState.getBundleManager();
- // context's bundle
- AbstractBundleState other = manager.getBundleForContext(context);
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ AbstractBundleState other = plugin.getBundleForContext(context);
return isAssignableTo(context, bundleState, other, className);
}
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -44,11 +44,7 @@
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
-import java.util.jar.Attributes;
-import java.util.jar.Manifest;
-import java.util.jar.Attributes.Name;
-import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.ControllerState;
import org.jboss.deployers.client.spi.DeployerClient;
@@ -59,7 +55,6 @@
import org.jboss.deployers.spi.attachments.MutableAttachments;
import org.jboss.deployers.spi.deployer.DeploymentStage;
import org.jboss.deployers.spi.deployer.DeploymentStages;
-import org.jboss.deployers.structure.spi.DeploymentRegistry;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.deployers.structure.spi.main.MainDeployerStructure;
import org.jboss.deployers.vfs.spi.client.VFSDeployment;
@@ -71,7 +66,6 @@
import org.jboss.osgi.framework.deployers.OSGiBundleActivatorDeployer;
import org.jboss.osgi.framework.metadata.OSGiMetaData;
import org.jboss.osgi.framework.metadata.ParameterizedAttribute;
-import org.jboss.osgi.framework.metadata.internal.AbstractOSGiMetaData;
import org.jboss.osgi.framework.plugins.AutoInstallPlugin;
import org.jboss.osgi.framework.plugins.BundleStoragePlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
@@ -91,7 +85,6 @@
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
-import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.Version;
import org.osgi.service.packageadmin.PackageAdmin;
@@ -130,10 +123,6 @@
private Kernel kernel;
/** The main deployer */
private DeployerClient deployerClient;
- /** The deployment structure */
- private MainDeployerStructure deployerStructure;
- /** The deployment registry */
- private DeploymentRegistry registry;
/** The executor */
private Executor executor;
/** The system bundle */
@@ -179,9 +168,9 @@
* @param registry the deployment registry
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleManager(Kernel kernel, DeployerClient deployerClient, DeploymentRegistry registry)
+ public OSGiBundleManager(Kernel kernel, DeployerClient deployerClient)
{
- this(kernel, deployerClient, registry, null);
+ this(kernel, deployerClient, null);
}
/**
@@ -193,7 +182,7 @@
* @param executor the executor
* @throws IllegalArgumentException for a null parameter
*/
- public OSGiBundleManager(Kernel kernel, DeployerClient deployerClient, DeploymentRegistry registry, Executor executor)
+ public OSGiBundleManager(Kernel kernel, DeployerClient deployerClient, Executor executor)
{
if (kernel == null)
throw new IllegalArgumentException("Null kernel");
@@ -201,13 +190,9 @@
throw new IllegalArgumentException("Null deployerClient");
if (deployerClient instanceof MainDeployerStructure == false)
throw new IllegalArgumentException("Deployer client does not implement " + MainDeployerStructure.class.getName());
- if (registry == null)
- throw new IllegalArgumentException("Null deployment registry");
-
+
this.kernel = kernel;
this.deployerClient = deployerClient;
- this.deployerStructure = (MainDeployerStructure)deployerClient;
- this.registry = registry;
// TODO thread factory
if (executor == null)
@@ -561,6 +546,7 @@
deployerClient.deploy(deployment);
try
{
+ MainDeployerStructure deployerStructure = (MainDeployerStructure)deployerClient;
DeploymentUnit unit = deployerStructure.getDeploymentUnit(deployment.getName());
bundleState = unit.getAttachment(AbstractBundleState.class);
if (bundleState == null)
@@ -1581,164 +1567,6 @@
}
}
- /**
- * 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 registered contexts for bundle.
- *
- * @param bundleState the owning bundle
- * @return registered contexts
- */
- Set<ControllerContext> getRegisteredContext(AbstractDeployedBundleState bundleState)
- {
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- return registry.getContexts(unit);
- }
-
- /**
- * Is the context undergisted.
- *
- * @param context the context
- * @return true if the context is unregisted, false otherwise
- */
- public static boolean isUnregistered(ControllerContext context)
- {
- Controller controller = context.getController();
- return controller == null || controller.getStates().isBeforeState(context.getState(), ControllerState.INSTALLED);
- }
-
- /**
- * Unregister contexts.
- *
- * @param bundleState the stopping bundle
- */
- void unregisterContexts(AbstractDeployedBundleState bundleState)
- {
- DeploymentUnit unit = bundleState.getDeploymentUnit();
- Set<ControllerContext> contexts = registry.getContexts(unit);
- for (ControllerContext context : contexts)
- {
- unregisterContext(context);
- }
- }
-
- /**
- * Get bundle for user tracker.
- *
- * @param user the user tracker object
- * @return bundle state
- */
- AbstractBundleState getBundleForUser(Object user)
- {
- if (user instanceof AbstractBundleState)
- return (AbstractBundleState)user;
- else if (user instanceof ControllerContext)
- return getBundleForContext((ControllerContext)user);
- else
- throw new IllegalArgumentException("Unknown tracker type: " + user);
- }
-
- /**
- * Unget a context
- *
- * @param bundleState the bundle state
- * @param context the context
- * @return true when the context is still in use by the bundle
- */
- boolean ungetContext(AbstractBundleState bundleState, ControllerContext context)
- {
- return bundleState.removeContextInUse(context);
- }
-
- /**
- * Unregister context.
- *
- * @param context the context
- */
- private static void unregisterContext(ControllerContext context)
- {
- if (context instanceof ServiceRegistration)
- {
- ServiceRegistration service = (ServiceRegistration)context;
- service.unregister();
- }
- }
-
- /**
- * Get bundle for context.
- *
- * @param context the context
- * @return bundle state
- */
- public AbstractBundleState getBundleForContext(ControllerContext context)
- {
- if (context instanceof OSGiServiceState)
- {
- OSGiServiceState service = (OSGiServiceState)context;
- return service.getBundleState();
- }
-
- DeploymentUnit unit = registry.getDeployment(context);
- if (unit != null)
- {
- synchronized (unit)
- {
- OSGiBundleState bundleState = unit.getAttachment(OSGiBundleState.class);
- if (bundleState == null)
- {
- OSGiMetaData osgiMetaData = unit.getAttachment(OSGiMetaData.class);
- if (osgiMetaData == null)
- {
- Manifest manifest = unit.getAttachment(Manifest.class);
- // [TODO] we need a mechanism to construct an OSGiMetaData from an easier factory
- if (manifest == null)
- manifest = new Manifest();
- // [TODO] populate some bundle information
- Attributes attributes = manifest.getMainAttributes();
- attributes.put(new Name(Constants.BUNDLE_SYMBOLICNAME), unit.getName());
- osgiMetaData = new AbstractOSGiMetaData(manifest);
- unit.addAttachment(OSGiMetaData.class, osgiMetaData);
- }
-
- try
- {
- bundleState = (OSGiBundleState)addDeployment(unit);
- bundleState.startInternal();
- }
- catch (Throwable t)
- {
- throw new RuntimeException("Cannot dynamically add generic bundle: " + unit, t);
- }
- }
- return bundleState;
- }
- }
-
- return systemBundle;
- }
-
private URL getLocationURL(String location) throws BundleException
{
// Try location as URL
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-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleState.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -39,6 +39,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.osgi.framework.AdminPermission;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleActivator;
@@ -133,7 +134,9 @@
protected Set<ControllerContext> getRegisteredContexts()
{
- return getBundleManager().getRegisteredContext(this);
+ OSGiBundleManager manager = getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ return plugin.getRegisteredContext(this);
}
public Class<?> loadClass(String name) throws ClassNotFoundException
@@ -308,7 +311,9 @@
}
// Any services registered by this bundle must be unregistered
- getBundleManager().unregisterContexts(this);
+ OSGiBundleManager manager = getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ plugin.unregisterContexts(this);
// Any services used by this bundle must be released
for (ControllerContext context : getUsedContexts(this))
@@ -318,7 +323,7 @@
{
try
{
- getBundleManager().ungetContext(this, context);
+ removeContextInUse(context);
}
catch (Throwable t)
{
@@ -387,12 +392,16 @@
@Override
protected void afterServiceRegistration(OSGiServiceState service)
{
- getBundleManager().putContext(service, getDeploymentUnit());
+ OSGiBundleManager manager = getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ plugin.putContext(service, getDeploymentUnit());
}
@Override
protected void beforeServiceUnregistration(OSGiServiceState service)
{
- getBundleManager().removeContext(service, getDeploymentUnit());
+ 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/OSGiServiceState.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/OSGiServiceState.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -45,6 +45,7 @@
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.Scope;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.util.CaseInsensitiveDictionary;
import org.jboss.osgi.spi.util.BundleClassLoader;
@@ -289,7 +290,8 @@
protected Object getActualUser(ControllerContext context)
{
OSGiBundleManager manager = bundleState.getBundleManager();
- return manager.getBundleForContext(context);
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ return plugin.getBundleForContext(context);
}
protected Object getTargetForActualUser(Object user)
@@ -537,11 +539,13 @@
return null;
OSGiBundleManager manager = bundleState.getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+
Set<Object> users = ct.getUsers(this);
Set<Bundle> bundles = new HashSet<Bundle>();
for (Object user : users)
{
- AbstractBundleState abs = manager.getBundleForUser(user);
+ AbstractBundleState abs = plugin.getBundleForUser(user);
bundles.add(abs.getBundleInternal());
}
return bundles.toArray(new Bundle[bundles.size()]);
@@ -667,9 +671,11 @@
{
Set<AbstractBundleState> used = new HashSet<AbstractBundleState>();
OSGiBundleManager manager = bundleState.getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+
for (Object user : users)
{
- AbstractBundleState using = manager.getBundleForUser(user);
+ AbstractBundleState using = plugin.getBundleForUser(user);
if (used.add(using)) // add so we don't do duplicate work
{
int count = ct.getUsedByCount(this, using);
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-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/bundle/ServiceManagerPluginImpl.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -46,9 +46,11 @@
import org.jboss.metadata.spi.retrieval.MetaDataRetrievalFactory;
import org.jboss.metadata.spi.scope.CommonLevels;
import org.jboss.metadata.spi.scope.ScopeKey;
+import org.jboss.osgi.framework.plugins.ControllerContextPlugin;
import org.jboss.osgi.framework.plugins.FrameworkEventsPlugin;
import org.jboss.osgi.framework.plugins.ServiceManagerPlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractPlugin;
+import org.jboss.osgi.framework.util.KernelUtils;
import org.jboss.osgi.framework.util.NoFilter;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
@@ -154,7 +156,7 @@
ControllerContextHandle handle = (ControllerContextHandle)reference;
ControllerContext context = handle.getContext();
- if (OSGiBundleManager.isUnregistered(context)) // we're probably not installed anymore
+ if (KernelUtils.isUnregistered(context)) // we're probably not installed anymore
return null;
return bundleState.addContextInUse(context);
@@ -227,10 +229,10 @@
ControllerContextHandle serviceReference = (ControllerContextHandle)reference;
ControllerContext context = serviceReference.getContext();
- if (OSGiBundleManager.isUnregistered(context))
+ if (KernelUtils.isUnregistered(context))
return false;
- return getBundleManager().ungetContext(bundleState, context);
+ return bundleState.removeContextInUse(context);
}
/**
@@ -341,7 +343,7 @@
for (ControllerContext context : sorted)
{
// re-check?? -- we already only get INSTALLED
- if (OSGiBundleManager.isUnregistered(context) == false)
+ if (KernelUtils.isUnregistered(context) == false)
{
ServiceReference ref = getServiceReferenceForContext(context);
if (filter.match(ref) && hasPermission(context))
@@ -372,7 +374,9 @@
return service.hasPermission() ? service.getReferenceInternal() : null;
}
- AbstractBundleState bundleState = getBundleManager().getBundleForContext(context);
+ OSGiBundleManager manager = getBundleManager();
+ ControllerContextPlugin plugin = manager.getPlugin(ControllerContextPlugin.class);
+ AbstractBundleState bundleState = plugin.getBundleForContext(context);
return new GenericServiceReferenceWrapper(context, bundleState);
}
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ControllerContextPlugin.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ControllerContextPlugin.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ControllerContextPlugin.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -0,0 +1,89 @@
+/*
+ * 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.framework.plugins;
+
+import java.util.Set;
+
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.osgi.framework.bundle.AbstractBundleState;
+import org.jboss.osgi.framework.bundle.AbstractDeployedBundleState;
+
+
+/**
+ * A plugin that manages kernel controller contexts.
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 20-Jan-2010
+ */
+public interface ControllerContextPlugin extends Plugin
+{
+ /**
+ * Put context to deployment mapping.
+ *
+ * @param context the context
+ * @param unit the deployment
+ * @return previous mapping value
+ */
+ DeploymentUnit putContext(ControllerContext context, DeploymentUnit 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);
+
+ /**
+ * Get registered contexts for bundle.
+ *
+ * @param bundleState the owning bundle
+ * @return registered contexts
+ */
+ Set<ControllerContext> getRegisteredContext(AbstractDeployedBundleState bundleState);
+
+ /**
+ * Unregister contexts.
+ *
+ * @param bundleState the stopping bundle
+ */
+ void unregisterContexts(AbstractDeployedBundleState bundleState);
+
+ /**
+ * Get bundle for user tracker.
+ *
+ * @param user the user tracker object
+ * @return bundle state
+ */
+ AbstractBundleState getBundleForUser(Object user);
+
+ /**
+ * Get bundle for context.
+ *
+ * @param context the context
+ * @return bundle state
+ */
+ AbstractBundleState getBundleForContext(ControllerContext context);
+
+}
\ No newline at end of file
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/plugins/ControllerContextPlugin.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/KernelUtils.java
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/KernelUtils.java (rev 0)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/KernelUtils.java 2010-01-20 10:44:03 UTC (rev 99651)
@@ -0,0 +1,53 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, Red Hat Middleware LLC, and individual contributors
+* as indicated by the @author tags. See the copyright.txt file 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.framework.util;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+
+
+/**
+ * A collection of kernel utils
+ *
+ * @author thomas.diesler at jboss.com
+ * @since 20-Jan-2010
+ */
+public final class KernelUtils
+{
+ // Hide the ctor
+ private KernelUtils()
+ {
+ }
+
+ /**
+ * Is the context undergisted.
+ *
+ * @param context the context
+ * @return true if the context is unregisted, false otherwise
+ */
+ public static boolean isUnregistered(ControllerContext context)
+ {
+ Controller controller = context.getController();
+ return controller == null || controller.getStates().isBeforeState(context.getState(), ControllerState.INSTALLED);
+ }
+}
Property changes on: projects/jboss-osgi/projects/runtime/framework/trunk/src/main/java/org/jboss/osgi/framework/util/KernelUtils.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/projects/runtime/framework/trunk/src/test/resources/bootstrap/jboss-osgi-bootstrap.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -12,7 +12,6 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
<parameter><inject bean="MainDeployer" /></parameter>
- <parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
@@ -47,10 +46,16 @@
********************************
-->
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
+ </bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
- <bean name="OSGiServiceManager" class="org.jboss.osgi.framework.bundle.ServiceManagerPluginImpl">
+ <bean name="OSGiServiceManagerPlugin" class="org.jboss.osgi.framework.bundle.ServiceManagerPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
<bean name="OSGiStoragePlugin" class="org.jboss.osgi.framework.plugins.internal.BundleStoragePluginImpl">
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/jbossas/jboss-beans-jbossmc.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -96,9 +96,11 @@
</property>
</bean>
-->
-
- <bean name="OSGiBundleResolver" class="org.jboss.osgi.framework.resolver.internal.basic.BasicResolverImpl">
- <constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
</bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
Modified: projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/trunk/distribution/installer/src/main/resources/runtime/server/conf/jboss-osgi-bootstrap.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -12,7 +12,6 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
<parameter><inject bean="MainDeployer" /></parameter>
- <parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
@@ -91,6 +90,12 @@
</list>
</property>
</bean>
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
+ </bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
Modified: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -12,7 +12,6 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
<parameter><inject bean="MainDeployer" /></parameter>
- <parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
@@ -74,6 +73,12 @@
</list>
</property>
</bean>
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
+ </bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
Modified: projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-20 09:48:55 UTC (rev 99650)
+++ projects/jboss-osgi/trunk/testsuite/functional/src/test/resources/META-INF/jboss-osgi-bootstrap.xml 2010-01-20 10:44:03 UTC (rev 99651)
@@ -12,7 +12,6 @@
<constructor>
<parameter><inject bean="jboss.kernel:service=Kernel" /></parameter>
<parameter><inject bean="MainDeployer" /></parameter>
- <parameter><inject bean="DeploymentRegistry" /></parameter>
</constructor>
<property name="properties">
<map keyClass="java.lang.String" valueClass="java.lang.String">
@@ -73,6 +72,12 @@
</list>
</property>
</bean>
+ <bean name="OSGiControllerContextPlugin" class="org.jboss.osgi.framework.bundle.ControllerContextPluginImpl">
+ <constructor>
+ <parameter><inject bean="OSGiBundleManager" /></parameter>
+ <parameter><inject bean="DeploymentRegistry" /></parameter>
+ </constructor>
+ </bean>
<bean name="OSGiFrameworkEventsPlugin" class="org.jboss.osgi.framework.plugins.internal.FrameworkEventsPluginImpl">
<constructor><parameter><inject bean="OSGiBundleManager" /></parameter></constructor>
</bean>
More information about the jboss-cvs-commits
mailing list