Author: abroekhuis
Date: Wed Jul 27 08:35:16 2011
New Revision: 1151377
URL: http://svn.apache.org/viewvc?rev=1151377&view=rev
Log:
Updated error handling, fixed a bug in the dependency manager
Modified:
incubator/celix/trunk/framework/private/include/bundle.h
incubator/celix/trunk/framework/private/src/framework.c
Modified: incubator/celix/trunk/framework/private/include/bundle.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle.h?rev=1151377&r1=1151376&r2=1151377&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle.h Wed Jul 27
08:35:16 2011
@@ -70,7 +70,11 @@ ARRAY_LIST getUsingBundles(SERVICE_REFER
int compareTo(SERVICE_REFERENCE a, SERVICE_REFERENCE b);
+<<<<<<< HEAD
celix_status_t bundle_getState(BUNDLE bundle, BUNDLE_STATE *state);
+=======
+BUNDLE_STATE bundle_getState(BUNDLE bundle);
+>>>>>>> Updated error handling, fixed a bug in the dependency manager
celix_status_t bundle_isLockable(BUNDLE bundle, bool *lockable);
celix_status_t bundle_getLockingThread(BUNDLE bundle, apr_os_thread_t *thread);
celix_status_t bundle_lock(BUNDLE bundle, bool *locked);
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1151377&r1=1151376&r2=1151377&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Jul 27 08:35:16
2011
@@ -653,6 +653,7 @@ celix_status_t fw_stopBundle(FRAMEWORK f
//if (!fw_isBundlePersistentlyStarted(framework, bundle)) {
//}
+<<<<<<< HEAD
BUNDLE_STATE state;
bundle_getState(bundle, &state);
@@ -714,6 +715,60 @@ celix_status_t fw_stopBundle(FRAMEWORK f
framework_setBundleStateAndNotify(framework, bundle,
BUNDLE_RESOLVED);
+=======
+ switch (bundle_getState(bundle)) {
+ case BUNDLE_UNINSTALLED:
+ printf("Cannot stop bundle since it is
uninstalled.");
+ framework_releaseBundleLock(framework, bundle);
+ return status;
+ case BUNDLE_STARTING:
+ printf("Cannot stop bundle since it is
starting.");
+ framework_releaseBundleLock(framework, bundle);
+ return status;
+ case BUNDLE_STOPPING:
+ printf("Cannot stop bundle since it is
stopping.");
+ framework_releaseBundleLock(framework, bundle);
+ return status;
+ case BUNDLE_INSTALLED:
+ case BUNDLE_RESOLVED:
+ framework_releaseBundleLock(framework, bundle);
+ return status;
+ case BUNDLE_ACTIVE:
+ // only valid state
+ break;
+ }
+
+ framework_setBundleStateAndNotify(framework, bundle,
BUNDLE_STOPPING);
+
+ ACTIVATOR activator = bundle_getActivator(bundle);
+ if (activator->stop != NULL) {
+ activator->stop(activator->userData,
bundle_getContext(bundle));
+ }
+
+ if (activator->destroy != NULL) {
+ activator->destroy(activator->userData,
bundle_getContext(bundle));
+ }
+
+ if (strcmp(module_getId(bundle_getCurrentModule(bundle)), "0")
!= 0) {
+ activator->start = NULL;
+ activator->stop = NULL;
+ activator->userData = NULL;
+ //free(activator);
+ bundle_setActivator(bundle, NULL);
+
+ serviceRegistry_unregisterServices(framework->registry,
bundle);
+ serviceRegistry_ungetServices(framework->registry,
bundle);
+
+ dlclose(bundle_getHandle(bundle));
+ }
+
+ bundleContext_destroy(bundle_getContext(bundle));
+ bundle_setContext(bundle, NULL);
+ manifest_destroy(bundle_getManifest(bundle));
+
+ framework_setBundleStateAndNotify(framework, bundle,
BUNDLE_RESOLVED);
+
+>>>>>>> Updated error handling, fixed a bug in the dependency manager
framework_releaseBundleLock(framework, bundle);
}
@@ -1258,9 +1313,13 @@ celix_status_t framework_acquireBundleLo
while (!lockable
|| ((framework->globalLockThread != NULL)
&& (framework->globalLockThread !=
pthread_self()))) {
+<<<<<<< HEAD
BUNDLE_STATE state;
bundle_getState(bundle, &state);
if ((desiredStates & state) == 0) {
+=======
+ if ((desiredStates & bundle_getState(bundle)) == 0) {
+>>>>>>> Updated error handling, fixed a bug in the dependency manager
status = CELIX_ILLEGAL_STATE;
break;
} else
@@ -1282,9 +1341,13 @@ celix_status_t framework_acquireBundleLo
}
if (status == CELIX_SUCCESS) {
+<<<<<<< HEAD
BUNDLE_STATE state;
bundle_getState(bundle, &state);
if ((desiredStates & state) == 0) {
+=======
+ if ((desiredStates & bundle_getState(bundle)) == 0) {
+>>>>>>> Updated error handling, fixed a bug in the dependency manager
status = CELIX_ILLEGAL_STATE;
} else {
if (bundle_lock(bundle, &locked)) {