incubator-celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ejans...@apache.org
Subject svn commit: r1585991 - in /incubator/celix/trunk: ./ event_admin/ event_admin/event_admin/ event_admin/event_admin/private/ event_admin/event_admin/private/include/ event_admin/event_admin/private/src/ event_admin/event_admin/public/ event_admin/event_...
Date Wed, 09 Apr 2014 15:27:18 GMT
Author: ejansman
Date: Wed Apr  9 15:27:17 2014
New Revision: 1585991

URL: http://svn.apache.org/r1585991
Log:
First commit for event admin. the event admin example bundle starts, but the handler won't find the right channel for published events, this is a known issue.

Added:
    incubator/celix/trunk/event_admin/
    incubator/celix/trunk/event_admin/CMakeLists.txt
    incubator/celix/trunk/event_admin/deploy.cmake
    incubator/celix/trunk/event_admin/event_admin/
    incubator/celix/trunk/event_admin/event_admin/CMakeLists.txt
    incubator/celix/trunk/event_admin/event_admin/private/
    incubator/celix/trunk/event_admin/event_admin/private/include/
    incubator/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h
    incubator/celix/trunk/event_admin/event_admin/private/src/
    incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c
    incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
    incubator/celix/trunk/event_admin/event_admin/private/src/event_impl.c
    incubator/celix/trunk/event_admin/event_admin/public/
    incubator/celix/trunk/event_admin/event_admin/public/include/
    incubator/celix/trunk/event_admin/event_admin/public/include/event_admin.h
    incubator/celix/trunk/event_admin/event_admin/public/include/event_constants.h
    incubator/celix/trunk/event_admin/event_admin/public/include/event_handler.h
    incubator/celix/trunk/event_admin/event_handler/
    incubator/celix/trunk/event_admin/event_handler/CMakeLists.txt
    incubator/celix/trunk/event_admin/event_handler/private/
    incubator/celix/trunk/event_admin/event_handler/private/include/
    incubator/celix/trunk/event_admin/event_handler/private/include/event_handler_impl.h
    incubator/celix/trunk/event_admin/event_handler/private/src/
    incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_activator.c
    incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c
    incubator/celix/trunk/event_admin/event_publisher/
    incubator/celix/trunk/event_admin/event_publisher/CMakeLists.txt
    incubator/celix/trunk/event_admin/event_publisher/private/
    incubator/celix/trunk/event_admin/event_publisher/private/include/
    incubator/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h
    incubator/celix/trunk/event_admin/event_publisher/private/src/
    incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_activator.c
    incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c
    incubator/celix/trunk/event_admin/utils/
    incubator/celix/trunk/event_admin/utils/CMakeLists.txt
    incubator/celix/trunk/event_admin/utils/private/
    incubator/celix/trunk/event_admin/utils/private/src/
    incubator/celix/trunk/event_admin/utils/private/src/event_impl.c
    incubator/celix/trunk/event_admin/utils/public/
    incubator/celix/trunk/event_admin/utils/public/include/
    incubator/celix/trunk/event_admin/utils/public/include/event.h
Modified:
    incubator/celix/trunk/CMakeLists.txt

Modified: incubator/celix/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/CMakeLists.txt?rev=1585991&r1=1585990&r2=1585991&view=diff
==============================================================================
--- incubator/celix/trunk/CMakeLists.txt (original)
+++ incubator/celix/trunk/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -60,6 +60,7 @@ add_subdirectory(shell)
 add_subdirectory(log_writer)
 add_subdirectory(log_service)
 
+add_subdirectory(event_admin)
 add_subdirectory(dependency_manager)
 
 add_subdirectory(launcher)

Added: incubator/celix/trunk/event_admin/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/CMakeLists.txt?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/CMakeLists.txt (added)
+++ incubator/celix/trunk/event_admin/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -0,0 +1,25 @@
+# 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.
+
+celix_subproject(EVENT_ADMIN "Option to enable building the Event Admin Service bundles" OFF DEPS LAUNCHER LOG_SERVICE SHELL shell_tui)
+if(EVENT_ADMIN)
+	#add_subdirectory(utils)
+	add_subdirectory(event_admin)
+	add_subdirectory(event_handler)
+	add_subdirectory(event_publisher)
+	
+endif(EVENT_ADMIN)
\ No newline at end of file

Added: incubator/celix/trunk/event_admin/deploy.cmake
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/deploy.cmake?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/deploy.cmake (added)
+++ incubator/celix/trunk/event_admin/deploy.cmake Wed Apr  9 15:27:17 2014
@@ -0,0 +1,23 @@
+# 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.
+is_enabled(EVENT_ADMIN)
+if(EVENT_ADMIN)
+	deploy("event_admin" BUNDLES event_admin shell shell_tui log_service log_writer)
+	deploy("event_publisher_example" BUNDLES event_publisher shell shell_tui log_service log_writer)
+	deploy("event_handler_example" BUNDLES event_handler shell shell_tui log_service log_writer)
+	deploy("event_admin_example" BUNDLES event_admin event_publisher event_handler shell shell_tui log_service log_writer)
+endif(EVENT_ADMIN)
\ No newline at end of file

Added: incubator/celix/trunk/event_admin/event_admin/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/CMakeLists.txt?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/CMakeLists.txt (added)
+++ incubator/celix/trunk/event_admin/event_admin/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -0,0 +1,47 @@
+# 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.
+
+find_package(APR REQUIRED)
+find_package(CELIX REQUIRED)
+
+include_directories(public/include)
+include_directories(private/include)
+include_directories("${CELIX_INCLUDE_DIRS}")
+#include_directories(../utils/public/include)
+
+SET_HEADER(BUNDLE_SYMBOLICNAME "eventadmin")
+SET_HEADERS("Bundle-Name: Event admin")
+
+
+bundle(event_admin 
+	SOURCES 
+		private/src/event_admin_activator.c
+		private/src/event_admin_impl.c
+		private/src/event_impl.c
+		public/include/event_admin.h
+		public/include/event_handler.h
+		private/include/event_admin_impl.h
+)
+
+install_bundle(event_admin
+	HEADERS
+	    public/include/event_admin.h
+	    public/include/event_constants.h
+	    public/include/event_handler.h
+)
+
+target_link_libraries(event_admin celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})

