incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1245362 - in /incubator/celix/trunk/deployment_admin/private: include/deployment_admin.h src/deployment_admin.c
Date Fri, 17 Feb 2012 10:00:44 GMT
Author: abroekhuis
Date: Fri Feb 17 10:00:44 2012
New Revision: 1245362

URL: http://svn.apache.org/viewvc?rev=1245362&view=rev
Log:
Deployment Admin configuration

Added configuration parameters to the deployment admin

Modified:
    incubator/celix/trunk/deployment_admin/private/include/deployment_admin.h
    incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c

Modified: incubator/celix/trunk/deployment_admin/private/include/deployment_admin.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/include/deployment_admin.h?rev=1245362&r1=1245361&r2=1245362&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/include/deployment_admin.h (original)
+++ incubator/celix/trunk/deployment_admin/private/include/deployment_admin.h Fri Feb 17 10:00:44
2012
@@ -22,6 +22,8 @@ struct deployment_admin {
 	bool running;
 	char *current;
 	HASH_MAP packages;
+	char *targetIdentification;
+	char *pollUrl;
 };
 
 celix_status_t deploymentAdmin_create(apr_pool_t *pool, BUNDLE_CONTEXT context, deployment_admin_t
*admin);

Modified: incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c?rev=1245362&r1=1245361&r2=1245362&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c (original)
+++ incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c Fri Feb 17 10:00:44
2012
@@ -23,7 +23,11 @@
 
 #include "resource_processor.h"
 
-#define VERSIONS "http://localhost:8080/deployment/test/versions"
+#define IDENTIFICATION_ID "deployment_admin.identification"
+#define DISCOVERY_URL "deployment_admin.url"
+// "http://localhost:8080/deployment/"
+
+#define VERSIONS "/versions"
 
 static void *APR_THREAD_FUNC deploymentAdmin_poll(apr_thread_t *thd, void *deploymentAdmin);
 celix_status_t deploymentAdmin_download(char * url, char **inputFile);
@@ -53,7 +57,24 @@ celix_status_t deploymentAdmin_create(ap
 		(*admin)->context = context;
 		(*admin)->current = NULL;
 		(*admin)->packages = hashMap_create(string_hash, NULL, string_equals, NULL);
-		apr_thread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin, subpool);
+		(*admin)->targetIdentification = NULL;
+		(*admin)->pollUrl = NULL;
+        bundleContext_getProperty(context, IDENTIFICATION_ID, &(*admin)->targetIdentification);
+		if ((*admin)->targetIdentification == NULL ) {
+			printf("Target name must be set using \"deployment_admin.identification\"\n");
+			status = CELIX_ILLEGAL_ARGUMENT;
+		} else {
+			char *url = NULL;
+			bundleContext_getProperty(context, DISCOVERY_URL, &url);
+			if (url == NULL) {
+				printf("URL must be set using \"deployment_admin.url\"\n");
+				status = CELIX_ILLEGAL_ARGUMENT;
+			} else {
+				(*admin)->pollUrl = apr_pstrcat(subpool, url, (*admin)->targetIdentification, VERSIONS);
+
+				apr_thread_create(&(*admin)->poller, NULL, deploymentAdmin_poll, *admin, subpool);
+			}
+		}
 	}
 
 	return status;
@@ -74,11 +95,11 @@ static void *APR_THREAD_FUNC deploymentA
 			printf("install version: %s\n", last);
 			char *request = NULL;
 			if (admin->current == NULL) {
-				request = apr_pstrcat(admin->pool, VERSIONS, "/", last, NULL);
+				request = apr_pstrcat(admin->pool, admin->pollUrl, "/", last, NULL);
 			} else {
 				// We do not yet support fix packages
 				//request = apr_pstrcat(admin->pool, VERSIONS, "/", last, "?current=", admin->current,
NULL);
-				request = apr_pstrcat(admin->pool, VERSIONS, "/", last, NULL);
+				request = apr_pstrcat(admin->pool, admin->pollUrl, "/", last, NULL);
 			}
 			printf("Request: %s\n", request);
 
@@ -180,7 +201,7 @@ celix_status_t deploymentAdmin_readVersi
 	chunk.memory = malloc(1);
 	chunk.size = 0;
 	if (curl) {
-		curl_easy_setopt(curl, CURLOPT_URL, VERSIONS);
+		curl_easy_setopt(curl, CURLOPT_URL, admin->pollUrl);
 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, deploymentAdmin_parseVersions);
 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);
 		curl_easy_setopt(curl, CURLOPT_FAILONERROR, true);



Mime
View raw message