You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xbean-scm@geronimo.apache.org by xu...@apache.org on 2011/01/10 02:36:04 UTC
svn commit: r1057070 -
/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
Author: xuhaihong
Date: Mon Jan 10 01:36:04 2011
New Revision: 1057070
URL: http://svn.apache.org/viewvc?rev=1057070&view=rev
Log:
Add resolve related util methods
Modified:
geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
Modified: geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java?rev=1057070&r1=1057069&r2=1057070&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java (original)
+++ geronimo/xbean/trunk/xbean-bundleutils/src/main/java/org/apache/xbean/osgi/bundle/util/BundleUtils.java Mon Jan 10 01:36:04 2011
@@ -38,14 +38,59 @@ import org.osgi.service.packageadmin.Pac
*/
public class BundleUtils {
+ /**
+ * Based on the constant field values, if it is bigger than the RESOLVED status value, the bundle has been resolved by the framework
+ * @param bundle
+ * @return true if the bundle is resolved, or false if not.
+ */
+ public static boolean isResolved(Bundle bundle) {
+ return bundle.getState() >= Bundle.RESOLVED;
+ }
+
+ /**
+ * resolve method will try to load the Object.class, the behavior triggers a resolved request to the OSGI framework.
+ * @param bundle
+ */
+ public static void resolve(Bundle bundle) {
+ if (isFragment(bundle)) {
+ return;
+ }
+ try {
+ bundle.loadClass(Object.class.getName());
+ } catch (Exception e) {
+ }
+ }
+
+ /**
+ * If the bundle fulfills the conditions below, it could be started
+ * a. Not in the UNINSTALLED status.
+ * b. Not in the STARTING status.
+ * c. Not a fragment bundle.
+ * @param bundle
+ * @return
+ */
public static boolean canStart(Bundle bundle) {
return (bundle.getState() != Bundle.UNINSTALLED) && (bundle.getState() != Bundle.STARTING) && (!isFragment(bundle));
}
+ /**
+ * If the bundle fulfills the conditions below, it could be stopped
+ * a. Not in the UNINSTALLED status.
+ * b. Not in the STOPPING status.
+ * c. Not a fragment bundle.
+ * @param bundle
+ * @return
+ */
public static boolean canStop(Bundle bundle) {
return (bundle.getState() != Bundle.UNINSTALLED) && (bundle.getState() != Bundle.STOPPING) && (!isFragment(bundle));
}
+ /**
+ * If the bundle fulfills the conditions below, it could be un-installed
+ * a. Not in the UNINSTALLED status.
+ * @param bundle
+ * @return
+ */
public static boolean canUninstall(Bundle bundle) {
return bundle.getState() != Bundle.UNINSTALLED;
}