[vmkit-commits] [vmkit] r180523 - Management bundle now supports installation and startup (but not operation) on a non-Incinerator JVM. Updated management stress bundle to operate on a non-Incinerator JVM in degraded mode.

Peter Senna Tschudin peter.senna at gmail.com
Thu Apr 25 10:21:20 PDT 2013


Author: peter.senna
Date: Thu Apr 25 12:19:49 2013
New Revision: 180523

URL: http://llvm.org/viewvc/llvm-project?rev=180523&view=rev
Log:
Management bundle now supports installation and startup (but not operation) on a non-Incinerator JVM. Updated management stress bundle to operate on a non-Incinerator JVM in degraded mode.
(cherry picked from commit bebe36b15d71fb0c98082d5c34dc4df19a19c0a9)

Modified:
    vmkit/trunk/incinerator/osgi/src/j3/J3Mgr.java
    vmkit/trunk/incinerator/osgi/src/j3mgr/J3MgrImpl.java
    vmkit/trunk/incinerator/tests/ijvm.tests.BundleMgmtStress/src/ijvm/tests/BundleMgmtStress/Activator.java

Modified: vmkit/trunk/incinerator/osgi/src/j3/J3Mgr.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/osgi/src/j3/J3Mgr.java?rev=180523&r1=180522&r2=180523&view=diff
==============================================================================
--- vmkit/trunk/incinerator/osgi/src/j3/J3Mgr.java (original)
+++ vmkit/trunk/incinerator/osgi/src/j3/J3Mgr.java Thu Apr 25 12:19:49 2013
@@ -2,13 +2,17 @@ package j3;
 
 public interface J3Mgr
 {
-	public void setBundleStaleReferenceCorrected(long bundleID, boolean corrected) throws Exception;
-	public boolean isBundleStaleReferenceCorrected(long bundleID) throws Exception;
+	public void setBundleStaleReferenceCorrected(
+		long bundleID, boolean corrected) throws Throwable;
+	public boolean isBundleStaleReferenceCorrected(
+		long bundleID) throws Throwable;
 	
 	// THE FOLLOWING METHODS ARE DEBUGGING HELPERS
 	// THEY SHOULD BE REMOVED IN PRODUCTION
 	
-	public void dumpClassLoaderBundles();
-	public void setBundleStaleReferenceCorrected(String bundleNameOrID, String corrected) throws Exception;
-	public void isBundleStaleReferenceCorrected(String bundleNameOrID) throws Exception;
+	public void dumpClassLoaderBundles() throws Throwable;
+	public void setBundleStaleReferenceCorrected(
+		String bundleNameOrID, String corrected) throws Throwable;
+	public void isBundleStaleReferenceCorrected(
+		String bundleNameOrID) throws Throwable;
 }

Modified: vmkit/trunk/incinerator/osgi/src/j3mgr/J3MgrImpl.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/osgi/src/j3mgr/J3MgrImpl.java?rev=180523&r1=180522&r2=180523&view=diff
==============================================================================
--- vmkit/trunk/incinerator/osgi/src/j3mgr/J3MgrImpl.java (original)
+++ vmkit/trunk/incinerator/osgi/src/j3mgr/J3MgrImpl.java Thu Apr 25 12:19:49 2013
@@ -27,17 +27,22 @@ public class J3MgrImpl
 		context = null;
 	}
 
-	public void setBundleStaleReferenceCorrected(long bundleID, boolean corrected) throws Exception
+	public void setBundleStaleReferenceCorrected(
+		long bundleID, boolean corrected) throws Throwable
 	{
 		j3.vm.OSGi.setBundleStaleReferenceCorrected(bundleID, corrected);
 		
-		if (corrected && (context.getBundle(bundleID) == null)) {
-			j3.vm.OSGi.notifyBundleUninstalled(bundleID);
-			refreshFramework();
-		}
+		if (!corrected || (context.getBundle(bundleID) != null))
+			return;	// Bundle ignored, or still installed
+		
+		// Inexistent bundle to be corrected, probably uninstalled,
+		// Notify the VM now.
+		j3.vm.OSGi.notifyBundleUninstalled(bundleID);
+		refreshFramework();
 	}
 
-	public boolean isBundleStaleReferenceCorrected(long bundleID) throws Exception
+	public boolean isBundleStaleReferenceCorrected(
+		long bundleID) throws Throwable
 	{
 		return j3.vm.OSGi.isBundleStaleReferenceCorrected(bundleID);
 	}
