Repository: celix
Updated Branches:
  refs/heads/develop 6f85bf3c2 -> f542c25f0


CELIX-104: Adds default admin url and identifation for config_admin when no url 
and/or id is provided


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/f542c25f
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/f542c25f
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/f542c25f

Branch: refs/heads/develop
Commit: f542c25f0efce420d075b731f57943cb04f8be1f
Parents: 6f85bf3
Author: Pepijn Noltes <[email protected]>
Authored: Wed Jul 6 13:26:38 2016 +0200
Committer: Pepijn Noltes <[email protected]>
Committed: Wed Jul 6 13:26:38 2016 +0200

----------------------------------------------------------------------
 deployment_admin/private/src/deployment_admin.c | 41 ++++++++++++--------
 framework/private/src/bundle.c                  |  1 -
 2 files changed, 25 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/f542c25f/deployment_admin/private/src/deployment_admin.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_admin.c 
b/deployment_admin/private/src/deployment_admin.c
index 74cb6a8..1364dd4 100644
--- a/deployment_admin/private/src/deployment_admin.c
+++ b/deployment_admin/private/src/deployment_admin.c
@@ -57,7 +57,11 @@
 #include "miniunz.h"
 
 #define IDENTIFICATION_ID "deployment_admin_identification"
-#define DISCOVERY_URL "deployment_admin_url"
+#define DEFAULT_IDENTIFICATION_ID "celix"
+
+#define ADMIN_URL "deployment_admin_url"
+#define DEFAULT_ADMIN_URL "localhost:8080"
+
 #define DEPLOYMENT_CACHE_DIR "deployment_cache_dir"
 #define DEPLOYMENT_TAGS "deployment_tags"
 // "http://localhost:8080/deployment/";
@@ -98,6 +102,11 @@ celix_status_t deploymentAdmin_create(bundle_context_pt 
context, deployment_admi
                (*admin)->auditlogUrl = NULL;
 
         bundleContext_getProperty(context, IDENTIFICATION_ID, (const char**) 
&(*admin)->targetIdentification);
+        if ((*admin)->targetIdentification == NULL) {
+               (*admin)->targetIdentification = DEFAULT_IDENTIFICATION_ID;
+               fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Identification ID not 
set, using default '%s'. Set id by using '%s'",
+                       DEFAULT_IDENTIFICATION_ID, IDENTIFICATION_ID);
+        }
 
         struct timeval tv;
                gettimeofday(&tv,NULL);
@@ -106,25 +115,26 @@ celix_status_t deploymentAdmin_create(bundle_context_pt 
context, deployment_admi
 
                if ((*admin)->targetIdentification == NULL ) {
                    fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Target name must 
be set using \"deployment_admin_identification\"");
-                       status = CELIX_ILLEGAL_ARGUMENT;
                } else {
                        const char *url = NULL;
-                       bundleContext_getProperty(context, DISCOVERY_URL, &url);
+                       bundleContext_getProperty(context, ADMIN_URL, &url);
                        if (url == NULL) {
-                           fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "URL must 
be set using \"deployment_admin_url\"\n");
-                               status = CELIX_ILLEGAL_ARGUMENT;
-                       } else {
-                               int pollUrlLength = strlen(url) + 
strlen((*admin)->targetIdentification) + strlen(VERSIONS) + 13;
-                               int auditlogUrlLength = strlen(url) + 10;
+                               url = DEFAULT_ADMIN_URL;
+                           fw_log(logger, OSGI_FRAMEWORK_LOG_INFO, "Server URL 
is not set, using default '%s'. Set id by using '%s'",
+                               DEFAULT_ADMIN_URL, ADMIN_URL);
+                       }
+               
+                       int pollUrlLength = strlen(url) + 
strlen((*admin)->targetIdentification) + strlen(VERSIONS) + 13;
+                       int auditlogUrlLength = strlen(url) + 10;
 
-                               char pollUrl[pollUrlLength];
-                               char auditlogUrl[auditlogUrlLength];
+                       char pollUrl[pollUrlLength];
+                       char auditlogUrl[auditlogUrlLength];
 
-                               snprintf(pollUrl, pollUrlLength, 
"%s/deployment/%s%s", url, (*admin)->targetIdentification, VERSIONS);
-                               snprintf(auditlogUrl, auditlogUrlLength, 
"%s/auditlog", url);
+                       snprintf(pollUrl, pollUrlLength, "%s/deployment/%s%s", 
url, (*admin)->targetIdentification, VERSIONS);
+                       snprintf(auditlogUrl, auditlogUrlLength, "%s/auditlog", 
url);
 
-                               (*admin)->pollUrl = strdup(pollUrl);
-                               (*admin)->auditlogUrl = strdup(auditlogUrl);
+                       (*admin)->pollUrl = strdup(pollUrl);
+                       (*admin)->auditlogUrl = strdup(auditlogUrl);
 
 //                             log_store_pt store = NULL;
 //                             log_pt log = NULL;
@@ -136,8 +146,7 @@ celix_status_t deploymentAdmin_create(bundle_context_pt 
context, deployment_admi
 //                             log_log(log, 20000, NULL);
 
 
-                               celixThread_create(&(*admin)->poller, NULL, 
deploymentAdmin_poll, *admin);
-                       }
+                       celixThread_create(&(*admin)->poller, NULL, 
deploymentAdmin_poll, *admin);
                }
        }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/f542c25f/framework/private/src/bundle.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle.c b/framework/private/src/bundle.c
index 8e50a42..fbd25b9 100644
--- a/framework/private/src/bundle.c
+++ b/framework/private/src/bundle.c
@@ -67,7 +67,6 @@ celix_status_t bundle_create(bundle_pt * bundle) {
                        (*bundle)->lockThread = celix_thread_default;
         }
        }
-
        framework_logIfError(logger, status, NULL, "Failed to create bundle");
 
        return status;

Reply via email to