incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1043916 - in /incubator/celix/trunk: echo_service/ echo_service/client/ echo_service/client/MANIFEST/ echo_service/server/ echo_service/server/MANIFEST/ remote/ whiteboard/ whiteboard/publisherA/ whiteboard/publisherA/MANIFEST/ whiteboard/...
Date Thu, 09 Dec 2010 11:59:20 GMT
Author: abroekhuis
Date: Thu Dec  9 11:59:18 2010
New Revision: 1043916

URL: http://svn.apache.org/viewvc?rev=1043916&view=rev
Log:
CELIX-1 initial code import

Added:
    incubator/celix/trunk/echo_service/
    incubator/celix/trunk/echo_service/CMakeLists.txt
    incubator/celix/trunk/echo_service/client/
    incubator/celix/trunk/echo_service/client/CMakeLists.txt
    incubator/celix/trunk/echo_service/client/MANIFEST/
    incubator/celix/trunk/echo_service/client/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/echo_service/client/echo_client.c
    incubator/celix/trunk/echo_service/client/echo_client_activator.c
    incubator/celix/trunk/echo_service/client/echo_client_private.h
    incubator/celix/trunk/echo_service/server/
    incubator/celix/trunk/echo_service/server/CMakeLists.txt
    incubator/celix/trunk/echo_service/server/MANIFEST/
    incubator/celix/trunk/echo_service/server/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/echo_service/server/echo_server.c
    incubator/celix/trunk/echo_service/server/echo_server.h
    incubator/celix/trunk/echo_service/server/echo_server_activator.c
    incubator/celix/trunk/echo_service/server/echo_server_private.h
    incubator/celix/trunk/remote/
    incubator/celix/trunk/remote/TestService.java
    incubator/celix/trunk/remote/test.service.proto
    incubator/celix/trunk/remote/test_service.h
    incubator/celix/trunk/whiteboard/
    incubator/celix/trunk/whiteboard/CMakeLists.txt
    incubator/celix/trunk/whiteboard/publisherA/
    incubator/celix/trunk/whiteboard/publisherA/CMakeLists.txt
    incubator/celix/trunk/whiteboard/publisherA/MANIFEST/
    incubator/celix/trunk/whiteboard/publisherA/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/whiteboard/publisherA/activator.c
    incubator/celix/trunk/whiteboard/publisherA/publisher.c
    incubator/celix/trunk/whiteboard/publisherB/
    incubator/celix/trunk/whiteboard/publisherB/CMakeLists.txt
    incubator/celix/trunk/whiteboard/publisherB/MANIFEST/
    incubator/celix/trunk/whiteboard/publisherB/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/whiteboard/publisherB/activator.c
    incubator/celix/trunk/whiteboard/publisherB/publisher.c
    incubator/celix/trunk/whiteboard/publisherService/
    incubator/celix/trunk/whiteboard/publisherService/publisher.h
    incubator/celix/trunk/whiteboard/publisherService/publisher_private.h
    incubator/celix/trunk/whiteboard/tracker/
    incubator/celix/trunk/whiteboard/tracker/CMakeLists.txt
    incubator/celix/trunk/whiteboard/tracker/MANIFEST/
    incubator/celix/trunk/whiteboard/tracker/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/whiteboard/tracker/activator.c
    incubator/celix/trunk/whiteboard/tracker_depman/
    incubator/celix/trunk/whiteboard/tracker_depman/CMakeLists.txt
    incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/
    incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF
    incubator/celix/trunk/whiteboard/tracker_depman/dependency_activator.c

Added: incubator/celix/trunk/echo_service/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/CMakeLists.txt (added)
+++ incubator/celix/trunk/echo_service/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,2 @@
+add_subdirectory(server)
+add_subdirectory(client)

