Author: adrian(a)jboss.org
Date: 2009-11-11 13:38:49 -0500 (Wed, 11 Nov 2009)
New Revision: 96275
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/OSGiBundleWrapper.java
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
Log:
Don't leak implementation details through the wrapper
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-11-11
18:37:08 UTC (rev 96274)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleManager.java 2009-11-11
18:38:49 UTC (rev 96275)
@@ -829,6 +829,24 @@
}
/**
+ * Get the underlying bundle state for a bundle
+ *
+ * @param bundle the bundle
+ * @return the bundle state
+ * @throws IllegalArgumentException if it is an unrecognised bundle
+ */
+ public AbstractBundleState getBundleState(Bundle bundle)
+ {
+ if (bundle instanceof OSGiBundleWrapper)
+ bundle = ((OSGiBundleWrapper)bundle).getBundleState();
+
+ if (bundle instanceof AbstractBundleState == false)
+ throw new IllegalArgumentException("Cannot obtain bunde state from: "
+ bundle);
+
+ return (AbstractBundleState)bundle;
+ }
+
+ /**
* Get a bundle by location
*
* @param location the location of the bundle
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleWrapper.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleWrapper.java 2009-11-11
18:37:08 UTC (rev 96274)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/bundle/OSGiBundleWrapper.java 2009-11-11
18:38:49 UTC (rev 96275)
@@ -65,7 +65,7 @@
*
* @return the bundle state
*/
- public AbstractBundleState getBundleState()
+ AbstractBundleState getBundleState()
{
return bundleState;
}
Modified:
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java
===================================================================
---
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-11-11
18:37:08 UTC (rev 96274)
+++
projects/jboss-osgi/trunk/reactor/framework/src/main/java/org/jboss/osgi/framework/service/internal/PackageAdminImpl.java 2009-11-11
18:38:49 UTC (rev 96275)
@@ -36,12 +36,11 @@
import org.jboss.osgi.framework.bundle.AbstractBundleState;
import org.jboss.osgi.framework.bundle.OSGiBundleManager;
import org.jboss.osgi.framework.bundle.OSGiBundleState;
-import org.jboss.osgi.framework.bundle.OSGiBundleWrapper;
-import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.PackageAdminServicePlugin;
+import org.jboss.osgi.framework.plugins.ResolverPlugin;
import org.jboss.osgi.framework.plugins.internal.AbstractServicePlugin;
-import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.framework.resolver.Resolvable;
+import org.jboss.osgi.framework.resolver.Resolver;
import org.jboss.osgi.spi.NotImplementedException;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -109,7 +108,13 @@
public ExportedPackage[] getExportedPackages(Bundle bundle)
{
- OSGiBundleState bundleState = assertBundleState(bundle);
+ AbstractBundleState abstractBundleState = bundleManager.getBundleState(bundle);
+
+ // [TODO] exported packages for the system bundle
+ if (abstractBundleState instanceof OSGiBundleState == false)
+ throw new UnsupportedOperationException("FIXME: getExportedPackages for
System bundle");
+
+ OSGiBundleState bundleState = (OSGiBundleState) abstractBundleState;
DeploymentUnit unit = bundleState.getDeploymentUnit();
ClassLoadingMetaData metaData = unit.getAttachment(ClassLoadingMetaData.class);
if (metaData == null)
@@ -194,7 +199,7 @@
Iterator<OSGiBundleState> it = resolvableBundles.iterator();
while (it.hasNext())
{
- OSGiBundleState bundleState = assertBundleState(it.next());
+ OSGiBundleState bundleState = it.next();
if (bundleManager.resolveBundle(bundleState, false))
{
it.remove();
@@ -210,17 +215,6 @@
return allResolved;
}
- private OSGiBundleState assertBundleState(Bundle bundle)
- {
- if (bundle instanceof OSGiBundleWrapper)
- bundle = ((OSGiBundleWrapper)bundle).getBundleState();
-
- if (bundle instanceof OSGiBundleState == false)
- throw new IllegalArgumentException("Cannot obtain bunde state from: "
+ bundle);
-
- return (OSGiBundleState)bundle;
- }
-
private static class ExportedPackageImpl implements ExportedPackage
{
private Bundle bundle;
Show replies by date