Added: incubator/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h (added)
+++ incubator/celix/trunk/event_admin/event_admin/private/include/event_admin_impl.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,162 @@
+/**
+ *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.
+ */
+/*
+ * event_admin_impl.h
+ *
+ *  \Created on: Jul 16, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_ADMIN_IMPL_H_
+#define EVENT_ADMIN_IMPL_H_
+#include <string.h>
+#include <apr.h>
+#include <apr_pools.h>
+#include "celix_errno.h"
+#include "bundle_context.h"
+#include "constants.h"
+#include "event_constants.h"
+#include "event_admin.h"
+#include "event_handler.h"
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "service_listener.h"
+#include "service_registration.h"
+#include "listener_hook_service.h"
+#include "event_admin.h"
+
+struct event_admin {
+        apr_pool_t *pool;
+        hash_map_pt channels;
+        array_list_pt event_handlers;
+        bundle_context_pt context;
+};
+typedef struct channel *channel_t;
+struct channel {
+        char *topic;
+        hash_map_pt eventHandlers;///array list containing all listeners subscribed to the channel
+       // hash_map_pt channels;
+        apr_thread_mutex_t *channelLock;
+
+};
+/**
+ * @desc Create event an event admin and put it in the event_admin parameter.
+ * @param apr_pool_t *pool. Pointer to the apr pool
+ * @param bundle_context_pt context. Pointer to the bundle context.
+ * @param event_admin_pt *event_admin. The event admin result.
+ */
+celix_status_t eventAdmin_create(apr_pool_t *pool, bundle_context_pt context, event_admin_pt *event_admin);
+/**
+ * @desc Post event. sends the event to the handlers in async.
+ * @param event_admin_pt event_admin. the event admin instance
+ * @param event_pt event. the event to be send.
+ *
+ */
+celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event);// async event sending
+/**
+ * @desc send event. sends the event to the handlers in sync.
+ * @param event_admin_pt event_admin. the event admin instance
+ * @param event_pt event. the event to be send.
+ *
+ */
+celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event);// sync event sending
+/**
+ * @desc functions for the service tracker
+ * @param void * handle.  Pointer to the event admin.
+ * @param service_reference_pt ref. Pointer to the service reference. Needed to get the service
+ * @param void **service Pointer to the service. Needed to use the service.
+ */
+celix_status_t eventAdmin_addingService(void * handle, service_reference_pt ref, void **service);
+celix_status_t eventAdmin_addedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void * service) ;
+/*
+ * end functions for service tracker
+ */
+
+/**
+ * @desc finds the handlers interested in the topic.
+ * @param hash_map_pt channels. hashmap contains the channels, key string based
+ * @param char *topic, the topic string.
+ * @param array_list_pt event_handlers. The array list to contain the interested handlers.
+ */
+celix_status_t eventAdmin_findHandlersByTopic(hash_map_pt channels, char *topic , array_list_pt event_handlers);
+/**
+ * @desc create the needed event channels for an event handler.
+ * @desc apr_pool_t *pool. a memory pool pointer.
+ * @desc event_handler_service_pt event_handler_service. The handler
+ * @desc char *topic the topic
+ * @desc channel_t *channel. the top level channel.
+ */
+celix_status_t eventAdmin_createEventChannelsByEventHandler(apr_pool_t *pool,event_handler_service_pt event_handler_service, char *topic, channel_t *channel);
+/**
+ * @desc mutex functions for the channels
+ * @param event_admin_pt event_admin. the event admin instance.
+ * @param char *topic. the topic for which the channels need to be locked or unlocked
+ */
+celix_status_t eventAdmin_lockHandlersList(event_admin_pt event_admin, char *topic );
+celix_status_t eventAdmin_releaseHandersList(event_admin_pt event_admin, char *topic );
+
+/**
+ * @desc create an event
+ * @param char *topic. String containing the topic
+ * @param properties_pt properties.
+ */
+celix_status_t eventAdmin_createEvent(event_admin_pt *event_admin, char *topic, properties_pt properties, event_pt *event);
+/**
+ * @desc checks if an event contains the property
+ * @param event_pt *event. the event to check
+ * @param char *property. the key for the property to check
+ * @param bool *result. the result.
+ */
+celix_status_t eventAdmin_containsProperty( event_pt *event, char *property, bool *result);
+/**
+ * @desc checks if an event is equal to the second event.
+ * @param event_pt *event, event to compare to
+ * @param event_pt *event, the event to be compared
+ * @param bool *result. the result true if equal.
+ */
+celix_status_t eventAdmin_event_equals( event_pt *event, event_pt *compare, bool *result);
+/**
+ * @desc gets a property from the event.
+ * @param event_pt *event. the event to get the property from
+ * @param char *propertyKey the key of the property to get
+ * @param char **propertyValue. the result param will contain the property if it exists in the event.
+ */
+celix_status_t eventAdmin_getProperty( event_pt *event, char *propertyKey, char **propertyValue);
+/**
+ * @desc gets all property names from the event
+ * @param event_pt *event. the event to get the property names from
+ * @param array_list_pt *names. will contain the keys
+ */
+celix_status_t eventAdmin_getPropertyNames( event_pt *event, array_list_pt *names);
+/**
+ * @desc gets the topic from an event
+ * @param event_pt *event. the event to get the topic from
+ * @param char **topic, result pointer will contain the topic.
+ */
+celix_status_t eventAdmin_getTopic( event_pt *event, char **topic);
+celix_status_t eventAdmin_hashCode(event_pt *event, int *hashCode);
+celix_status_t eventAdmin_matches( event_pt *event);
+celix_status_t eventAdmin_toString( event_pt *event, char *eventString);
+
+
+#endif /* EVENT_ADMIN_IMPL_H_ */