Added: incubator/celix/trunk/echo_service/client/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/client/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/client/CMakeLists.txt (added)
+++ incubator/celix/trunk/echo_service/client/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,6 @@
+add_library(echo_client SHARED echo_client_activator echo_client)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+include_directories("../server")
+target_link_libraries(echo_client framework)
+
+bundle(echo_client)

Added: incubator/celix/trunk/echo_service/client/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/client/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/client/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/echo_service/client/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18 2010
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: echo_client
+Bundle-Version: 1.0.0
+library: echo_client
+Import-Service: echo_server

Added: incubator/celix/trunk/echo_service/client/echo_client.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/client/echo_client.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/client/echo_client.c (added)
+++ incubator/celix/trunk/echo_service/client/echo_client.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,51 @@
+/*
+ * echo_client.c
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+
+#include "service_tracker.h"
+
+#include "echo_client_private.h"
+#include "echo_server.h"
+
+void * trk_send(void * handle) {
+	ECHO_CLIENT client = (ECHO_CLIENT) handle;
+	while (client->running) {
+		ECHO_SERVICE service = (ECHO_SERVICE) tracker_getService(client->tracker);
+		if (service != NULL) {
+			service->echo(service->server, "hi");
+		}
+		sleep(1);
+	}
+	pthread_exit(NULL);
+}
+
+ECHO_CLIENT echoClient_create(SERVICE_TRACKER echoServiceTracker) {
+	ECHO_CLIENT client = malloc(sizeof(*client));
+
+	client->tracker = echoServiceTracker;
+	client->running = false;
+
+	return client;
+}
+
+void echoClient_start(ECHO_CLIENT client) {
+	client->running = true;
+	pthread_create(&client->sender, NULL, trk_send, client);
+}
+
+void echoClient_stop(ECHO_CLIENT client) {
+	client->running = false;
+	pthread_join(client->sender, NULL);
+}
+
+void echoClient_destroy(ECHO_CLIENT client) {
+	client->tracker = NULL;
+	client->sender = NULL;
+	free(client);
+	client = NULL;
+}
+

Added: incubator/celix/trunk/echo_service/client/echo_client_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/client/echo_client_activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/client/echo_client_activator.c (added)
+++ incubator/celix/trunk/echo_service/client/echo_client_activator.c Thu Dec  9 11:59:18
2010
@@ -0,0 +1,52 @@
+/*
+ * echo_server_activator.c
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_tracker.h"
+
+#include "echo_server.h"
+#include "echo_client_private.h"
+
+struct echoActivator {
+	ECHO_CLIENT client;
+	SERVICE_TRACKER tracker;
+};
+
+void * bundleActivator_create() {
+	struct echoActivator * act = malloc(sizeof(*act));
+	act->client = NULL;
+	act->tracker = NULL;
+
+	return act;
+}
+
+void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+
+	SERVICE_TRACKER tracker = tracker_create(context, ECHO_SERVICE_NAME, NULL);
+	act->tracker = tracker;
+
+	ECHO_CLIENT client = echoClient_create(tracker);
+	act->client = client;
+
+	echoClient_start(act->client);
+	tracker_open(act->tracker);
+}
+
+void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+	tracker_close(act->tracker);
+	echoClient_stop(act->client);
+}
+
+void bundleActivator_destroy(void * userData) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+	echoClient_destroy(act->client);
+	tracker_destroy(act->tracker);
+}

Added: incubator/celix/trunk/echo_service/client/echo_client_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/client/echo_client_private.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/client/echo_client_private.h (added)
+++ incubator/celix/trunk/echo_service/client/echo_client_private.h Thu Dec  9 11:59:18 2010
@@ -0,0 +1,33 @@
+/*
+ * echo_client_private.h
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef ECHO_CLIENT_PRIVATE_H_
+#define ECHO_CLIENT_PRIVATE_H_
+
+#include <stdbool.h>
+#include <pthread.h>
+
+#include "headers.h"
+
+struct echoClient {
+	SERVICE_TRACKER tracker;
+	bool running;
+
+	pthread_t sender;
+};
+
+typedef struct echoClient * ECHO_CLIENT;
+
+ECHO_CLIENT echoClient_create(SERVICE_TRACKER context);
+
+void echoClient_start(ECHO_CLIENT client);
+void echoClient_stop(ECHO_CLIENT client);
+
+void echoClient_destroy(ECHO_CLIENT client);
+
+
+#endif /* ECHO_CLIENT_PRIVATE_H_ */

