Hello,
I have attached the header files created for the event admin. I have
left out the eventProperties and TopicPermissions at this point. The
topicPermission is a security aspect which I wanted to leave out of the
google summer of code project in order to be able to have more change to
get the project done in time. I have left the eventProperties out of the
implementation because I'm unsure of how it is supposed to work and if
it is needed.
Event_admin, event_handler and event_constants are all as far as I can
tell confirming to the specification. In event.h there is a method
equals which according to the spec will do: "Compares this Event object
to another object.
An event is considered to be equal to another event if the topic is
equal and the properties are equal.
The properties are compared using the java.util.Map.equals() rules which
includes identity compar-
ison for array values." I was thinking of first implementing by
comparing two pointers and not check on all properties.
What does everyone think of the header files?
/**
*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: erik
* copyright Apache License, Version 2.0
* note: Create for Google Summer of Code 2013
*/
#ifndef EVENT_CONSTANTS_H_
#define EVENT_CONSTANTS_H_
static const char * const BUNDLE = "bundle";
static const char * const BUNDLE_ID = "bundle.id";
static const char * const BUNDLE_SIGNER = "bundle.signer";
static const char * const BUNDLE_SYMBOLICNAME = "bundle.symbolicName";
static const char * const BUNDLE_VERSION = "bundle.version";
static const char * const DELIVERY_ASYNC_ORDERED = "async.ordered";
static const char * const 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 EXCEPTION = "exception";
static const char * const EXCEPTION_CLASS = "exception.class";
static const char * const EXCEPTION_MESSAGE = "exception.message";
static const char * const EXCEPTION_CLASS = "exception.class";
static const char * const MESSAGE = "message";
static const char * const SERVICE = "service";
static const char * const SERVICE_ID = "async.ordered";
static const char * const SERVICE_OBJECTCLASS = "service.objectClass";
static const char * const SERVICE_PID = "service.pid";
static const char * const TIMESTAMP = "timestamp";
#endif /* EVENT_CONSTANTS_H_ */
/**
*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: erik
* copyright Apache License, Version 2.0
* note: Create for Google Summer of Code 2013
*/
#ifndef EVENT_H_
#define EVENT_H_
#include "celix_errno.h"
#include "properties.h"
#include "array_list.h"
typedef struct event *event_pt;
celix_status_t createEvent(char *topic, properties_pt properties, event_pt *event);
celix_status_t containsProperty(event_pt *event, char *property, bool *result);
celix_status_t equals(event_pt *event, event_pt *compare, bool *result);
celix_status_t getProperty(event_pt *event, char *property, properties_pt *prop);
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_H_ */
/**
*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: erik
* copyright Apache License, Version 2.0
* note: Create for Google Summer of Code 2013
*/
#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;
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);
};
#endif /* EVENT_ADMIN_H_ */
/**
*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: erik
* copyright Apache License, Version 2.0
* note: Create for Google Summer of Code 2013
*/
#include "properties.h"
#ifndef EVENT_HANDLER_H_
#define EVENT_HANDLER_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
struct event_handler_service {
event_handler_pt event_handler;
celix_status_t (*handle_event)(event_handler_pt instance, event_pt event);
};
#endif /* EVENT_HANDLER_H_ */