Added: incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c (added)
+++ incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_activator.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,130 @@
+/**
+ *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
+ *
+ *  Created on: Jul 9, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include <stdlib.h>
+
+#include "event_admin_impl.h"
+
+struct activator {
+	apr_pool_t *pool;
+	event_admin_service_pt event_admin_service;
+	event_admin_pt event_admin;
+	service_registration_pt registration;
+	service_tracker_pt tracker;
+	bundle_context_pt context;
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	apr_pool_t *pool = NULL;
+	apr_pool_t *parentPool;
+	struct activator *activator;
+	status = bundleContext_getMemoryPool(context, &parentPool);
+	if( status == CELIX_SUCCESS ) {
+		if(apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}else {
+			activator = apr_palloc(pool,sizeof(*activator));
+			activator->pool = pool;
+			activator->registration = NULL;
+			*userData = activator;
+			event_admin_pt event_admin = NULL;
+			event_admin_service_pt event_admin_service = NULL;
+			status = eventAdmin_create(activator->pool,context, &event_admin);
+			printf("event admin activator pointer: %p\n",event_admin);
+			if(status == CELIX_SUCCESS){
+				activator->event_admin = event_admin;
+				event_admin_service = apr_palloc(activator->pool, sizeof(event_admin_service));
+				if(!event_admin_service){
+					status = CELIX_ENOMEM;
+				} else {
+					event_admin->context = context;
+					event_admin_service->eventAdmin = event_admin;
+					event_admin_service->postEvent = eventAdmin_postEvent;
+					event_admin_service->sendEvent = eventAdmin_sendEvent;
+					event_admin_service->createEvent = eventAdmin_createEvent;
+					event_admin_service->containsProperty = eventAdmin_containsProperty;
+					event_admin_service->event_equals = eventAdmin_event_equals;
+					event_admin_service->getProperty = eventAdmin_getProperty;
+					event_admin_service->getPropertyNames = eventAdmin_getPropertyNames;
+					event_admin_service->getTopic = eventAdmin_getTopic;
+					event_admin_service->hashCode = eventAdmin_hashCode;
+					event_admin_service->matches = eventAdmin_matches;
+					event_admin_service->toString = eventAdmin_toString;
+
+				}
+			}
+			activator->event_admin_service = event_admin_service;
+			printf("event admin service pointer: %p\n",event_admin_service);
+		}
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	event_admin_service_pt event_admin_service = NULL;
+	apr_pool_t *pool;
+	status = bundleContext_getMemoryPool(context, &pool);
+	if(status == CELIX_SUCCESS) {
+		struct activator * data = (struct activator *) userData;
+		service_tracker_customizer_pt cust = NULL;
+		service_tracker_pt tracker = NULL;
+		data->context = context;
+
+		serviceTrackerCustomizer_create(pool, data->event_admin_service->eventAdmin, eventAdmin_addingService, eventAdmin_addedService, eventAdmin_modifiedService, eventAdmin_removedService, &cust);
+		serviceTracker_create(pool, context, (char *) EVENT_HANDLER_SERVICE, cust, &tracker);
+
+		data->tracker = tracker;
+
+		serviceTracker_open(tracker);
+		properties_pt properties = NULL;
+		properties = properties_create();
+		event_admin_service = activator->event_admin_service;
+		//printf("pointer of event admin service %p\n",event_admin_service);
+		bundleContext_registerService(context, (char *) EVENT_ADMIN_NAME, event_admin_service, properties, &activator->registration);
+
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator * data =  userData;
+		serviceTracker_close(data->tracker);
+	return status;
+}
+
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}
+
+

Added: incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c (added)
+++ incubator/celix/trunk/event_admin/event_admin/private/src/event_admin_impl.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,233 @@
+/**
+ *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.
+ */
+/*
+ * event_admin_impl.c
+ *
+ *  Created on: Jul 24, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include "event_admin.h"
+#include "event_admin_impl.h"
+#include "event_handler.h"
+#include "hash_map.h"
+#include "utils.h"
+
+
+celix_status_t eventAdmin_create(apr_pool_t *pool, bundle_context_pt context, event_admin_pt *event_admin){
+	celix_status_t status = CELIX_SUCCESS;
+	*event_admin = apr_palloc(pool, sizeof(**event_admin));
+	if(!*event_admin){
+				status = CELIX_ENOMEM;
+		}else {
+
+			(*event_admin)->pool = pool;
+			printf("pool evenadmin create: %p\n",(*event_admin)->pool);
+			(*event_admin)->channels = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
+			(*event_admin)->context =context;
+			printf("event admin pointer: %p\n",(*event_admin));
+			status = arrayList_create(&(*event_admin)->event_handlers);
+		}
+	return status;
+}
+
+celix_status_t eventAdmin_getEventHandlersByChannel(bundle_context_pt context, const char * serviceName, array_list_pt *eventHandlers) {
+	celix_status_t status = CELIX_SUCCESS;
+	status = bundleContext_getServiceReferences(context, serviceName,NULL, eventHandlers);
+	return status;
+}
+
+celix_status_t eventAdmin_postEvent(event_admin_pt event_admin, event_pt event){
+	celix_status_t status = CELIX_SUCCESS;
+	array_list_pt event_handlers = NULL;
+	char *topic;
+		eventAdmin_getTopic(&event,&topic);
+	eventAdmin_lockHandlersList(event_admin,topic);
+	printf("post called\n");
+	eventAdmin_releaseHandersList(event_admin,topic);
+	return status;
+}
+
+celix_status_t eventAdmin_sendEvent(event_admin_pt event_admin, event_pt event){
+	celix_status_t status = CELIX_SUCCESS;
+	printf("send called\n");
+	char *topic;
+	eventAdmin_getTopic(&event,&topic);
+
+	array_list_pt event_handlers;
+	arrayList_create(&event_handlers);
+	eventAdmin_lockHandlersList(event_admin,topic);
+	eventAdmin_findHandlersByTopic(event_admin->channels,topic,event_handlers);
+	array_list_iterator_pt handlers_itterator = arrayListIterator_create(event_handlers);
+	while(arrayListIterator_hasNext(handlers_itterator)){
+		void *handler = arrayListIterator_next(handlers_itterator);
+		event_handler_service_pt event_handler_service = (event_handler_service_pt) handler;
+		event_handler_service->handle_event(&event_handler_service->event_handler,event);
+		printf("handler found \n");
+	}
+	eventAdmin_releaseHandersList(event_admin,topic);
+	return status;
+}
+
+
+
+celix_status_t eventAdmin_findHandlersByTopic(hash_map_pt channels, char *topic , array_list_pt event_handlers){
+	celix_status_t status = CELIX_SUCCESS;
+	channel_t channel;
+	char channel_name[strlen(topic)+1];
+	strcpy(channel_name,topic);
+	printf("Finding channel: %s\n",channel_name);
+	//check if the channel exists
+	if(hashMap_containsKey(channels,channel_name)==1) {
+		printf("found channel \n");
+		channel = hashMap_get(channels,channel_name);
+		if(channel != NULL && channel->eventHandlers != NULL && hashMap_size(channel->eventHandlers)> 0 ){
+			//itterate throught the handlers and add them to the array list for result.
+			hash_map_iterator_pt hashmap_itterator =  hashMapIterator_create(channel->eventHandlers);
+			while(hashMapIterator_hasNext(hashmap_itterator)){
+				printf("add handler \n");
+				event_handler_service_pt event_handler_service = NULL;
+				event_handler_service = (event_handler_service_pt) hashMapIterator_nextValue(hashmap_itterator);
+				arrayList_add(event_handlers,event_handler_service);
+			}
+		}
+	}else {
+		printf("no channel\n");
+	}
+	return status;
+}
+
+celix_status_t eventAdmin_createEventChannels(event_admin_pt *event_admin, char *topic, event_handler_service_pt event_handler_service){
+	celix_status_t status = CELIX_SUCCESS;
+	char channel_name[strlen(topic)+1];
+	strcpy(channel_name,topic);
+	printf("Creating channel: %s\n");
+	//char complete_channel_name[strlen(topic)+1];
+	channel_t channel;
+	apr_pool_t *subPool= NULL;
+	apr_pool_create(&subPool,(*event_admin)->pool);
+	if(hashMap_containsKey((*event_admin)->channels,channel_name)==1) {
+		channel = hashMap_get((*event_admin)->channels,channel_name);
+		//hashMap_put(channel->eventHandlers,&event_handler_service,event_handler_service);
+	}else {
+		//create channel
+		channel = apr_palloc(subPool, sizeof(*channel));
+		if(!channel){
+			status = CELIX_ENOMEM;
+		}else {
+			channel->topic = channel_name;
+			channel->eventHandlers = hashMap_create(NULL,NULL,NULL,NULL);
+			channel->channelLock = NULL;
+			apr_thread_mutex_create(&channel->channelLock,APR_THREAD_MUTEX_NESTED, subPool);
+			hashMap_put((*event_admin)->channels,channel_name,channel);
+		}
+		hashMap_put(channel->eventHandlers,&event_handler_service,event_handler_service);
+	}
+
+	return status;
+
+	/*apr_pool_t *subPool= NULL;
+	apr_pool_create(&subPool,(*event_admin)->pool);
+	char delims[] = "/";
+	char *result = NULL;
+	result = strtok( topic, delims );
+	if(result != NULL){
+		strcpy(complete_channel_name, result);
+	}
+	while( result != NULL  && status == CELIX_SUCCESS) {
+	    channel_t channel;
+	    //check if the channel exists
+	    if(hashMap_containsKey((*event_admin)->channels,complete_channel_name)==1) {
+	    	channel = hashMap_get((*event_admin)->channels,complete_channel_name);
+	    	//hashMap_put(channel->eventHandlers,&event_handler_service,event_handler_service);
+	    }else {
+	    	//create channel
+	    	channel = apr_palloc(subPool, sizeof(*channel));
+	    	if(!channel){
+	    		status = CELIX_ENOMEM;
+	    	}else {
+	    		channel->topic = complete_channel_name;
+				channel->eventHandlers = hashMap_create(NULL,NULL,NULL,NULL);
+				channel->channelLock = NULL;
+				apr_thread_mutex_create(&channel->channelLock,APR_THREAD_MUTEX_NESTED, subPool);
+	    	}
+	    }
+	    result = strtok( NULL, delims );
+	    if(result != NULL && status == CELIX_SUCCESS){
+	    	strcat(complete_channel_name, "/");
+	    	strcat(complete_channel_name, result);
+	    }else if(status == CELIX_SUCCESS) {
+	    	hashMap_put(channel->eventHandlers,&event_handler_service,event_handler_service);
+	    }
+	}*/
+
+}
+
+celix_status_t eventAdmin_lockHandlersList(event_admin_pt event_admin, char *topic ){
+	celix_status_t status = CELIX_SUCCESS;
+	char *channel_name;
+	printf("lock: %s\n",topic);
+
+	printf("LOCK!\n");
+	return status;
+}
+celix_status_t eventAdmin_releaseHandersList(event_admin_pt event_admin, char *topic ){
+	celix_status_t status = CELIX_SUCCESS;
+	char *channel_name;
+	printf("release: %s\n",topic);
+
+	printf("UNLOCK\n");
+	return status;
+}
+
+celix_status_t eventAdmin_addingService(void * handle, service_reference_pt ref, void **service) {
+
+	celix_status_t status = CELIX_SUCCESS;
+	event_admin_pt  event_admin = handle;
+	status = bundleContext_getService(event_admin->context, ref, service);
+  	return CELIX_SUCCESS;
+}
+
+celix_status_t eventAdmin_addedService(void * handle, service_reference_pt ref, void * service) {
+	celix_status_t status = CELIX_SUCCESS;
+	event_admin_pt  event_admin = handle;
+	event_handler_service_pt event_handler_service = NULL;
+	event_handler_service = (event_handler_service_pt) service;
+	service_registration_pt registration = NULL;
+	serviceReference_getServiceRegistration(ref,&registration);
+	properties_pt props = NULL;
+	serviceRegistration_getProperties(registration, &props);
+	char *topic = properties_get(props, (char*)EVENT_TOPIC);
+	printf("Original TOPIC: %s\n,",topic);
+	eventAdmin_createEventChannels(&event_admin,topic,event_handler_service);
+	return CELIX_SUCCESS;
+}
+
+celix_status_t eventAdmin_modifiedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Modified\n");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t eventAdmin_removedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Removed %p\n", service);
+	return CELIX_SUCCESS;
+}

