incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1528023 - in /incubator/celix/trunk: examples/whiteboard/tracker/private/src/ examples/whiteboard/tracker_depman/private/src/ log_writer/ log_writer/private/include/ log_writer/private/src/
Date Tue, 01 Oct 2013 09:53:22 GMT
Author: abroekhuis
Date: Tue Oct  1 09:53:22 2013
New Revision: 1528023

URL: http://svn.apache.org/r1528023
Log:
CELIX-67: Removed Dependency manager usage from the log writer.

Added:
    incubator/celix/trunk/log_writer/private/src/log_writer_activator.c
Removed:
    incubator/celix/trunk/log_writer/private/src/dependency_activator.c
Modified:
    incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c
    incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/tracker.c
    incubator/celix/trunk/log_writer/CMakeLists.txt
    incubator/celix/trunk/log_writer/private/include/log_writer.h
    incubator/celix/trunk/log_writer/private/src/log_writer.c

Modified: incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c?rev=1528023&r1=1528022&r2=1528023&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker/private/src/activator.c Tue Oct  1 09:53:22
2013
@@ -124,11 +124,12 @@ celix_status_t bundleActivator_start(voi
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
     struct data * data = (struct data *) userData;
+    apr_status_t stat;
 
 	printf("Stop\n");
     serviceTracker_close(data->tracker);
     data->running = false;
-    apr_thread_join(APR_SUCCESS, data->sender);
+    apr_thread_join(&stat, data->sender);
 
     return status;
 }

Modified: incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/tracker.c?rev=1528023&r1=1528022&r2=1528023&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/tracker.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker_depman/private/src/tracker.c Tue Oct
 1 09:53:22 2013
@@ -63,9 +63,10 @@ void service_start(void * userData) {
 }
 
 void service_stop(void * userData) {
+	apr_status_t stat;
 	struct data * data = (struct data *) userData;
 	data->running = false;
-	apr_thread_join(APR_SUCCESS, data->sender);
+	apr_thread_join(&stat, data->sender);
 }
 
 void service_destroy(void * userData) {

Modified: incubator/celix/trunk/log_writer/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/CMakeLists.txt?rev=1528023&r1=1528022&r2=1528023&view=diff
==============================================================================
--- incubator/celix/trunk/log_writer/CMakeLists.txt (original)
+++ incubator/celix/trunk/log_writer/CMakeLists.txt Tue Oct  1 09:53:22 2013
@@ -15,14 +15,14 @@
 # specific language governing permissions and limitations
 # under the License.
 
-celix_subproject(LOG_WRITER "Option to enable building the Log Writer bundle" "OFF" DEPS
FRAMEWORK LOG_SERVICE DEPENDENCY_MANAGER)
+celix_subproject(LOG_WRITER "Option to enable building the Log Writer bundle" "OFF" DEPS
FRAMEWORK LOG_SERVICE)
 if (LOG_WRITER)
 
 	SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_log_writer")
 	SET_HEADERS("Bundle-Name: Apache Celix Log Writer")
 
     bundle(log_writer SOURCES 
-    	private/src/dependency_activator 
+    	private/src/log_writer_activator 
     	private/src/log_writer
     
         private/include/log_writer.h    
@@ -31,8 +31,7 @@ if (LOG_WRITER)
     install_bundle(log_writer)
     
 	include_directories("private/include")
-    include_directories("${PROJECT_SOURCE_DIR}/dependency_manager/public/include")
     include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
     include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-    target_link_libraries(log_writer celix_framework dependency_manager)
+    target_link_libraries(log_writer celix_framework)
 endif (LOG_WRITER)
\ No newline at end of file

Modified: incubator/celix/trunk/log_writer/private/include/log_writer.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/private/include/log_writer.h?rev=1528023&r1=1528022&r2=1528023&view=diff
==============================================================================
--- incubator/celix/trunk/log_writer/private/include/log_writer.h (original)
+++ incubator/celix/trunk/log_writer/private/include/log_writer.h Tue Oct  1 09:53:22 2013
@@ -27,20 +27,27 @@
 #ifndef LOG_WRITER_H_
 #define LOG_WRITER_H_
 
-#include "service_component.h"
-#include "service_dependency.h"
 #include "log_reader_service.h"
 
+#include "service_tracker.h"
+
 struct log_writer {
     log_reader_service_pt logReader;
-    service_pt service;
-    service_dependency_pt dep;
     log_listener_pt logListener;
+    apr_pool_t *pool;
+    bundle_context_pt context;
+    service_tracker_pt tracker;
 };
 
 typedef struct log_writer *log_writer_pt;
 
-celix_status_t logWriter_create(apr_pool_t *pool, log_writer_pt *writer);
-
+celix_status_t logWriter_create(apr_pool_t *pool, bundle_context_pt context, log_writer_pt
*writer);
+celix_status_t logWriter_start(log_writer_pt writer);
+celix_status_t logWriter_stop(log_writer_pt writer);
+
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service);
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service);
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service);
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service);
 
 #endif /* LOG_WRITER_H_ */