@@ -45,14 +50,18 @@ public class J3MgrImpl
 	public void bundleChanged(BundleEvent event)
 	{
 		if (event.getType() != BundleEvent.UNINSTALLED) return;
-		j3.vm.OSGi.notifyBundleUninstalled(event.getBundle().getBundleId());
-		refreshFramework();
+		
+		try {
+			j3.vm.OSGi.notifyBundleUninstalled(event.getBundle().getBundleId());
+			refreshFramework();
+		} catch (Throwable e) {}
 	}
 	
 	void refreshFramework()
 	{
-		ServiceReference<?> pkgAdminRef = (ServiceReference<?>)context.getServiceReference(
-			"org.osgi.service.packageadmin.PackageAdmin");
+		ServiceReference<?> pkgAdminRef =
+			(ServiceReference<?>)context.getServiceReference(
+				"org.osgi.service.packageadmin.PackageAdmin");
 		PackageAdmin pkgAdmin = (PackageAdmin)context.getService(pkgAdminRef);
 		pkgAdmin.refreshPackages(null);
 		context.ungetService(pkgAdminRef);
@@ -61,17 +70,25 @@ public class J3MgrImpl
 	// THE FOLLOWING METHODS ARE DEBUGGING HELPERS
 	// THEY SHOULD BE REMOVED IN PRODUCTION
 	
-	public void setBundleStaleReferenceCorrected(String bundleNameOrID, String corrected) throws Exception
+	public void setBundleStaleReferenceCorrected(
+		String bundleNameOrID, String corrected) throws Throwable
 	{
 		long bundleID = getBundleID(bundleNameOrID);
+		if (bundleID == -1) throw new IllegalArgumentException(bundleNameOrID);
+
 		setBundleStaleReferenceCorrected(bundleID, corrected.equals("yes"));
 	}
 	
-	public void isBundleStaleReferenceCorrected(String bundleNameOrID) throws Exception
+	public void isBundleStaleReferenceCorrected(
+		String bundleNameOrID) throws Throwable
 	{
 		long bundleID = getBundleID(bundleNameOrID);
+		if (bundleID == -1) throw new IllegalArgumentException(bundleNameOrID);
+		
 		boolean value = isBundleStaleReferenceCorrected(bundleID);
-		System.out.println("isBundleStaleReferenceCorrected(bundleID=" + bundleID + ") = " + (value ? "yes" : "no"));
+		System.out.println(
+			"isBundleStaleReferenceCorrected(bundleID=" + bundleID + ") = " +
+			(value ? "yes" : "no"));
 	}
 
 	long getBundleID(String symbolicNameOrID)
@@ -79,8 +96,11 @@ public class J3MgrImpl
 		try {
 			long bundleID = Long.parseLong(symbolicNameOrID);
 			
-			if (context.getBundle(bundleID) == null)
-				System.out.println("WARNING: bundleID=" + bundleID + " is invalid.");
+			if (context.getBundle(bundleID) == null) {
+				System.out.println(
+					"WARNING: bundleID=" + bundleID +
+					" is invalid, probably already uninstalled.");
+			}
 			
 			return (bundleID < 0) ? -1 : bundleID;
 		} catch (NumberFormatException e) {
@@ -95,7 +115,7 @@ public class J3MgrImpl
 		return -1;
 	}
 
-	public void dumpClassLoaderBundles()
+	public void dumpClassLoaderBundles() throws Throwable
 	{
 		j3.vm.OSGi.dumpClassLoaderBundles();
 	}

Modified: vmkit/trunk/incinerator/tests/ijvm.tests.BundleMgmtStress/src/ijvm/tests/BundleMgmtStress/Activator.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/incinerator/tests/ijvm.tests.BundleMgmtStress/src/ijvm/tests/BundleMgmtStress/Activator.java?rev=180523&r1=180522&r2=180523&view=diff
==============================================================================
--- vmkit/trunk/incinerator/tests/ijvm.tests.BundleMgmtStress/src/ijvm/tests/BundleMgmtStress/Activator.java (original)
+++ vmkit/trunk/incinerator/tests/ijvm.tests.BundleMgmtStress/src/ijvm/tests/BundleMgmtStress/Activator.java Thu Apr 25 12:19:49 2013
@@ -12,8 +12,8 @@ public class Activator
 	implements BundleActivator, Runnable
 {
 	static final boolean correctStaleReferences = false;
-	static final String targetBundle = "file:///home/koutheir/PhD/VMKit/knopflerfish/osgi/jars/http/http_all-3.1.2.jar";
-	static final long firstBundleID = 8;
+	static final String targetBundle = "file:///home/koutheir/PhD/VMKit/knopflerfish.verbatim/osgi/jars/http/http_all-3.1.2.jar";
+	static final long firstBundleID = 6;
 	
 	BundleContext context;
 	Thread worker;
@@ -89,7 +89,6 @@ public class Activator
 				currentState == Bundle.STARTING) {
 				thisBundle.stop();
 			}
-			worker = null;
 		} catch (BundleException e) {
 			e.printStackTrace();
 		}
@@ -97,8 +96,6 @@ public class Activator
 	
 	void uninstallBundle(Bundle bundle) throws Throwable
 	{	
-		if (bundle == null) return;
-		
 		try {
 			j3mgr.setBundleStaleReferenceCorrected(
 				bundle.getBundleId(), correctStaleReferences);





More information about the vmkit-commits mailing list