celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1655822 - in /celix/trunk/examples: ./ embedding/private/src/ hello_world/private/src/ hello_world_test/private/src/ mongoose/ mongoose/private/src/ osgi-in-action/chapter01-greeting-example/greeting/private/src/ whiteboard/publisherA/priv...
Date Thu, 29 Jan 2015 19:27:51 GMT
Author: abroekhuis
Date: Thu Jan 29 19:27:51 2015
New Revision: 1655822

URL: http://svn.apache.org/r1655822
Log:
CELIX-208: Remove APR from examples

Modified:
    celix/trunk/examples/CMakeLists.txt
    celix/trunk/examples/deploy.cmake
    celix/trunk/examples/embedding/private/src/main.c
    celix/trunk/examples/hello_world/private/src/activator.c
    celix/trunk/examples/hello_world_test/private/src/activator.c
    celix/trunk/examples/mongoose/CMakeLists.txt
    celix/trunk/examples/mongoose/private/src/activator.c
    celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
    celix/trunk/examples/whiteboard/publisherA/private/src/activator.c
    celix/trunk/examples/whiteboard/publisherB/private/src/activator.c

Modified: celix/trunk/examples/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/examples/CMakeLists.txt?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/CMakeLists.txt (original)
+++ celix/trunk/examples/CMakeLists.txt Thu Jan 29 19:27:51 2015
@@ -18,7 +18,7 @@ celix_subproject(EXAMPLES "Option to ena
 if (EXAMPLES)
     add_subdirectory(hello_world)
     add_subdirectory(hello_world_test)
-    #add_subdirectory(mongoose)
+    add_subdirectory(mongoose)
     
     add_subdirectory(whiteboard)
     add_subdirectory(echo_service)

Modified: celix/trunk/examples/deploy.cmake
URL: http://svn.apache.org/viewvc/celix/trunk/examples/deploy.cmake?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/deploy.cmake (original)
+++ celix/trunk/examples/deploy.cmake Thu Jan 29 19:27:51 2015
@@ -23,4 +23,5 @@ if (EXAMPLES)
 	deploy("wb" BUNDLES tracker publisherA publisherB shell shell_tui log_service log_writer)
 	deploy("wb_dp" BUNDLES tracker_depman publisherA publisherB shell shell_tui log_service
log_writer)
 	deploy("echo" BUNDLES echo_server echo_client shell shell_tui)
+	deploy("mongoose" BUNDLES shell shell_tui log_service apache_celix_examples_mongoose)
 endif (EXAMPLES)
\ No newline at end of file

Modified: celix/trunk/examples/embedding/private/src/main.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/embedding/private/src/main.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/embedding/private/src/main.c (original)
+++ celix/trunk/examples/embedding/private/src/main.c Thu Jan 29 19:27:51 2015
@@ -67,8 +67,8 @@ int main(void) {
 	bundle_context_pt context = NULL;
 	bundle_getContext(fwBundle, &context);
 
-	struct foo *f = apr_palloc(memoryPool, sizeof(*f));
-	struct fooSrv *fs = apr_palloc(memoryPool, sizeof(*fs));
+	struct foo *f = calloc(1, sizeof(*f));
+	struct fooSrv *fs = calloc(1, sizeof(*fs));
 	fs->handle = f;
 	fs->foo = embedded_foo;
 

Modified: celix/trunk/examples/hello_world/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/hello_world/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/hello_world/private/src/activator.c (original)
+++ celix/trunk/examples/hello_world/private/src/activator.c Thu Jan 29 19:27:51 2015
@@ -25,7 +25,6 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
-#include <apr_general.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"

Modified: celix/trunk/examples/hello_world_test/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/hello_world_test/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/hello_world_test/private/src/activator.c (original)
+++ celix/trunk/examples/hello_world_test/private/src/activator.c Thu Jan 29 19:27:51 2015
@@ -25,7 +25,6 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
-#include <apr_general.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"

Modified: celix/trunk/examples/mongoose/CMakeLists.txt
URL: http://svn.apache.org/viewvc/celix/trunk/examples/mongoose/CMakeLists.txt?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/mongoose/CMakeLists.txt (original)
+++ celix/trunk/examples/mongoose/CMakeLists.txt Thu Jan 29 19:27:51 2015
@@ -18,17 +18,24 @@
 add_library(mongoose STATIC private/src/mongoose.c)
 SET_TARGET_PROPERTIES(mongoose PROPERTIES COMPILE_FLAGS -fPIC)
 
+SET(BUNDLE_SYMBOLICNAME "apache_celix_examples_mongoose")
+SET(BUNDLE_VERSION "0.0.1")
+
 include_directories("private/include")
 include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-bundle(celix.mongoose SOURCES
-    private/src/activator
-    
-    private/include/mongoose.h
-    DIRECTORIES root
-)
 
-target_link_libraries(celix.mongoose celix_framework mongoose)
 if(WIN32)
-	target_link_libraries(celix.mongoose wsock32)
+	  set(LIBS wsock32)
 endif(WIN32)
 
+bundle(
+    SOURCES
+        private/src/activator
+    
+        private/include/mongoose.h
+    DIRECTORIES 
+        root
+    LINK_LIBRARIES
+        celix_framework mongoose ${LIBS}
+        
+)
\ No newline at end of file

Modified: celix/trunk/examples/mongoose/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/mongoose/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/mongoose/private/src/activator.c (original)
+++ celix/trunk/examples/mongoose/private/src/activator.c Thu Jan 29 19:27:51 2015
@@ -25,7 +25,6 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
-#include <apr_general.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"
@@ -37,9 +36,7 @@ struct userData {
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	apr_pool_t *pool;
-	celix_status_t status = bundleContext_getMemoryPool(context, &pool);
-	*userData = apr_palloc(pool, sizeof(struct userData));
+	*userData = calloc(1, sizeof(struct userData));
 	return CELIX_SUCCESS;
 }
 
@@ -49,23 +46,21 @@ celix_status_t bundleActivator_start(voi
 	struct userData * data = (struct userData *) userData;
 
 	if (bundleContext_getBundle(context, &bundle) == CELIX_SUCCESS) {
-	    apr_pool_t *pool;
-	    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
-	    if (status == CELIX_SUCCESS) {
-			char *entry = NULL;
-			const char *options[] = {
-                "document_root", entry,
-                "listening_ports", "8081",
-                NULL
-            };
-            bundle_getEntry(bundle, "root", pool, &entry);
-
-            data->ctx = mg_start(NULL, options);
-
-            printf("Mongoose started on: %s\n", mg_get_option(data->ctx, "listening_ports"));
-	    } else {
-	        status = CELIX_BUNDLE_EXCEPTION;
-	    }
+		char *entry = NULL;
+		bundle_getEntry(bundle, "root", &entry);
+		const char *options[] = {
+			"document_root", entry,
+			"listening_ports", "8081",
+			NULL
+		};
+
+		printf("entry %p\n", entry);
+
+		data->ctx = mg_start(NULL, options);
+
+		if (data->ctx) {
+			printf("Mongoose started on: %s\n", mg_get_option(data->ctx, "listening_ports"));
+		}
 	} else {
 		status = CELIX_START_ERROR;
 	}
@@ -81,5 +76,6 @@ celix_status_t bundleActivator_stop(void
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	free(userData);
 	return CELIX_SUCCESS;
 }

Modified: celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
(original)
+++ celix/trunk/examples/osgi-in-action/chapter01-greeting-example/greeting/private/src/activator.c
Thu Jan 29 19:27:51 2015
@@ -25,7 +25,6 @@
  */
 #include <stdlib.h>
 #include <stdio.h>
-#include <apr_general.h>
 
 #include "bundle_activator.h"
 #include "bundle_context.h"
@@ -35,24 +34,20 @@
 
 struct greetingActivator {
 	service_registration_pt reg;
-	apr_pool_t *pool;
+	greeting_service_pt greetingService;
 };
 
 typedef struct greetingActivator *greeting_activator_pt;
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-	apr_pool_t *pool;
+	celix_status_t status = CELIX_SUCCESS;
 	greeting_activator_pt activator;
-	celix_status_t status = bundleContext_getMemoryPool(context, &pool);
-	if (status == CELIX_SUCCESS) {
-		*userData = apr_palloc(pool, sizeof(struct greetingActivator));
-		if (userData) {
-			activator = *userData;
-			activator->reg = NULL;
-			activator->pool = pool;
-		} else {
-			status = CELIX_ENOMEM;
-		}
+	*userData = calloc(1, sizeof(struct greetingActivator));
+	if (userData) {
+		activator = *userData;
+		activator->reg = NULL;
+	} else {
+		status = CELIX_ENOMEM;
 	}
 	return status;
 }
@@ -62,15 +57,15 @@ celix_status_t bundleActivator_start(voi
 
 	greeting_activator_pt act = (greeting_activator_pt) userData;
 
-	greeting_service_pt greetingService = apr_palloc(act->pool, sizeof(*greetingService));
+	act->greetingService = calloc(1, sizeof(*act->greetingService));
 
-	if (greetingService) {
-		greetingService->instance = apr_palloc(act->pool, sizeof(*greetingService->instance));
-		if (greetingService->instance) {
-			greetingService->instance->name = GREETING_SERVICE_NAME;
-			greetingService->greeting_sayHello = greeting_sayHello;
+	if (act->greetingService) {
+		act->greetingService->instance = calloc(1, sizeof(*act->greetingService->instance));
+		if (act->greetingService->instance) {
+			act->greetingService->instance->name = GREETING_SERVICE_NAME;
+			act->greetingService->greeting_sayHello = greeting_sayHello;
 
-			status = bundleContext_registerService(context, GREETING_SERVICE_NAME, greetingService,
NULL, &act->reg);
+			status = bundleContext_registerService(context, GREETING_SERVICE_NAME, act->greetingService,
NULL, &act->reg);
 		} else {
 			status = CELIX_ENOMEM;
 		}
@@ -82,12 +77,19 @@ celix_status_t bundleActivator_start(voi
 
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
+
 	greeting_activator_pt act = (greeting_activator_pt) userData;
+
 	serviceRegistration_unregister(act->reg);
 	act->reg = NULL;
+
+	free(act->greetingService->instance);
+	free(act->greetingService);
+
 	return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	free(userData);
 	return CELIX_SUCCESS;
 }

Modified: celix/trunk/examples/whiteboard/publisherA/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/whiteboard/publisherA/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/whiteboard/publisherA/private/src/activator.c (original)
+++ celix/trunk/examples/whiteboard/publisherA/private/src/activator.c Thu Jan 29 19:27:51
2015
@@ -39,41 +39,30 @@ struct activatorData {
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    apr_pool_t *pool;
-    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
-    if (status == CELIX_SUCCESS) {
-        *userData = apr_palloc(pool, sizeof(struct activatorData));
-    } else {
-        status = CELIX_START_ERROR;
-    }
+	*userData = calloc(1, sizeof(struct activatorData));
     return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
-    apr_pool_t *pool;
-    status = bundleContext_getMemoryPool(context, &pool);
-    if (status == CELIX_SUCCESS) {
-		properties_pt props = NULL;
-
-        struct activatorData * data = (struct activatorData *) userData;
-        data->ps = apr_pcalloc(pool, sizeof(*(data->ps)));
-        data->pub = apr_pcalloc(pool, sizeof(*(data->pub)));
-        data->ps->invoke = publisher_invoke;
-        data->ps->publisher = data->pub;
-        data->reg = NULL;
-
-        props = properties_create();
-        properties_set(props, "id", "A");
-
-        status = bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props,
&data->reg);
-        if (status != CELIX_SUCCESS) {
-        	char error[256];
-        	printf("Error: %s\n", celix_strerror(status, error, 256));
-        }
-    } else {
-        status = CELIX_BUNDLE_EXCEPTION;
-    }
+	properties_pt props = NULL;
+
+	struct activatorData * data = (struct activatorData *) userData;
+	data->ps = calloc(1, sizeof(*(data->ps)));
+	data->pub = calloc(1, sizeof(*(data->pub)));
+	data->ps->invoke = publisher_invoke;
+	data->ps->publisher = data->pub;
+	data->reg = NULL;
+
+	props = properties_create();
+	properties_set(props, "id", "A");
+
+	status = bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
+	if (status != CELIX_SUCCESS) {
+		char error[256];
+		printf("Error: %s\n", celix_strerror(status, error, 256));
+	}
+
     return status;
 }
 
@@ -83,9 +72,13 @@ celix_status_t bundleActivator_stop(void
     struct activatorData * data = (struct activatorData *) userData;
     serviceRegistration_unregister(data->reg);
 
+    free(data->ps);
+    free(data->pub);
+
     return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	free(userData);
     return CELIX_SUCCESS;
 }

Modified: celix/trunk/examples/whiteboard/publisherB/private/src/activator.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/whiteboard/publisherB/private/src/activator.c?rev=1655822&r1=1655821&r2=1655822&view=diff
==============================================================================
--- celix/trunk/examples/whiteboard/publisherB/private/src/activator.c (original)
+++ celix/trunk/examples/whiteboard/publisherB/private/src/activator.c Thu Jan 29 19:27:51
2015
@@ -38,36 +38,24 @@ struct activatorData {
 };
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
-    apr_pool_t *pool;
-    celix_status_t status = bundleContext_getMemoryPool(context, &pool);
-    if (status == CELIX_SUCCESS) {
-        *userData = apr_palloc(pool, sizeof(struct activatorData));
-    } else {
-        status = CELIX_START_ERROR;
-    }
+	*userData = calloc(1, sizeof(struct activatorData));
     return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
-    apr_pool_t *pool;
-    status = bundleContext_getMemoryPool(context, &pool);
-    if (status == CELIX_SUCCESS) {
-		properties_pt props = properties_create();
-
-        struct activatorData * data = (struct activatorData *) userData;
-        data->ps = apr_pcalloc(pool, sizeof(*(data->ps)));
-        data->pub = apr_pcalloc(pool, sizeof(*(data->pub)));
-        data->ps->invoke = publisher_invoke;
-        data->ps->publisher = data->pub;
-        data->reg = NULL;
-        
-		properties_set(props, "id", "B");
-
-    	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
-    } else {
-        status = CELIX_START_ERROR;
-    }
+	properties_pt props = properties_create();
+
+	struct activatorData * data = (struct activatorData *) userData;
+	data->ps = calloc(1, sizeof(*(data->ps)));
+	data->pub = calloc(1, sizeof(*(data->pub)));
+	data->ps->invoke = publisher_invoke;
+	data->ps->publisher = data->pub;
+	data->reg = NULL;
+
+	properties_set(props, "id", "B");
+
+	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
     return status;
 }
 
@@ -77,9 +65,13 @@ celix_status_t bundleActivator_stop(void
     struct activatorData * data = (struct activatorData *) userData;
 	serviceRegistration_unregister(data->reg);
 
+	free(data->pub);
+	free(data->ps);
+
     return status;
 }
 
 celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	free(userData);
     return CELIX_SUCCESS;
 }



Mime
View raw message