Author: abroekhuis
Date: Wed Oct  2 09:08:43 2013
New Revision: 1528388

URL: http://svn.apache.org/r1528388
Log:
CELIX-58: Added BUNDLE_UNKNOWN state for easier handling of the bundle state

Modified:
    incubator/celix/trunk/framework/private/src/bundle_archive.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/public/include/bundle_state.h

Modified: incubator/celix/trunk/framework/private/src/bundle_archive.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_archive.c?rev=1528388&r1=1528387&r2=1528388&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Wed Oct  2 
09:08:43 2013
@@ -86,6 +86,7 @@ celix_status_t bundleArchive_createSyste
                     archive->archiveRoot = NULL;
                     archive->archiveRootDir = NULL;
                     archive->refreshCount = -1;
+                    archive->persistentState = BUNDLE_UNKNOWN;
                     time(&archive->lastModified);
 
                     *bundle_archive = archive;
@@ -310,7 +311,7 @@ celix_status_t bundleArchive_getPersiste
        celix_status_t status = CELIX_SUCCESS;
        apr_status_t apr_status;
 
-       if (archive->persistentState >= 0) {
+       if (archive->persistentState != BUNDLE_UNKNOWN) {
                *state = archive->persistentState;
        } else {
                apr_file_t *persistentStateLocationFile;

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1528388&r1=1528387&r2=1528388&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Wed Oct  2 09:08:43 
2013
@@ -680,6 +680,10 @@ celix_status_t fw_startBundle(framework_
        bundle_getState(bundle, &state);
 
        switch (state) {
+               case BUNDLE_UNKNOWN:
+                       printf("Cannot start bundle since its state is 
unknown.");
+                       framework_releaseBundleLock(framework, bundle);
+                       return CELIX_ILLEGAL_STATE;
                case BUNDLE_UNINSTALLED:
                        printf("Cannot start bundle since it is uninstalled.");
                        framework_releaseBundleLock(framework, bundle);
@@ -877,6 +881,10 @@ celix_status_t fw_stopBundle(framework_p
                bundle_getState(bundle, &state);
 
                switch (state) {
+                       case BUNDLE_UNKNOWN:
+                               printf("Cannot stop bundle since its state is 
unknown.");
+                               framework_releaseBundleLock(framework, bundle);
+                               return CELIX_ILLEGAL_STATE;
                        case BUNDLE_UNINSTALLED:
                                printf("Cannot stop bundle since it is 
uninstalled.");
                                framework_releaseBundleLock(framework, bundle);

Modified: incubator/celix/trunk/framework/public/include/bundle_state.h
URL: 
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/bundle_state.h?rev=1528388&r1=1528387&r2=1528388&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/bundle_state.h (original)
+++ incubator/celix/trunk/framework/public/include/bundle_state.h Wed Oct  2 
09:08:43 2013
@@ -29,6 +29,7 @@
 
 enum bundleState
 {
+       BUNDLE_UNKNOWN = 0x00000000,
        BUNDLE_UNINSTALLED = 0x00000001,
        BUNDLE_INSTALLED = 0x00000002,
        BUNDLE_RESOLVED = 0x00000004,


Reply via email to