Modified: incubator/celix/trunk/log_writer/private/src/log_writer.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/private/src/log_writer.c?rev=1528023&r1=1528022&r2=1528023&view=diff
==============================================================================
--- incubator/celix/trunk/log_writer/private/src/log_writer.c (original)
+++ incubator/celix/trunk/log_writer/private/src/log_writer.c Tue Oct  1 09:53:22 2013
@@ -29,13 +29,12 @@
 #include "celix_errno.h"
 #include "celixbool.h"
 
-#include "service.h"
 #include "log_writer.h"
 #include "log_listener.h"
 #include "module.h"
 #include "bundle.h"
 
-celix_status_t logWriter_create(apr_pool_t *pool, log_writer_pt *writer) {
+celix_status_t logWriter_create(apr_pool_t *pool, bundle_context_pt context, log_writer_pt
*writer) {
     celix_status_t status = CELIX_SUCCESS;
 
     apr_pool_t *mypool;
@@ -46,30 +45,65 @@ celix_status_t logWriter_create(apr_pool
     (*writer)->logListener->handle = *writer;
     (*writer)->logListener->logged = logListener_logged;
     (*writer)->logReader = NULL;
-    (*writer)->service = NULL;
+    (*writer)->pool = mypool;
+    (*writer)->context = context;
+    (*writer)->tracker = NULL;
 
     return status;
 }
 
-void service_init(void * userData) {
+celix_status_t logWriter_start(log_writer_pt writer) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	service_tracker_customizer_pt cust = NULL;
+	service_tracker_pt tracker = NULL;
+
+	status = serviceTrackerCustomizer_create(writer->pool, writer, logWriter_addingServ,
logWriter_addedServ, logWriter_modifiedServ, logWriter_removedServ, &cust);
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_create(writer->pool, writer->context, (char *) LOG_READER_SERVICE_NAME,
cust, &tracker);
+		if (status == CELIX_SUCCESS) {
+			writer->tracker = tracker;
+			status = serviceTracker_open(tracker);
+		}
+	}
+
+	return status;
 }
 
-void service_start(void * userData) {
-    log_writer_pt writer = (log_writer_pt) userData;
-    if (writer->logReader != NULL) {
-    	writer->logReader->addLogListener(writer->logReader->reader, writer->logListener);
-    }
+celix_status_t logWriter_stop(log_writer_pt writer) {
+	return serviceTracker_close(writer->tracker);
 }
 
-void service_stop(void * userData) {
-    log_writer_pt writer = (log_writer_pt) userData;
+celix_status_t logWriter_addingServ(void * handle, service_reference_pt ref, void **service)
{
+	log_writer_pt writer = (log_writer_pt) handle;
+	bundleContext_getService(writer->context, ref, service);
+	return CELIX_SUCCESS;
+}
 
-    if (writer->logReader != NULL) {
-    	writer->logReader->removeLogListener(writer->logReader->reader, writer->logListener);
-    }
+celix_status_t logWriter_addedServ(void * handle, service_reference_pt ref, void * service)
{
+	log_writer_pt writer = (log_writer_pt) handle;
+
+	// Add this writer to each log reader service found
+	if (service != NULL) {
+		((log_reader_service_pt) service)->addLogListener(((log_reader_service_pt) service)->reader,
writer->logListener);
+	}
+
+	return CELIX_SUCCESS;
 }
 
-void service_destroy(void * userData) {
+celix_status_t logWriter_modifiedServ(void * handle, service_reference_pt ref, void * service)
{
+	log_writer_pt writer = (log_writer_pt) handle;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t logWriter_removedServ(void * handle, service_reference_pt ref, void * service)
{
+	log_writer_pt writer = (log_writer_pt) handle;
+
+	if (service != NULL) {
+		((log_reader_service_pt) service)->removeLogListener(((log_reader_service_pt) service)->reader,
writer->logListener);
+	}
+
+	return CELIX_SUCCESS;
 }
 
 celix_status_t logListener_logged(log_listener_pt listener, log_entry_pt entry) {

Added: incubator/celix/trunk/log_writer/private/src/log_writer_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_writer/private/src/log_writer_activator.c?rev=1528023&view=auto
==============================================================================
--- incubator/celix/trunk/log_writer/private/src/log_writer_activator.c (added)
+++ incubator/celix/trunk/log_writer/private/src/log_writer_activator.c Tue Oct  1 09:53:22
2013
@@ -0,0 +1,56 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * activator.c
+ *
+ *  \date       Oct 1, 2013
+ *  \author     <a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
+ *  \copyright  Apache License, Version 2.0
+ */
+
+#include "log_writer.h"
+
+#include "bundle_activator.h"
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	apr_pool_t *pool;
+	log_writer_pt writer = NULL;
+
+	bundleContext_getMemoryPool(context, &pool);
+
+	logWriter_create(pool, context, &writer);
+
+	*userData = writer;
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	logWriter_start(userData);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	logWriter_stop(userData);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+    return CELIX_SUCCESS;
+}



Mime
View raw message