[jboss-cvs] JBossAS SVN: r95880 - in projects/jboss-osgi: projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/services and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sat Oct 31 03:00:37 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-31 03:00:36 -0400 (Sat, 31 Oct 2009)
New Revision: 95880
Modified:
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java
projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
Log:
Allow grace period for managed bundles to get registered
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java 2009-10-31 03:27:41 UTC (rev 95879)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteFramework.java 2009-10-31 07:00:36 UTC (rev 95880)
@@ -43,11 +43,13 @@
/**
* Get the installed bundle
+ * @return A managed bundle MBean or null if the identifier does not match any installed bundle.
*/
ManagedBundleMBean getBundle(String symbolicName, String version);
/**
* Get the installed bundle by id
+ * @return A managed bundle MBean or null if the identifier does not match any installed bundle.
*/
ManagedBundleMBean getBundle(long bundleId);
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-10-31 03:27:41 UTC (rev 95879)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/harness/src/main/java/org/jboss/osgi/testing/internal/RemoteRuntime.java 2009-10-31 07:00:36 UTC (rev 95880)
@@ -69,12 +69,23 @@
{
URL bundleURL = getTestHelper().getTestArchiveURL(location);
BundleInfo bundleInfo = BundleInfo.createBundleInfo(bundleURL);
+ String symbolicName = bundleInfo.getSymbolicName();
+ String version = bundleInfo.getVersion().toString();
deployInternal(location, true);
- String symbolicName = bundleInfo.getSymbolicName();
- String version = bundleInfo.getVersion().toString();
+ // The remote framework uses a BundleTracker that works of an asynchronous
+ // event to register the installed bundle. It is not available immediately.
+ int timeout = 50;
ManagedBundleMBean bundleMBean = getRemoteFramework().getBundle(symbolicName, version);
+ while (bundleMBean == null && 0 < timeout--)
+ {
+ Thread.sleep(200);
+ bundleMBean = getRemoteFramework().getBundle(symbolicName, version);
+ }
+ if (bundleMBean == null)
+ throw new IllegalStateException("Cannot find installed bundle: " + symbolicName + "-" + version);
+
RemoteBundle bundle = new RemoteBundle(this, bundleMBean, location);
return registerBundle(location, bundle);
}
@@ -144,7 +155,6 @@
OSGiBundle[] bundleArr = new OSGiBundle[bundles.size()];
bundles.toArray(bundleArr);
-
return bundleArr;
}
catch (Exception ex)
@@ -228,36 +238,40 @@
return new RemoteFramework()
{
- public ManagedBundleMBean getBundle(String symbolicName, String version)
+ public ManagedBundleMBean getBundle(String name, String version)
{
- ObjectName oname = managedFramework.getBundle(symbolicName, version);
- if (oname == null)
- throw new IllegalArgumentException("Cannot get remote bundle for: " + symbolicName);
-
- try
+ ManagedBundleMBean bundleMBean = null;
+ ObjectName oname = managedFramework.getBundle(name, version);
+ if (oname != null)
{
- return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ try
+ {
+ bundleMBean = MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
}
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
+ return bundleMBean;
}
public ManagedBundleMBean getBundle(long bundleId)
{
+ ManagedBundleMBean bundleMBean = null;
ObjectName oname = managedFramework.getBundle(bundleId);
- if (oname == null)
- throw new IllegalArgumentException("Cannot get remote bundle for: " + bundleId);
-
- try
+ if (oname != null)
{
- return MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ try
+ {
+ bundleMBean = MBeanProxy.get(ManagedBundleMBean.class, oname, getMBeanServer());
+ }
+ catch (MBeanProxyException ex)
+ {
+ throw new RemoteFrameworkException(ex);
+ }
}
- catch (MBeanProxyException ex)
- {
- throw new RemoteFrameworkException(ex);
- }
+ return bundleMBean;
}
public Set<ManagedBundleMBean> getBundles()
Modified: projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider
===================================================================
--- projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-10-31 03:27:41 UTC (rev 95879)
+++ projects/jboss-osgi/projects/bundles/husky/trunk/testsuite/src/test/resources/META-INF/services/org.jboss.osgi.spi.framework.OSGiBootstrapProvider 2009-10-31 07:00:36 UTC (rev 95880)
@@ -1 +1 @@
-org.jboss.osgi.spi.framework.PropertiesBootstrapProvider
\ No newline at end of file
+org.jboss.osgi.felix.FelixBootstrapProvider
\ No newline at end of file
Modified: projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java 2009-10-31 03:27:41 UTC (rev 95879)
+++ projects/jboss-osgi/trunk/reactor/jmx/src/main/java/org/jboss/osgi/jmx/internal/ManagedFrameworkImpl.java 2009-10-31 07:00:36 UTC (rev 95880)
@@ -25,6 +25,7 @@
import static org.jboss.osgi.spi.OSGiConstants.DOMAIN_NAME;
import static org.jboss.osgi.spi.management.ManagedBundle.PROPERTY_SYMBOLIC_NAME;
+import static org.jboss.osgi.spi.management.ManagedBundle.PROPERTY_VERSION;
import static org.jboss.osgi.spi.management.ManagedBundle.PROPERTY_ID;
import java.util.ArrayList;
@@ -93,12 +94,11 @@
{
ObjectName oname = null;
- ObjectName pattern = ObjectNameFactory.create(DOMAIN_NAME + ":" + PROPERTY_SYMBOLIC_NAME + "=" + symbolicName + ",*");
- Set<ObjectName> names = mbeanServer.queryNames(pattern, null);
+ String namestr = DOMAIN_NAME + ":" + PROPERTY_SYMBOLIC_NAME + "=" + symbolicName + "," + PROPERTY_VERSION + "=" + version + ",*" ;
+ Set<ObjectName> names = mbeanServer.queryNames(ObjectNameFactory.create(namestr), null);
if (names.size() > 0)
{
- // [TODO] Support bundle version
if (names.size() > 1)
log.warn("Multiple bundles found: " + names);
More information about the jboss-cvs-commits
mailing list