Added: incubator/celix/trunk/echo_service/server/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/CMakeLists.txt (added)
+++ incubator/celix/trunk/echo_service/server/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,5 @@
+add_library(echo_server SHARED echo_server_activator echo_server)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+target_link_libraries(echo_server framework)
+
+bundle(echo_server)

Added: incubator/celix/trunk/echo_service/server/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/echo_service/server/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18 2010
@@ -0,0 +1,5 @@
+Bundle-SymbolicName: echo_server
+Bundle-Version: 1.0.0
+library: echo_server
+Export-Service: echo_server
+Import-Service: echo_server

Added: incubator/celix/trunk/echo_service/server/echo_server.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/echo_server.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/echo_server.c (added)
+++ incubator/celix/trunk/echo_service/server/echo_server.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,30 @@
+/*
+ * echo_server.c
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "echo_server_private.h"
+
+struct echoServer {
+	char * name;
+};
+
+ECHO_SERVER echoServer_create() {
+	ECHO_SERVER server = malloc(sizeof(*server));
+	server->name = "MacBook Pro";
+	return server;
+}
+
+void echoServer_echo(ECHO_SERVER server, char * text) {
+	printf("Server %s says %s\n", server->name, text);
+}
+
+void echoServer_destroy(ECHO_SERVER server) {
+	server->name = NULL;
+	free(server);
+	server = NULL;
+}

Added: incubator/celix/trunk/echo_service/server/echo_server.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/echo_server.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/echo_server.h (added)
+++ incubator/celix/trunk/echo_service/server/echo_server.h Thu Dec  9 11:59:18 2010
@@ -0,0 +1,22 @@
+/*
+ * echo_server.h
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef ECHO_SERVER_H_
+#define ECHO_SERVER_H_
+
+#define ECHO_SERVICE_NAME "echo_server"
+
+typedef struct echoServer * ECHO_SERVER;
+
+struct echoService {
+	ECHO_SERVER server;
+	void (*echo)(ECHO_SERVER server, char * text);
+};
+
+typedef struct echoService * ECHO_SERVICE;
+
+#endif /* ECHO_SERVER_H_ */

Added: incubator/celix/trunk/echo_service/server/echo_server_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/echo_server_activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/echo_server_activator.c (added)
+++ incubator/celix/trunk/echo_service/server/echo_server_activator.c Thu Dec  9 11:59:18
2010
@@ -0,0 +1,55 @@
+/*
+ * echo_server_activator.c
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_registration.h"
+#include "echo_server_private.h"
+
+struct echoActivator {
+	SERVICE_REGISTRATION reg;
+	ECHO_SERVICE es;
+};
+
+void * bundleActivator_create() {
+	struct echoActivator * act = malloc(sizeof(*act));
+	act->reg = NULL;
+	return act;
+}
+
+void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+
+	ECHO_SERVICE es = malloc(sizeof(*es));
+	ECHO_SERVER server = echoServer_create();
+	es->server = server;
+	es->echo = echoServer_echo;
+
+	act->es = es;
+
+	SERVICE_REGISTRATION reg = bundleContext_registerService(context, ECHO_SERVICE_NAME, es,
NULL);
+	act->reg = reg;
+}
+
+void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+
+	serviceRegistration_unregister(act->reg);
+	act->reg = NULL;
+}
+
+void bundleActivator_destroy(void * userData) {
+	struct echoActivator * act = (struct echoActivator *) userData;
+	act->es->echo = NULL;
+	echoServer_destroy(act->es->server);
+	act->es->server = NULL;
+	free(act->es);
+	act->es = NULL;
+	act->reg = NULL;
+	free(act);
+}

Added: incubator/celix/trunk/echo_service/server/echo_server_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/echo_service/server/echo_server_private.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/echo_service/server/echo_server_private.h (added)
+++ incubator/celix/trunk/echo_service/server/echo_server_private.h Thu Dec  9 11:59:18 2010
@@ -0,0 +1,17 @@
+/*
+ * echo_server_private.h
+ *
+ *  Created on: Sep 21, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef ECHO_SERVER_PRIVATE_H_
+#define ECHO_SERVER_PRIVATE_H_
+
+#include "echo_server.h"
+
+ECHO_SERVER echoServer_create();
+void echoServer_echo(ECHO_SERVER server, char * text);
+void echoServer_destroy(ECHO_SERVER server);
+
+#endif /* ECHO_SERVER_PRIVATE_H_ */