Added: incubator/celix/trunk/event_admin/event_admin/private/src/event_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/private/src/event_impl.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/private/src/event_impl.c (added)
+++ incubator/celix/trunk/event_admin/event_admin/private/src/event_impl.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,139 @@
+/**
+ *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.
+ */
+/*
+ * event_impl.c
+ *
+ *  \Created on: Aug 22, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ *
+ */
+
+
+#include "event_admin.h"
+#include "event_admin_impl.h"
+#include "event_constants.h"
+#include "celix_errno.h"
+#include "stddef.h"
+#include <apr.h>
+#include <apr_pools.h>
+struct event {
+	char *topic;
+	properties_pt properties;
+};
+
+celix_status_t eventAdmin_createEvent(event_admin_pt *event_admin, char *topic, properties_pt properties, event_pt *event){
+	celix_status_t status = CELIX_SUCCESS;
+
+	printf("create event event admin pointer: %p\n",(*event_admin));
+	printf("pool create event: %p\n",(*event_admin)->pool);
+
+	*event = apr_palloc((*event_admin)->pool,sizeof(**event));
+	if(!*event){
+	       status = CELIX_ENOMEM;
+	       printf("No MEM\n");
+	}else {
+		printf("Event created : %s \n",topic);
+		(*event)->topic = topic;
+		(*event)->properties = properties;
+		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);
+	}
+	return status;
+}
+
+celix_status_t eventAdmin_containsProperty( event_pt *event, char *property, bool *result){
+	celix_status_t status = CELIX_SUCCESS;
+	if((*event)==NULL || property == NULL){
+		status = CELIX_BUNDLE_EXCEPTION;
+	}else {
+		char * propertyValue = properties_get((*event)->properties,property);
+		if(propertyValue == NULL){
+			(*result)= false;
+		}else {
+			(*result) = true;
+		}
+	}
+	return status;
+}
+
+celix_status_t eventAdmin_event_equals( event_pt *event, event_pt *compare, bool *result){
+	celix_status_t status = CELIX_SUCCESS;
+	if(event == compare){
+		(*result) = true;
+	}else {
+		int sizeofEvent = hashMap_size((*event)->properties);
+		int sizeofCompare = hashMap_size((*compare)->properties);
+		if(sizeofEvent == sizeofCompare){
+			(*result) = true;
+		}else {
+
+		}
+	}
+	return status;
+}
+
+celix_status_t eventAdmin_getProperty( event_pt *event, char *propertyKey,  char **propertyValue){
+	celix_status_t status = CELIX_SUCCESS;
+	*propertyValue = properties_get((*event)->properties,propertyKey);
+
+	return status;
+}
+
+celix_status_t eventAdmin_getPropertyNames( event_pt *event, array_list_pt *names){
+	celix_status_t status = CELIX_SUCCESS;
+	properties_pt properties =  (*event)->properties;
+	if (hashMap_size(properties) > 0) {
+		hash_map_iterator_pt iterator = hashMapIterator_create(properties);
+		while (hashMapIterator_hasNext(iterator)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+			char * key =hashMapEntry_getKey(entry);
+			arrayList_add((*names),key);
+		}
+	}
+	return status;
+}
+
+celix_status_t eventAdmin_getTopic( event_pt *event, char **topic){
+	celix_status_t status = CELIX_SUCCESS;
+	char *value;
+	value = properties_get((*event)->properties,(char*) EVENT_TOPIC);
+	*topic = value;
+
+	return status;
+}
+
+celix_status_t eventAdmin_hashCode( event_pt *event, int *hashCode){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+celix_status_t eventAdmin_matches( event_pt *event){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+celix_status_t eventAdmin_toString( event_pt *event, char *eventString){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+
+
+

Added: incubator/celix/trunk/event_admin/event_admin/public/include/event_admin.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/public/include/event_admin.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/public/include/event_admin.h (added)
+++ incubator/celix/trunk/event_admin/event_admin/public/include/event_admin.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,62 @@
+/**
+ *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.
+ */
+/*
+ * event_admin.h
+ *
+ *  Created on: Jul 9, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_ADMIN_H_
+#define EVENT_ADMIN_H_
+/*#include "event.h"*/
+#include "celix_errno.h"
+
+#include "listener_hook_service.h"
+
+#define EVENT_ADMIN_NAME "event_admin"
+typedef struct event_admin *event_admin_pt;
+typedef struct event_admin_service *event_admin_service_pt;
+typedef struct event *event_pt;
+/**
+ * @desc service description for the event admin.
+ * @param event_admin_pt eventAdmin. incomplete type for the event admin instance.
+ * @param celix_status_t postEvent. Pointer to the post event function. For async sending
+ * @param celix_status_t sendEvent. Pointer to the send event function. for Sync sending
+ */
+struct event_admin_service {
+	event_admin_pt eventAdmin;
+	celix_status_t (*postEvent)(event_admin_pt event_admin, event_pt event);
+	celix_status_t (*sendEvent)(event_admin_pt event_admin, event_pt event);
+
+	celix_status_t (*createEvent)(event_admin_pt event_admin, char *topic, properties_pt properties,  event_pt *event);
+	celix_status_t (*containsProperty)(event_pt *event, char *property, bool *result);
+	celix_status_t (*event_equals)(event_pt *event, event_pt *compare, bool *result);
+	celix_status_t (*getProperty)( event_pt *event, char *propertyKey, char **propertyValue);
+	celix_status_t (*getPropertyNames)(event_pt *event, array_list_pt *names);
+	celix_status_t (*getTopic)( event_pt *event, char **topic);
+	celix_status_t (*hashCode)(event_pt *event, int *hashCode);
+	celix_status_t (*matches)( event_pt *event);
+	celix_status_t (*toString)( event_pt *event, char *eventString);
+
+};
+
+
+#endif /* EVENT_ADMIN_H_ */

Added: incubator/celix/trunk/event_admin/event_admin/public/include/event_constants.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/public/include/event_constants.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/public/include/event_constants.h (added)
+++ incubator/celix/trunk/event_admin/event_admin/public/include/event_constants.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,60 @@
+/**
+ *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.
+ */
+/*
+ * event_constants.h
+ *
+ *  Created on: Aug 11, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_CONSTANTS_H_
+#define EVENT_CONSTANTS_H_
+
+static const char * const EVENT_BUNDLE = "bundle";
+static const char * const EVENT_BUNDLE_ID = "bundle.id";
+static const char * const EVENT_BUNDLE_SIGNER = "bundle.signer";
+
+static const char * const EVENT_BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
+
+
+static const char * const EVENT_BUNDLE_VERSION = "bundle.version";
+
+static const char * const EVENT_DELIVERY_ASYNC_ORDERED = "async.ordered";
+static const char * const EVENT_DELIVERY_ASYNC_UNORDERED = "async.unordered";
+static const char * const EVENT = "event";
+static const char * const EVENT_DELIVERY = "event.delivery";
+static const char * const EVENT_FILTER = "event.filter";
+static const char * const EVENT_TOPIC = "event.topic";
+static const char * const EVENT_EXCEPTION = "exception";
+static const char * const EVENT_EXCEPTION_CLASS = "exception.class";
+static const char * const EVENT_EXCEPTION_MESSAGE = "exception.message";
+static const char * const MESSAGE = "message";
+
+static const char * const EVENT_SERVICE = "service";
+
+static const char * const EVENT_SERVICE_ID = "async.ordered";
+
+static const char * const EVENT_SERVICE_OBJECTCLASS = "service.objectClass";
+
+static const char * const EVENT_SERVICE_PID = "service.pid";
+
+static const char * const EVENT_TIMESTAMP = "timestamp";
+
+#endif /* EVENT_CONSTANTS_H_ */

Added: incubator/celix/trunk/event_admin/event_admin/public/include/event_handler.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_admin/public/include/event_handler.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_admin/public/include/event_handler.h (added)
+++ incubator/celix/trunk/event_admin/event_admin/public/include/event_handler.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,45 @@
+/**
+ *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.
+ */
+/*
+ * event_handler.h
+ *
+ *  Created on: Jul 22, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_HANDLER_H_
+#define EVENT_HANDLER_H_
+#include "event_admin.h"
+#include "properties.h"
+static const char * const EVENT_HANDLER_SERVICE = "service.event.handler";
+
+typedef struct event_handler_service *event_handler_service_pt;
+typedef struct event_handler *event_handler_pt; //ADT
+/**
+ * @desc description of the event handler service
+ * @param event_handler_pt event_handler incomplete type pointer for the event_handler instance
+ * @param celix_status_t handle event. pointer to the handle event method.
+ */
+struct event_handler_service {
+		event_handler_pt event_handler;
+        celix_status_t (*handle_event)(event_handler_pt *event_handler, event_pt event);
+};
+
+#endif /* EVENT_HANDLER_H_ */

Added: incubator/celix/trunk/event_admin/event_handler/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_handler/CMakeLists.txt?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_handler/CMakeLists.txt (added)
+++ incubator/celix/trunk/event_admin/event_handler/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -0,0 +1,37 @@
+# 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.
+
+find_package(APR REQUIRED)
+find_package(CELIX REQUIRED)
+
+include_directories(private/include)
+include_directories(${PROJECT_SOURCE_DIR}/event_admin/event_admin/public/include)
+include_directories("${CELIX_INCLUDE_DIRS}")
+
+SET_HEADER(BUNDLE_SYMBOLICNAME "eventhandler")
+SET_HEADERS("Bundle-Name: Event Handler")
+
+
+bundle(event_handler 
+	SOURCES 
+		private/src/event_handler_activator.c
+		private/src/event_handler_impl.c
+)
+
+install_bundle(event_handler)
+
+target_link_libraries(event_handler celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})

Added: incubator/celix/trunk/event_admin/event_handler/private/include/event_handler_impl.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_handler/private/include/event_handler_impl.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_handler/private/include/event_handler_impl.h (added)
+++ incubator/celix/trunk/event_admin/event_handler/private/include/event_handler_impl.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,57 @@
+/**
+ *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.
+ */
+/*
+ * event_handler_impl.h
+ *
+ *  Created on: Aug 20, 2013
+  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_HANDLER_IMPL_H_
+#define EVENT_HANDLER_IMPL_H_
+#include "event_admin.h"
+#include "event_constants.h"
+#include "event_handler.h"
+
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "service_listener.h"
+#include "service_registration.h"
+#include "listener_hook_service.h"
+#include "event_constants.h"
+/**
+ * @desc handle the event send to the event handler
+ * @param event_handler_pt *instance the instance of the event handlers
+ * @param event_pt event. the event to be handled.
+ */
+celix_status_t eventHandlerHandleEvent(event_handler_pt *instance, event_pt event) ;
+
+/**
+ * @desc create the event handler
+ * @param apr_pool_t *pool the apr pool to contain the handler
+ * @param event_handler_pt *event_handler. the event handler to be made.
+ */
+celix_status_t eventHandlerCreate(apr_pool_t *pool, bundle_context_pt context,  event_handler_pt *event_handler);
+celix_status_t  eventHandlerRemovedService(void * handle, service_reference_pt ref, void * service) ;
+celix_status_t  eventHandlerModifiedService(void * handle, service_reference_pt ref, void * service) ;
+celix_status_t  eventHandlerAddedService(void * handle, service_reference_pt ref, void * service) ;
+celix_status_t  eventHandlerAddingService(void * handle, service_reference_pt ref, void **service) ;
+#endif /* EVENT_HANDLER_IMPL_H_ */

Added: incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_activator.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_activator.c (added)
+++ incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_activator.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,109 @@
+/**
+ *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
+ *
+ *  Created on: Jul 9, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+
+
+#include "event_handler_impl.h"
+
+static const char * const EVENT_HANDLER_NAME = "demo";
+struct activator {
+	apr_pool_t *pool;
+	event_handler_service_pt event_handler_service;
+	service_registration_pt registration;
+	service_tracker_pt eventAdminTracker;
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	apr_pool_t *pool = NULL;
+	apr_pool_t *parentPool;
+	struct activator *activator;
+	status = bundleContext_getMemoryPool(context, &parentPool);
+	if( status == CELIX_SUCCESS ) {
+		if(apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}else {
+			activator = apr_palloc(pool,sizeof(*activator));
+			activator->pool = pool;
+			activator->registration = NULL;
+			*userData = activator;
+			event_handler_pt event_handler = NULL;
+			event_handler_service_pt event_handler_service = NULL;
+			status = eventHandlerCreate(activator->pool,context,&event_handler);
+			if(status == CELIX_SUCCESS){
+				event_handler_service = apr_palloc(activator->pool,sizeof(event_handler_service));
+				if(!event_handler_service){
+					status = CELIX_ENOMEM;
+				}else {
+					event_handler_service->event_handler = event_handler;
+					event_handler_service->handle_event = eventHandlerHandleEvent;
+				}
+			}
+			activator->event_handler_service = event_handler_service;
+		}
+	}
+
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator *activator = userData;
+	properties_pt properties = NULL;
+	properties = properties_create();
+	properties_set(properties,(char*)EVENT_HANDLER_SERVICE,(char *)EVENT_HANDLER_NAME);
+	properties_set(properties,(char*)EVENT_TOPIC, (char*) "log/error/eventpublishers/event");
+	event_handler_service_pt event_handler_service = activator->event_handler_service;
+	bundleContext_registerService(context, (char *) EVENT_HANDLER_SERVICE, event_handler_service, properties, &activator->registration);
+	apr_pool_t *pool;
+	status = bundleContext_getMemoryPool(context, &pool);
+	if(status == CELIX_SUCCESS) {
+		service_tracker_customizer_pt customizer = NULL;
+		service_tracker_pt tracker = NULL;
+		serviceTrackerCustomizer_create(pool, activator->event_handler_service->event_handler,  eventHandlerAddingService, eventHandlerAddedService, eventHandlerModifiedService, eventHandlerRemovedService, &customizer);
+		serviceTracker_create(pool, context, (char *) EVENT_ADMIN_NAME, customizer,
+									&tracker);
+		activator->eventAdminTracker = tracker;
+		serviceTracker_open(tracker);
+		properties_pt properties = NULL;
+		properties = properties_create();
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}
+
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}

Added: incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c (added)
+++ incubator/celix/trunk/event_admin/event_handler/private/src/event_handler_impl.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,97 @@
+/**
+ *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.
+ */
+/*
+ * event_admin_impl.c
+ *
+ *  Created on: Jul 24, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include "event_handler.h"
+
+struct event_handler {
+	apr_pool_t *pool;
+	event_admin_service_pt event_admin_service;
+	bundle_context_pt context;
+};
+
+celix_status_t eventHandlerCreate(apr_pool_t *pool, bundle_context_pt context,  event_handler_pt *event_handler){
+	celix_status_t status = CELIX_SUCCESS;
+	*event_handler = apr_palloc(pool, sizeof(**event_handler));
+	if(!*event_handler){
+			status = CELIX_ENOMEM;
+	}else {
+			(*event_handler)->pool = pool;
+			(*event_handler)->event_admin_service = NULL;
+			(*event_handler)->context = context;
+	}
+	return status;
+}
+
+celix_status_t eventHandlerHandleEvent(event_handler_pt *event_handler, event_pt event) {
+	celix_status_t status = CELIX_SUCCESS;
+	printf("handle event called in first handler\n");
+	if(event != NULL){
+		char *topic = NULL;
+		status = (*event_handler)->event_admin_service->getTopic(&event,&topic);
+		printf("topic of event: %s\n",topic);
+		array_list_pt propertyNames;
+		arrayList_create(&propertyNames);
+		status = (*event_handler)->event_admin_service->getPropertyNames(&event,&propertyNames);
+		array_list_iterator_pt propertyIter = arrayListIterator_create(propertyNames);
+		while(arrayListIterator_hasNext(propertyIter)){
+			char *key = arrayListIterator_next(propertyIter);
+			char *value = NULL;
+			(*event_handler)->event_admin_service->getProperty(&event,key,&value);
+			//getProperty(&event,key,&value);
+			printf("Key: %s value: %s\n",key,value);
+		}
+	}
+	return status;
+}
+
+
+celix_status_t  eventHandlerAddingService(void * handle, service_reference_pt ref, void **service) {
+	celix_status_t status = CELIX_SUCCESS;
+	printf("event handler adding service \n");
+	event_handler_pt event_handler = handle;
+	status = bundleContext_getService(event_handler->context, ref, service);
+	return status;
+}
+
+celix_status_t  eventHandlerAddedService(void * handle, service_reference_pt ref, void * service) {
+	printf("Event handler Added service \n");
+	event_handler_pt  data =  handle;
+	event_admin_service_pt event_admin_service = NULL;
+	event_admin_service = (event_admin_service_pt ) service;
+	data->event_admin_service = event_admin_service;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t  eventHandlerModifiedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Modified\n");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t  eventHandlerRemovedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Removed %p\n", service);
+	return CELIX_SUCCESS;
+}

Added: incubator/celix/trunk/event_admin/event_publisher/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_publisher/CMakeLists.txt?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_publisher/CMakeLists.txt (added)
+++ incubator/celix/trunk/event_admin/event_publisher/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -0,0 +1,36 @@
+# 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.
+
+find_package(APR REQUIRED)
+find_package(CELIX REQUIRED)
+
+include_directories(private/include)
+include_directories(${PROJECT_SOURCE_DIR}/event_admin/event_admin/public/include)
+include_directories("${CELIX_INCLUDE_DIRS}")
+
+SET_HEADER(BUNDLE_SYMBOLICNAME "event_publisher")
+SET_HEADERS("Bundle-Name: Event Publisher")
+
+
+bundle(event_publisher SOURCES 
+	private/src/event_publisher_activator.c
+	private/src/event_publisher_impl.c
+)
+
+install_bundle(event_publisher)
+
+target_link_libraries(event_publisher celix_framework celix_utils ${APR_LIBRARY} ${APRUTIL_LIBRARY})

Added: incubator/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h (added)
+++ incubator/celix/trunk/event_admin/event_publisher/private/include/event_publisher_impl.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,84 @@
+/**
+ *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.
+ */
+/*
+ * event_publisher.h
+ *
+ *  Created on: Aug 9, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#ifndef EVENT_PUBLISHER_H_
+#define EVENT_PUBLISHER_H_
+#include "celix_errno.h"
+#include "event_admin.h"
+
+#include "listener_hook_service.h"
+#include "service_tracker.h"
+#include "bundle_activator.h"
+#include "bundle_context.h"
+#include "service_tracker.h"
+#include "service_listener.h"
+#include "service_registration.h"
+#include "event_constants.h"
+#include <apr.h>
+#include <apr_pools.h>
+typedef struct event_publisher *event_publisher_pt;
+struct event_publisher {
+	apr_pool_t *pool;
+	event_admin_service_pt event_admin_service;
+	bool running;
+	bool eventAdminAdded;
+	apr_thread_t *sender;
+	bundle_context_pt context;
+};
+/**
+ * @desc create the event publisher
+ * @param apr_pool_t *pool. the memory pool to store the publisher
+ * @param bundle_context_pt context the bundle context
+ * @param event_publisher_pt *event_publisher. The publisher to be made.
+ */
+celix_status_t eventPublisherCreate(apr_pool_t *pool, bundle_context_pt context, event_publisher_pt *event_publisher);
+/**
+ * @desc start the event publisher. Starts the threads and trackers.
+ * @param event_publisher_pt *event_publisher the publisher to start
+ */
+celix_status_t eventPublisherStart(event_publisher_pt *event_publisher);
+/**
+ * @desc the thread sending events.
+ * @param apr_thread_t *thd a pointer to the thread
+ * @param void *handle. Pointer to the event publisher
+ */
+static void *APR_THREAD_FUNC eventPublisherSendEventThread(apr_thread_t *thd, void *handle);
+/**
+ * @desc functions used by the event admin tracker
+ * @param void *handle, pointer to the event publisher
+ * @param service_reference_pt ref. pointer to the reference of the event admin
+ * @param void **service. pointer to the event admin service.
+ */
+celix_status_t eventPublisherAddingService(void * handle, service_reference_pt ref, void **service);
+celix_status_t eventPublisherAddedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventPublisherModifiedService(void * handle, service_reference_pt ref, void * service);
+celix_status_t eventPublisherRemovedService(void * handle, service_reference_pt ref, void * service);
+/**
+ * @desc stop the event publisher. stopping threads and tracker
+ * @param event_publisher_pt *event_publisher. pointer to the publisher.
+ */
+celix_status_t eventPublisherStop(event_publisher_pt *event_publisher);
+#endif /* EVENT_PUBLISHER_H_ */

Added: incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_activator.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_activator.c (added)
+++ incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_activator.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,98 @@
+/**
+ *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
+ *
+ *  Created on: Jul 9, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+#include <stdlib.h>
+
+
+#include "event_publisher_impl.h"
+
+struct activator {
+	apr_pool_t *pool;
+	bundle_context_pt context;
+	event_publisher_pt event_publisher;
+	service_tracker_pt tracker;
+};
+
+celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
+	celix_status_t status = CELIX_SUCCESS;
+	apr_pool_t *pool = NULL;
+	apr_pool_t *parentPool;
+	struct activator *activator;
+	status = bundleContext_getMemoryPool(context, &parentPool);
+	if( status == CELIX_SUCCESS ) {
+		if(apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}else {
+			activator = apr_palloc(pool,sizeof(*activator));
+			activator->pool = pool;
+			activator->context = context;
+			*userData = activator;
+		}
+	}
+	event_publisher_pt eventpublisher;
+	status = eventPublisherCreate(activator->pool,context,&eventpublisher);
+	if(status == CELIX_SUCCESS) {
+
+		activator->event_publisher = eventpublisher;
+
+	}
+	return status;
+}
+
+celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator * data = (struct activator *) userData;
+	apr_pool_t *pool;
+	status = bundleContext_getMemoryPool(context, &pool);
+	if(status == CELIX_SUCCESS){
+		service_tracker_customizer_pt cust = NULL;
+		service_tracker_pt tracker = NULL;
+		data->context = context;
+		serviceTrackerCustomizer_create(pool, data->event_publisher,  eventPublisherAddingService, eventPublisherAddedService, eventPublisherModifiedService, eventPublisherRemovedService, &cust);
+		serviceTracker_create(pool, context, (char *) EVENT_ADMIN_NAME, cust,
+							&tracker);
+		data->tracker = tracker;
+
+		serviceTracker_open(tracker);
+		properties_pt properties = NULL;
+		properties = properties_create();
+	}
+	eventPublisherStart(&data->event_publisher);
+	return status;
+}
+
+celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+	struct activator * data = (struct activator *) userData;
+	eventPublisherStop(&data->event_publisher);
+	serviceTracker_close(data->tracker);
+	return status;
+}
+
+celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
+	celix_status_t status = CELIX_SUCCESS;
+
+	return status;
+}

Added: incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c (added)
+++ incubator/celix/trunk/event_admin/event_publisher/private/src/event_publisher_impl.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,130 @@
+/**
+ *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.
+ */
+/*
+ * event_admin_impl.c
+ *
+ *  Created on: Jul 24, 2013
+  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+#include "event_publisher_impl.h"
+
+celix_status_t eventPublisherCreate(apr_pool_t *pool, bundle_context_pt context, event_publisher_pt *event_publisher){
+        celix_status_t status = CELIX_SUCCESS;
+        *event_publisher = apr_palloc(pool, sizeof(**event_publisher));
+
+        if(!*event_publisher){
+                status = CELIX_ENOMEM;
+        }else {
+        	(*event_publisher)->event_admin_service = NULL;
+        	(*event_publisher)->pool = NULL;
+        	(*event_publisher)->eventAdminAdded = false;
+        	(*event_publisher)->running = false;
+        	(*event_publisher)->pool = pool;
+        	(*event_publisher)->context = context;
+        }
+        return status;
+}
+
+celix_status_t eventPublisherStart(event_publisher_pt *event_publisher){
+	(*event_publisher)->running = true;
+	apr_thread_create(&(*event_publisher)->sender, NULL, eventPublisherSendEventThread, event_publisher, (*event_publisher)->pool);
+
+	return CELIX_SUCCESS;
+}
+
+celix_status_t eventPublisherStop(event_publisher_pt *event_publisher){
+	(*event_publisher)->running = false;
+	apr_status_t status;
+	apr_thread_join(&status,(*event_publisher)->sender);
+	return CELIX_SUCCESS;
+}
+
+static void *APR_THREAD_FUNC eventPublisherSendEventThread(apr_thread_t *thd, void *handle) {
+//celix_status_t trk_send(apr_thread_t *thd, void *handle) { //this function decleration is for debuggin purposes only.
+	/*event_publisher_pt client =  handle;
+
+	while (client->running && client->eventAdminAdded) {
+		apr_sleep(1000000);
+		event_admin_service_pt event_admin_service = client->event_admin_service ;
+		event_admin_pt event_admin =   event_admin_service->eventAdmin;
+		if (event_admin_service != NULL) {
+			event_pt event;
+			properties_pt props = properties_create();
+			properties_set(props,"This is a key","this is a value");
+
+			createEvent("log/error/eventpublishers/event/testChannel",props,client->pool,&event);
+			event_admin_service->postEvent(event_admin,event);
+			event_admin_service->sendEvent(event_admin,event);
+		}
+
+	}*/
+	 event_publisher_pt *client = (event_publisher_pt *) handle;
+
+		while ((*client)->running && (*client)->eventAdminAdded) {
+				apr_sleep(1000000);
+				event_admin_service_pt *event_admin_service = &(*client)->event_admin_service ;
+				printf("event admin service pointer in publisher : %p\n",event_admin_service);
+				event_admin_pt event_admin =   (*event_admin_service)->eventAdmin;
+				if (event_admin_service != NULL) {
+
+						event_pt event;
+						properties_pt props = properties_create();
+						properties_set(props,"This is a key","this is a value");
+						(*event_admin_service)->createEvent(event_admin,"log/error/eventpublishers/event/testChannel",props,&event);
+						(*event_admin_service)->postEvent(event_admin,event);
+						(*event_admin_service)->sendEvent(event_admin,event);
+				}
+
+		}
+	apr_thread_exit(thd, APR_SUCCESS);
+	return NULL;
+}
+
+celix_status_t  eventPublisherAddingService(void * handle, service_reference_pt ref, void **service) {
+	celix_status_t status = CELIX_SUCCESS;
+	event_publisher_pt event_publisher = handle;
+	status = bundleContext_getService(event_publisher->context, ref, service);
+	return status;
+}
+
+celix_status_t  eventPublisherAddedService(void * handle, service_reference_pt ref, void * service) {
+
+	 event_publisher_pt  data =  handle;
+	 event_admin_service_pt event_admin_service = NULL;
+	 event_admin_service = (event_admin_service_pt ) service;
+	 data->event_admin_service = event_admin_service;
+	 data->eventAdminAdded = true;
+	return CELIX_SUCCESS;
+}
+
+celix_status_t  eventPublisherModifiedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Modified\n");
+	return CELIX_SUCCESS;
+}
+
+celix_status_t  eventPublisherRemovedService(void * handle, service_reference_pt ref, void * service) {
+	struct data * data = (struct data *) handle;
+	printf("Event admin Removed %p\n", service);
+	return CELIX_SUCCESS;
+}
+
+