Added: incubator/celix/trunk/remote/TestService.java
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote/TestService.java?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/remote/TestService.java (added)
+++ incubator/celix/trunk/remote/TestService.java Thu Dec  9 11:59:18 2010
@@ -0,0 +1,5 @@
+package test;
+
+public interface Service {
+	public String doo(String message, int value);
+}
\ No newline at end of file

Added: incubator/celix/trunk/remote/test.service.proto
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote/test.service.proto?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/remote/test.service.proto (added)
+++ incubator/celix/trunk/remote/test.service.proto Thu Dec  9 11:59:18 2010
@@ -0,0 +1,8 @@
+service testService {
+  rpc doo (Type) returns (string);
+}
+
+message Type {
+	required string field1 = 1;
+	required string field2 = 2;
+}
\ No newline at end of file

Added: incubator/celix/trunk/remote/test_service.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote/test_service.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/remote/test_service.h (added)
+++ incubator/celix/trunk/remote/test_service.h Thu Dec  9 11:59:18 2010
@@ -0,0 +1,18 @@
+/*
+ * test_service.h
+ *
+ *  Created on: Sep 24, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef TEST_SERVICE_H_
+#define TEST_SERVICE_H_
+
+typedef struct test_service_handle * TEST_SERVICE_HANDLE;
+
+struct test_service {
+	TEST_SERVICE_HANDLE handle;
+	char * doo(char * message, int value);
+};
+
+#endif /* TEST_SERVICE_H_ */

Added: incubator/celix/trunk/whiteboard/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/CMakeLists.txt (added)
+++ incubator/celix/trunk/whiteboard/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,4 @@
+add_subdirectory(publisherA)
+add_subdirectory(publisherB)
+add_subdirectory(tracker)
+add_subdirectory(tracker_depman)
\ No newline at end of file

Added: incubator/celix/trunk/whiteboard/publisherA/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/CMakeLists.txt (added)
+++ incubator/celix/trunk/whiteboard/publisherA/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,7 @@
+add_library(publisherA SHARED activator publisher)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+include_directories("../publisherService")
+target_link_libraries(publisherA framework)
+
+bundle(publisherA)
+package(publisherA FILES ../publisherService/publisher.h)
\ No newline at end of file

Added: incubator/celix/trunk/whiteboard/publisherA/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/whiteboard/publisherA/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18 2010
@@ -0,0 +1,5 @@
+Bundle-SymbolicName: publisherA
+Bundle-Version: 1.0.0.test
+library: publisherA
+Export-Service: Publisher
+Import-Service: Publisher

Added: incubator/celix/trunk/whiteboard/publisherA/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/activator.c (added)
+++ incubator/celix/trunk/whiteboard/publisherA/activator.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,32 @@
+/*
+ * activator.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "publisher_private.h"
+
+void * bundleActivator_create() {
+	return NULL;
+}
+
+void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	PUBLISHER_SERVICE ps = malloc(sizeof(*ps));
+	PUBLISHER pub = malloc(sizeof(*pub));
+	ps->invoke = publisher_invoke;
+	ps->publisher = pub;
+
+	bundleContext_registerService(context, PUBLISHER_NAME, ps, NULL);
+}
+
+void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+
+}
+
+void bundleActivator_destroy(void * userData) {
+
+}

Added: incubator/celix/trunk/whiteboard/publisherA/publisher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherA/publisher.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherA/publisher.c (added)
+++ incubator/celix/trunk/whiteboard/publisherA/publisher.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,14 @@
+/*
+ * publisher.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdio.h>
+
+#include "publisher_private.h"
+
+void publisher_invoke(PUBLISHER publisher, char * text) {
+	printf("Hello from A %s\n", text);
+}
+

Added: incubator/celix/trunk/whiteboard/publisherB/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/CMakeLists.txt (added)
+++ incubator/celix/trunk/whiteboard/publisherB/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,7 @@
+add_library(publisherB SHARED activator publisher)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+include_directories("../publisherService")
+target_link_libraries(publisherB framework)
+
+bundle(publisherB)
+package(publisherB FILES ../publisherService/publisher.h)
\ No newline at end of file

Added: incubator/celix/trunk/whiteboard/publisherB/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/whiteboard/publisherB/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18 2010
@@ -0,0 +1,5 @@
+Bundle-SymbolicName: publisherB
+Bundle-Version: 1.0.0.test
+library: publisherB
+Export-Service: Publisher
+Import-Service: Publisher

Added: incubator/celix/trunk/whiteboard/publisherB/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/activator.c (added)
+++ incubator/celix/trunk/whiteboard/publisherB/activator.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,32 @@
+/*
+ * activator.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "publisher_private.h"
+
+void * bundleActivator_create() {
+	return NULL;
+}
+
+void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	PUBLISHER_SERVICE ps = malloc(sizeof(*ps));
+	PUBLISHER pub = malloc(sizeof(*pub));
+	ps->invoke = publisher_invoke;
+	ps->publisher = pub;
+
+	bundleContext_registerService(context, PUBLISHER_NAME, ps, NULL);
+}
+
+void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+
+}
+
+void bundleActivator_destroy(void * userData) {
+
+}

Added: incubator/celix/trunk/whiteboard/publisherB/publisher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherB/publisher.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherB/publisher.c (added)
+++ incubator/celix/trunk/whiteboard/publisherB/publisher.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,14 @@
+/*
+ * publisher.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdio.h>
+
+#include "publisher_private.h"
+
+void publisher_invoke(PUBLISHER publisher, char * text) {
+	printf("Hello from B %s\n", text);
+}
+

Added: incubator/celix/trunk/whiteboard/publisherService/publisher.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherService/publisher.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherService/publisher.h (added)
+++ incubator/celix/trunk/whiteboard/publisherService/publisher.h Thu Dec  9 11:59:18 2010
@@ -0,0 +1,23 @@
+/*
+ * publisher.h
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef PUBLISHER_H_
+#define PUBLISHER_H_
+
+#define PUBLISHER_NAME "Publisher"
+
+typedef struct publisher * PUBLISHER;
+
+struct publisherService {
+	PUBLISHER publisher;
+	void (*invoke)(PUBLISHER pub, char * text);
+};
+
+typedef struct publisherService * PUBLISHER_SERVICE;
+
+
+#endif /* PUBLISHER_H_ */

Added: incubator/celix/trunk/whiteboard/publisherService/publisher_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/publisherService/publisher_private.h?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/publisherService/publisher_private.h (added)
+++ incubator/celix/trunk/whiteboard/publisherService/publisher_private.h Thu Dec  9 11:59:18
2010
@@ -0,0 +1,19 @@
+/*
+ * publisher_private.h
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+
+#ifndef PUBLISHER_PRIVATE_H_
+#define PUBLISHER_PRIVATE_H_
+
+#include "publisher.h"
+
+struct publisher {
+
+};
+
+void publisher_invoke(PUBLISHER publisher, char * text);
+
+#endif /* PUBLISHER_PRIVATE_H_ */