Added: incubator/celix/trunk/event_admin/utils/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/utils/CMakeLists.txt?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/utils/CMakeLists.txt (added)
+++ incubator/celix/trunk/event_admin/utils/CMakeLists.txt Wed Apr  9 15:27:17 2014
@@ -0,0 +1,27 @@
+# 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.
+find_package(APR REQUIRED)
+find_package(CELIX REQUIRED)
+include_directories("${CELIX_INCLUDE_DIRS}")
+include_directories("${PROJECT_SOURCE_DIR}/event_admin/event_admin/public/include")
+include_directories(public/include)
+
+add_library(event_admin_utils STATIC private/src/event_impl.c)
+target_link_libraries(event_admin_utils ${APRUTIL_LIBRARY})
+#install(TARGETS event_admin_utils DESTINATION lib COMPONENT framework)
+#FILE(GLOB files "public/include/*.h")
+#INSTALL(FILES ${files} DESTINATION include/celix COMPONENT framework)
\ No newline at end of file

Added: incubator/celix/trunk/event_admin/utils/private/src/event_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/utils/private/src/event_impl.c?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/utils/private/src/event_impl.c (added)
+++ incubator/celix/trunk/event_admin/utils/private/src/event_impl.c Wed Apr  9 15:27:17 2014
@@ -0,0 +1,133 @@
+/**
+ *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.
+ */
+/*
+ * event_impl.c
+ *
+ *  \Created on: Aug 22, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ *
+ */
+
+
+#include "event.h"
+#include "event_constants.h"
+#include "celix_errno.h"
+#include "stddef.h"
+#include <apr.h>
+#include <apr_pools.h>
+struct event {
+	char *topic;
+	properties_pt properties;
+};
+
+celix_status_t createEvent(char *topic, properties_pt properties, apr_pool_t *pool, event_pt *event){
+	celix_status_t status = CELIX_SUCCESS;
+
+	*event= apr_palloc(pool,sizeof(**event));
+	if(!*event){
+	       status = CELIX_ENOMEM;
+	}else {
+		(*event)->topic = topic;
+		(*event)->properties = properties;
+		properties_set((*event)->properties, (char *)EVENT_TOPIC, topic);
+	}
+	return status;
+}
+
+celix_status_t containsProperty(event_pt *event, char *property, bool *result){
+	celix_status_t status = CELIX_SUCCESS;
+	if((*event)==NULL || property == NULL){
+		status = CELIX_BUNDLE_EXCEPTION;
+	}else {
+		char * propertyValue = properties_get((*event)->properties,property);
+		if(propertyValue == NULL){
+			(*result)= false;
+		}else {
+			(*result) = true;
+		}
+	}
+	return status;
+}
+
+celix_status_t event_equals(event_pt *event, event_pt *compare, bool *result){
+	celix_status_t status = CELIX_SUCCESS;
+	if(event == compare){
+		(*result) = true;
+	}else {
+		int sizeofEvent = hashMap_size((*event)->properties);
+		int sizeofCompare = hashMap_size((*compare)->properties);
+		if(sizeofEvent == sizeofCompare){
+			(*result) = true;
+		}else {
+
+		}
+	}
+	return status;
+}
+
+celix_status_t getProperty(event_pt *event, char *propertyKey,  char **propertyValue){
+	celix_status_t status = CELIX_SUCCESS;
+	*propertyValue = properties_get((*event)->properties,propertyKey);
+
+	return status;
+}
+
+celix_status_t getPropertyNames(event_pt *event, array_list_pt *names){
+	celix_status_t status = CELIX_SUCCESS;
+	properties_pt properties =  (*event)->properties;
+	if (hashMap_size(properties) > 0) {
+		hash_map_iterator_pt iterator = hashMapIterator_create(properties);
+		while (hashMapIterator_hasNext(iterator)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+			char * key =hashMapEntry_getKey(entry);
+			arrayList_add((*names),key);
+		}
+	}
+	return status;
+}
+
+celix_status_t getTopic(event_pt *event, char **topic){
+	celix_status_t status = CELIX_SUCCESS;
+	char *value;
+	value = properties_get((*event)->properties,(char*) EVENT_TOPIC);
+	*topic = value;
+
+	return status;
+}
+
+celix_status_t hashCode(event_pt *event, int *hashCode){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+celix_status_t matches(event_pt *event){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+celix_status_t toString(event_pt *event, char *eventString){
+	celix_status_t status = CELIX_SUCCESS;
+	return status;
+}
+
+
+
+
+

Added: incubator/celix/trunk/event_admin/utils/public/include/event.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/event_admin/utils/public/include/event.h?rev=1585991&view=auto
==============================================================================
--- incubator/celix/trunk/event_admin/utils/public/include/event.h (added)
+++ incubator/celix/trunk/event_admin/utils/public/include/event.h Wed Apr  9 15:27:17 2014
@@ -0,0 +1,36 @@
+/**
+ *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.
+ */
+/*
+ * event.h
+ *
+ *  \Created on: Jul 19, 2013
+ *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project Team</a>
+ *  \copyright	Apache License, Version 2.0
+ */
+
+
+#ifndef EVENT_H_
+#define EVENT_H_
+#include "celix_errno.h"
+#include "properties.h"
+#include "array_list.h"
+
+
+
+#endif /* EVENT_H_ */



Mime
View raw message