Added: incubator/celix/trunk/whiteboard/tracker/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker/CMakeLists.txt (added)
+++ incubator/celix/trunk/whiteboard/tracker/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,6 @@
+add_library(tracker SHARED activator)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+include_directories("../publisherService")
+target_link_libraries(tracker framework)
+
+bundle(tracker)

Added: incubator/celix/trunk/whiteboard/tracker/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/whiteboard/tracker/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18 2010
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: tracker
+Bundle-Version: 1.0.0.test
+library: tracker
+Import-Service: Publisher

Added: incubator/celix/trunk/whiteboard/tracker/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker/activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker/activator.c (added)
+++ incubator/celix/trunk/whiteboard/tracker/activator.c Thu Dec  9 11:59:18 2010
@@ -0,0 +1,94 @@
+/*
+ * activator.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include "bundle_activator.h"
+#include "publisher.h"
+#include "service_tracker.h"
+#include "bundle_context.h"
+
+struct data {
+	BUNDLE_CONTEXT context;
+	SERVICE_TRACKER tracker;
+	ARRAY_LIST publishers;
+	pthread_t sender;
+	bool running;
+};
+
+void * trk_send(void * handle) {
+	struct data * data = (struct data *) handle;
+	while (data->running) {
+		int i;
+		for (i = 0; i < arrayList_size(data->publishers); i++) {
+			PUBLISHER_SERVICE pub = arrayList_get(data->publishers, i);
+			pub->invoke(pub->publisher, "test");
+		}
+		sleep(1);
+	}
+	pthread_exit(NULL);
+}
+
+void * addingServ(void * handle, SERVICE_REFERENCE ref) {
+	struct data * data = (struct data *) handle;
+	printf("Adding\n");
+	return bundleContext_getService(data->context, ref);
+}
+
+void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	arrayList_add(data->publishers, service);
+	printf("Added\n");
+}
+
+void modifiedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Modified\n");
+}
+
+void removedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	arrayList_removeElement(data->publishers, service);
+	printf("Removed\n");
+}
+
+void * bundleActivator_create() {
+	struct data * data = malloc(sizeof(*data));
+	data->publishers = arrayList_create();
+	return data;
+}
+
+void bundleActivator_start(void * userData, BUNDLE_CONTEXT context) {
+	struct data * data = (struct data *) userData;
+	data->context = context;
+
+	SERVICE_TRACKER_CUSTOMIZER cust = (SERVICE_TRACKER_CUSTOMIZER) malloc(sizeof(*cust));
+	cust->handle = data;
+	cust->addedService = addedServ;
+	cust->addingService = addingServ;
+	cust->modifiedService = modifiedServ;
+	cust->removedService = removedServ;
+	SERVICE_TRACKER tracker = tracker_create(context, (char *) PUBLISHER_NAME, cust);
+	data->tracker = tracker;
+
+	tracker_open(tracker);
+
+	data->running = true;
+	pthread_create(&data->sender, NULL, trk_send, data);
+}
+
+void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
+	struct data * data = (struct data *) userData;
+	tracker_close(data->tracker);
+	data->running = false;
+}
+
+void bundleActivator_destroy(void * userData) {
+
+}

Added: incubator/celix/trunk/whiteboard/tracker_depman/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker_depman/CMakeLists.txt?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker_depman/CMakeLists.txt (added)
+++ incubator/celix/trunk/whiteboard/tracker_depman/CMakeLists.txt Thu Dec  9 11:59:18 2010
@@ -0,0 +1,7 @@
+add_library(tracker_depman SHARED dependency_activator)
+include_directories("${PROJECT_SOURCE_DIR}/celix")
+include_directories("${PROJECT_SOURCE_DIR}/dependency_manager")
+include_directories("../publisherService")
+target_link_libraries(tracker_depman framework dependency_manager)
+
+bundle(tracker_depman)

Added: incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF (added)
+++ incubator/celix/trunk/whiteboard/tracker_depman/MANIFEST/MANIFEST.MF Thu Dec  9 11:59:18
2010
@@ -0,0 +1,4 @@
+Bundle-SymbolicName: tracker_depman
+Bundle-Version: 1.0.0.test
+library: tracker_depman
+Import-Service: Publisher

Added: incubator/celix/trunk/whiteboard/tracker_depman/dependency_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/whiteboard/tracker_depman/dependency_activator.c?rev=1043916&view=auto
==============================================================================
--- incubator/celix/trunk/whiteboard/tracker_depman/dependency_activator.c (added)
+++ incubator/celix/trunk/whiteboard/tracker_depman/dependency_activator.c Thu Dec  9 11:59:18
2010
@@ -0,0 +1,101 @@
+/*
+ * dependency_activator.c
+ *
+ *  Created on: Aug 23, 2010
+ *      Author: alexanderb
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include "dependency_activator_base.h"
+#include "service_component_private.h"
+#include "service.h"
+#include "publisher.h"
+
+struct data {
+	SERVICE service;
+	BUNDLE_CONTEXT context;
+	ARRAY_LIST publishers;
+	pthread_t sender;
+	bool running;
+};
+
+void * dp_send(void * handle) {
+	struct data * data = (struct data *) handle;
+	while (data->running) {
+		int i;
+		for (i = 0; i < arrayList_size(data->publishers); i++) {
+			PUBLISHER_SERVICE pub = (PUBLISHER_SERVICE) arrayList_get(data->publishers, i);
+			pub->invoke(pub->publisher, "test");
+		}
+		sleep(1);
+	}
+	pthread_exit(NULL);
+}
+
+void service_init(void * userData) {
+
+}
+
+void service_start(void * userData) {
+	struct data * data = (struct data *) userData;
+	data->running = true;
+	pthread_create(&data->sender, NULL, dp_send, data);
+}
+
+void service_stop(void * userData) {
+	struct data * data = (struct data *) userData;
+	data->running = false;
+}
+
+void service_destroy(void * userData) {
+
+}
+
+void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	arrayList_add(data->publishers, service);
+	printf("Service Added\n");
+}
+
+void modifiedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Service Changed\n");
+}
+
+void removedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+	struct data * data = (struct data *) handle;
+	arrayList_removeElement(data->publishers, service);
+	printf("Service Removed\n");
+}
+
+void * dm_create() {
+	struct data * data = malloc(sizeof(*data));
+	data->publishers = arrayList_create();
+	return data;
+}
+
+void dm_init(void * userData, BUNDLE_CONTEXT context, DEPENDENCY_MANAGER manager) {
+	struct data * data = (struct data *) userData;
+	data->context = context;
+
+	SERVICE service = dependencyActivatorBase_createService(manager);
+	serviceComponent_setImplementation(service, data);
+	SERVICE_DEPENDENCY dep = dependencyActivatorBase_createServiceDependency(manager);
+	serviceDependency_setRequired(dep, false);
+	serviceDependency_setService(dep, PUBLISHER_NAME, NULL);
+	serviceDependency_setCallbacks(dep, addedServ, modifiedServ, removedServ);
+	serviceComponent_addServiceDependency(service, dep);
+
+	data->service = service;
+	dependencyManager_add(manager, service);
+}
+
+void dm_destroy(void * userData, BUNDLE_CONTEXT context, DEPENDENCY_MANAGER manager) {
+	struct data * data = (struct data *) userData;
+	dependencyManager_remove(manager, data->service);
+}
+



Mime
View raw message