You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2018/01/24 21:07:01 UTC
[09/11] celix git commit: Merge branch 'release/2.1.0' into
feature/CELIX-417-cmake-refactor
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/pubsub_admin_zmq/src/topic_subscription.c
----------------------------------------------------------------------
diff --cc pubsub/pubsub_admin_zmq/src/topic_subscription.c
index 0e7a794,0000000..9728865
mode 100644,000000..100644
--- a/pubsub/pubsub_admin_zmq/src/topic_subscription.c
+++ b/pubsub/pubsub_admin_zmq/src/topic_subscription.c
@@@ -1,732 -1,0 +1,732 @@@
+/**
+ *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.
+ */
+/*
+ * topic_subscription.c
+ *
+ * \date Oct 2, 2015
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+
+#include "topic_subscription.h"
+#include <czmq.h>
+/* The following undefs prevent the collision between:
+ * - sys/syslog.h (which is included within czmq)
+ * - celix/dfi/dfi_log_util.h
+ */
+#undef LOG_DEBUG
+#undef LOG_WARNING
+#undef LOG_INFO
+#undef LOG_WARNING
+
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "utils.h"
+#include "celix_errno.h"
+#include "constants.h"
+#include "version.h"
+
- #include "subscriber.h"
- #include "publisher.h"
++#include "pubsub/subscriber.h"
++#include "pubsub/publisher.h"
+#include "pubsub_utils.h"
+
+#ifdef BUILD_WITH_ZMQ_SECURITY
+#include "zmq_crypto.h"
+
+#define MAX_CERT_PATH_LENGTH 512
+#endif
+
+#define POLL_TIMEOUT 250
+#define ZMQ_POLL_TIMEOUT_MS_ENV "ZMQ_POLL_TIMEOUT_MS"
+
+struct topic_subscription{
+
+ zsock_t* zmq_socket;
+ zcert_t * zmq_cert;
+ zcert_t * zmq_pub_cert;
+ pthread_mutex_t socket_lock;
+ service_tracker_pt tracker;
+ array_list_pt sub_ep_list;
+ celix_thread_t recv_thread;
+ bool running;
+ celix_thread_mutex_t ts_lock;
+ bundle_context_pt context;
+
+ pubsub_serializer_service_t *serializer;
+
+ hash_map_pt servicesMap; // key = service, value = msg types map
+
+ celix_thread_mutex_t pendingConnections_lock;
+ array_list_pt pendingConnections;
+
+ array_list_pt pendingDisconnections;
+ celix_thread_mutex_t pendingDisconnections_lock;
+
+ unsigned int nrSubscribers;
+};
+
+typedef struct complete_zmq_msg{
+ zframe_t* header;
+ zframe_t* payload;
+}* complete_zmq_msg_pt;
+
+typedef struct mp_handle{
+ hash_map_pt svc_msg_db;
+ hash_map_pt rcv_msg_map;
+}* mp_handle_pt;
+
+typedef struct msg_map_entry{
+ bool retain;
+ void* msgInst;
+}* msg_map_entry_pt;
+
+static celix_status_t topicsub_subscriberTracked(void * handle, service_reference_pt reference, void * service);
+static celix_status_t topicsub_subscriberUntracked(void * handle, service_reference_pt reference, void * service);
+static void* zmq_recv_thread_func(void* arg);
+static bool checkVersion(version_pt msgVersion,pubsub_msg_header_pt hdr);
+static void sigusr1_sighandler(int signo);
+static int pubsub_localMsgTypeIdForMsgType(void* handle, const char* msgType, unsigned int* msgTypeId);
+static int pubsub_getMultipart(void *handle, unsigned int msgTypeId, bool retain, void **part);
+static mp_handle_pt create_mp_handle(hash_map_pt svc_msg_db,array_list_pt rcv_msg_list);
+static void destroy_mp_handle(mp_handle_pt mp_handle);
+static void connectPendingPublishers(topic_subscription_pt sub);
+static void disconnectPendingPublishers(topic_subscription_pt sub);
+
+celix_status_t pubsub_topicSubscriptionCreate(bundle_context_pt bundle_context, char* scope, char* topic, pubsub_serializer_service_t *best_serializer, topic_subscription_pt* out){
+ celix_status_t status = CELIX_SUCCESS;
+
+#ifdef BUILD_WITH_ZMQ_SECURITY
+ char* keys_bundle_dir = pubsub_getKeysBundleDir(bundle_context);
+ if (keys_bundle_dir == NULL){
+ return CELIX_SERVICE_EXCEPTION;
+ }
+
+ const char* keys_file_path = NULL;
+ const char* keys_file_name = NULL;
+ bundleContext_getProperty(bundle_context, PROPERTY_KEYS_FILE_PATH, &keys_file_path);
+ bundleContext_getProperty(bundle_context, PROPERTY_KEYS_FILE_NAME, &keys_file_name);
+
+ char sub_cert_path[MAX_CERT_PATH_LENGTH];
+ char pub_cert_path[MAX_CERT_PATH_LENGTH];
+
+ //certificate path ".cache/bundle{id}/version0.0/./META-INF/keys/subscriber/private/sub_{topic}.key.enc"
+ snprintf(sub_cert_path, MAX_CERT_PATH_LENGTH, "%s/META-INF/keys/subscriber/private/sub_%s.key.enc", keys_bundle_dir, topic);
+ snprintf(pub_cert_path, MAX_CERT_PATH_LENGTH, "%s/META-INF/keys/publisher/public/pub_%s.pub", keys_bundle_dir, topic);
+ free(keys_bundle_dir);
+
+ printf("PSA_ZMQ_PSA_ZMQ_TS: Loading subscriber key '%s'\n", sub_cert_path);
+ printf("PSA_ZMQ_PSA_ZMQ_TS: Loading publisher key '%s'\n", pub_cert_path);
+
+ zcert_t* sub_cert = get_zcert_from_encoded_file((char *) keys_file_path, (char *) keys_file_name, sub_cert_path);
+ if (sub_cert == NULL){
+ printf("PSA_ZMQ_PSA_ZMQ_TS: Cannot load key '%s'\n", sub_cert_path);
+ return CELIX_SERVICE_EXCEPTION;
+ }
+
+ zcert_t* pub_cert = zcert_load(pub_cert_path);
+ if (pub_cert == NULL){
+ zcert_destroy(&sub_cert);
+ printf("PSA_ZMQ_PSA_ZMQ_TS: Cannot load key '%s'\n", pub_cert_path);
+ return CELIX_SERVICE_EXCEPTION;
+ }
+
+ const char* pub_key = zcert_public_txt(pub_cert);
+#endif
+
+ zsock_t* zmq_s = zsock_new (ZMQ_SUB);
+ if(zmq_s==NULL){
+#ifdef BUILD_WITH_ZMQ_SECURITY
+ zcert_destroy(&sub_cert);
+ zcert_destroy(&pub_cert);
+#endif
+
+ return CELIX_SERVICE_EXCEPTION;
+ }
+
+#ifdef BUILD_WITH_ZMQ_SECURITY
+ zcert_apply (sub_cert, zmq_s);
+ zsock_set_curve_serverkey (zmq_s, pub_key); //apply key of publisher to socket of subscriber
+#endif
+
+ if(strcmp(topic,PUBSUB_ANY_SUB_TOPIC)==0){
+ zsock_set_subscribe (zmq_s, "");
+ }
+ else{
+ zsock_set_subscribe (zmq_s, topic);
+ }
+
+ topic_subscription_pt ts = (topic_subscription_pt) calloc(1,sizeof(*ts));
+ ts->context = bundle_context;
+ ts->zmq_socket = zmq_s;
+ ts->running = false;
+ ts->nrSubscribers = 0;
+ ts->serializer = best_serializer;
+
+#ifdef BUILD_WITH_ZMQ_SECURITY
+ ts->zmq_cert = sub_cert;
+ ts->zmq_pub_cert = pub_cert;
+#endif
+
+ celixThreadMutex_create(&ts->socket_lock, NULL);
+ celixThreadMutex_create(&ts->ts_lock,NULL);
+ arrayList_create(&ts->sub_ep_list);
+ ts->servicesMap = hashMap_create(NULL, NULL, NULL, NULL);
+
+ arrayList_create(&ts->pendingConnections);
+ arrayList_create(&ts->pendingDisconnections);
+ celixThreadMutex_create(&ts->pendingConnections_lock, NULL);
+ celixThreadMutex_create(&ts->pendingDisconnections_lock, NULL);
+
+ char filter[128];
+ memset(filter,0,128);
+ if(strncmp(PUBSUB_SUBSCRIBER_SCOPE_DEFAULT,scope,strlen(PUBSUB_SUBSCRIBER_SCOPE_DEFAULT)) == 0) {
+ // default scope, means that subscriber has not defined a scope property
+ snprintf(filter, 128, "(&(%s=%s)(%s=%s))",
+ (char*) OSGI_FRAMEWORK_OBJECTCLASS, PUBSUB_SUBSCRIBER_SERVICE_NAME,
+ PUBSUB_SUBSCRIBER_TOPIC,topic);
+
+ } else {
+ snprintf(filter, 128, "(&(%s=%s)(%s=%s)(%s=%s))",
+ (char*) OSGI_FRAMEWORK_OBJECTCLASS, PUBSUB_SUBSCRIBER_SERVICE_NAME,
+ PUBSUB_SUBSCRIBER_TOPIC,topic,
+ PUBSUB_SUBSCRIBER_SCOPE,scope);
+ }
+ service_tracker_customizer_pt customizer = NULL;
+ status += serviceTrackerCustomizer_create(ts,NULL,topicsub_subscriberTracked,NULL,topicsub_subscriberUntracked,&customizer);
+ status += serviceTracker_createWithFilter(bundle_context, filter, customizer, &ts->tracker);
+
+ struct sigaction actions;
+ memset(&actions, 0, sizeof(actions));
+ sigemptyset(&actions.sa_mask);
+ actions.sa_flags = 0;
+ actions.sa_handler = sigusr1_sighandler;
+
+ sigaction(SIGUSR1,&actions,NULL);
+
+ *out=ts;
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionDestroy(topic_subscription_pt ts){
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+
+ ts->running = false;
+ serviceTracker_destroy(ts->tracker);
+ arrayList_clear(ts->sub_ep_list);
+ arrayList_destroy(ts->sub_ep_list);
+ /* TODO: Destroy all the serializer maps? */
+ hashMap_destroy(ts->servicesMap,false,false);
+
+ celixThreadMutex_lock(&ts->pendingConnections_lock);
+ arrayList_destroy(ts->pendingConnections);
+ celixThreadMutex_unlock(&ts->pendingConnections_lock);
+ celixThreadMutex_destroy(&ts->pendingConnections_lock);
+
+ celixThreadMutex_lock(&ts->pendingDisconnections_lock);
+ arrayList_destroy(ts->pendingDisconnections);
+ celixThreadMutex_unlock(&ts->pendingDisconnections_lock);
+ celixThreadMutex_destroy(&ts->pendingDisconnections_lock);
+
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ celixThreadMutex_lock(&ts->socket_lock);
+ zsock_destroy(&(ts->zmq_socket));
+#ifdef BUILD_WITH_ZMQ_SECURITY
+ zcert_destroy(&(ts->zmq_cert));
+ zcert_destroy(&(ts->zmq_pub_cert));
+#endif
+ celixThreadMutex_unlock(&ts->socket_lock);
+ celixThreadMutex_destroy(&ts->socket_lock);
+
+ celixThreadMutex_destroy(&ts->ts_lock);
+
+ free(ts);
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionStart(topic_subscription_pt ts){
+ celix_status_t status = CELIX_SUCCESS;
+
+ status = serviceTracker_open(ts->tracker);
+
+ ts->running = true;
+
+ if(status==CELIX_SUCCESS){
+ status=celixThread_create(&ts->recv_thread,NULL,zmq_recv_thread_func,ts);
+ }
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionStop(topic_subscription_pt ts){
+ celix_status_t status = CELIX_SUCCESS;
+
+ ts->running = false;
+
+ pthread_kill(ts->recv_thread.thread,SIGUSR1);
+
+ celixThread_join(ts->recv_thread,NULL);
+
+ status = serviceTracker_close(ts->tracker);
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionConnectPublisher(topic_subscription_pt ts, char* pubURL){
+ celix_status_t status = CELIX_SUCCESS;
+ celixThreadMutex_lock(&ts->socket_lock);
+ if(!zsock_is(ts->zmq_socket) || zsock_connect(ts->zmq_socket,"%s",pubURL) != 0){
+ status = CELIX_SERVICE_EXCEPTION;
+ }
+ celixThreadMutex_unlock(&ts->socket_lock);
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionAddConnectPublisherToPendingList(topic_subscription_pt ts, char* pubURL) {
+ celix_status_t status = CELIX_SUCCESS;
+ char *url = strdup(pubURL);
+ celixThreadMutex_lock(&ts->pendingConnections_lock);
+ arrayList_add(ts->pendingConnections, url);
+ celixThreadMutex_unlock(&ts->pendingConnections_lock);
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionAddDisconnectPublisherToPendingList(topic_subscription_pt ts, char* pubURL) {
+ celix_status_t status = CELIX_SUCCESS;
+ char *url = strdup(pubURL);
+ celixThreadMutex_lock(&ts->pendingDisconnections_lock);
+ arrayList_add(ts->pendingDisconnections, url);
+ celixThreadMutex_unlock(&ts->pendingDisconnections_lock);
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionDisconnectPublisher(topic_subscription_pt ts, char* pubURL){
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->socket_lock);
+ if(!zsock_is(ts->zmq_socket) || zsock_disconnect(ts->zmq_socket,"%s",pubURL) != 0){
+ status = CELIX_SERVICE_EXCEPTION;
+ }
+ celixThreadMutex_unlock(&ts->socket_lock);
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionAddSubscriber(topic_subscription_pt ts, pubsub_endpoint_pt subEP){
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ arrayList_add(ts->sub_ep_list,subEP);
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+
+}
+
+celix_status_t pubsub_topicIncreaseNrSubscribers(topic_subscription_pt ts) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ ts->nrSubscribers++;
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+}
+
+celix_status_t pubsub_topicSubscriptionRemoveSubscriber(topic_subscription_pt ts, pubsub_endpoint_pt subEP){
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ arrayList_removeElement(ts->sub_ep_list,subEP);
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+}
+
+celix_status_t pubsub_topicDecreaseNrSubscribers(topic_subscription_pt ts) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ ts->nrSubscribers--;
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+}
+
+unsigned int pubsub_topicGetNrSubscribers(topic_subscription_pt ts) {
+ return ts->nrSubscribers;
+}
+
+array_list_pt pubsub_topicSubscriptionGetSubscribersList(topic_subscription_pt sub){
+ return sub->sub_ep_list;
+}
+
+static celix_status_t topicsub_subscriberTracked(void * handle, service_reference_pt reference, void * service){
+ celix_status_t status = CELIX_SUCCESS;
+ topic_subscription_pt ts = handle;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ if (!hashMap_containsKey(ts->servicesMap, service)) {
+ bundle_pt bundle = NULL;
+ hash_map_pt msgTypes = NULL;
+
+ serviceReference_getBundle(reference, &bundle);
+
+ if(ts->serializer != NULL && bundle!=NULL){
+ ts->serializer->createSerializerMap(ts->serializer->handle,bundle,&msgTypes);
+ if(msgTypes != NULL){
+ hashMap_put(ts->servicesMap, service, msgTypes);
+ printf("PSA_ZMQ_TS: New subscriber registered.\n");
+ }
+ }
+ else{
+ printf("PSA_ZMQ_TS: Cannot register new subscriber.\n");
+ status = CELIX_SERVICE_EXCEPTION;
+ }
+ }
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+}
+
+static celix_status_t topicsub_subscriberUntracked(void * handle, service_reference_pt reference, void * service){
+ celix_status_t status = CELIX_SUCCESS;
+ topic_subscription_pt ts = handle;
+
+ celixThreadMutex_lock(&ts->ts_lock);
+ if (hashMap_containsKey(ts->servicesMap, service)) {
+ hash_map_pt msgTypes = hashMap_remove(ts->servicesMap, service);
+ if(msgTypes!=NULL && ts->serializer!=NULL){
+ ts->serializer->destroySerializerMap(ts->serializer->handle,msgTypes);
+ printf("PSA_ZMQ_TS: Subscriber unregistered.\n");
+ }
+ else{
+ printf("PSA_ZMQ_TS: Cannot unregister subscriber.\n");
+ status = CELIX_SERVICE_EXCEPTION;
+ }
+ }
+ celixThreadMutex_unlock(&ts->ts_lock);
+
+ return status;
+}
+
+
+static void process_msg(topic_subscription_pt sub,array_list_pt msg_list){
+
+ pubsub_msg_header_pt first_msg_hdr = (pubsub_msg_header_pt)zframe_data(((complete_zmq_msg_pt)arrayList_get(msg_list,0))->header);
+
+ hash_map_iterator_pt iter = hashMapIterator_create(sub->servicesMap);
+ while (hashMapIterator_hasNext(iter)) {
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ pubsub_subscriber_pt subsvc = hashMapEntry_getKey(entry);
+ hash_map_pt msgTypes = hashMapEntry_getValue(entry);
+
+ pubsub_msg_serializer_t *msgSer = hashMap_get(msgTypes,(void*)(uintptr_t )first_msg_hdr->type);
+ if (msgSer == NULL) {
+ printf("PSA_ZMQ_TS: Primary message %d not supported. NOT sending any part of the whole message.\n",first_msg_hdr->type);
+ }
+ else{
+ void *msgInst = NULL;
+ bool validVersion = checkVersion(msgSer->msgVersion,first_msg_hdr);
+
+ if(validVersion){
+
+ celix_status_t status = msgSer->deserialize(msgSer, (const void *) zframe_data(((complete_zmq_msg_pt)arrayList_get(msg_list,0))->payload), 0, &msgInst);
+
+ if (status == CELIX_SUCCESS) {
+ bool release = true;
+ mp_handle_pt mp_handle = create_mp_handle(msgTypes,msg_list);
+ pubsub_multipart_callbacks_t mp_callbacks;
+ mp_callbacks.handle = mp_handle;
+ mp_callbacks.localMsgTypeIdForMsgType = pubsub_localMsgTypeIdForMsgType;
+ mp_callbacks.getMultipart = pubsub_getMultipart;
+ subsvc->receive(subsvc->handle, msgSer->msgName, first_msg_hdr->type, msgInst, &mp_callbacks, &release);
+
+ if(release){
+ msgSer->freeMsg(msgSer,msgInst); // pubsubSerializer_freeMsg(msgType, msgInst);
+ }
+ if(mp_handle!=NULL){
+ destroy_mp_handle(mp_handle);
+ }
+ }
+ else{
+ printf("PSA_ZMQ_TS: Cannot deserialize msgType %s.\n",msgSer->msgName);
+ }
+
+ }
+ else{
+ int major=0,minor=0;
+ version_getMajor(msgSer->msgVersion,&major);
+ version_getMinor(msgSer->msgVersion,&minor);
+ printf("PSA_ZMQ_TS: Version mismatch for primary message '%s' (have %d.%d, received %u.%u). NOT sending any part of the whole message.\n",
+ msgSer->msgName,major,minor,first_msg_hdr->major,first_msg_hdr->minor);
+ }
+
+ }
+ }
+ hashMapIterator_destroy(iter);
+
+ int i = 0;
+ for(;i<arrayList_size(msg_list);i++){
+ complete_zmq_msg_pt c_msg = arrayList_get(msg_list,i);
+ zframe_destroy(&(c_msg->header));
+ zframe_destroy(&(c_msg->payload));
+ free(c_msg);
+ }
+
+ arrayList_destroy(msg_list);
+
+}
+
+static void* zmq_recv_thread_func(void * arg) {
+ topic_subscription_pt sub = (topic_subscription_pt) arg;
+
+ while (sub->running) {
+
+ celixThreadMutex_lock(&sub->socket_lock);
+
+ zframe_t* headerMsg = zframe_recv(sub->zmq_socket);
+ if (headerMsg == NULL) {
+ if (errno == EINTR) {
+ //It means we got a signal and we have to exit...
+ printf("PSA_ZMQ_TS: header_recv thread for topic got a signal and will exit.\n");
+ } else {
+ perror("PSA_ZMQ_TS: header_recv thread");
+ }
+ }
+ else {
+
+ pubsub_msg_header_pt hdr = (pubsub_msg_header_pt) zframe_data(headerMsg);
+
+ if (zframe_more(headerMsg)) {
+
+ zframe_t* payloadMsg = zframe_recv(sub->zmq_socket);
+ if (payloadMsg == NULL) {
+ if (errno == EINTR) {
+ //It means we got a signal and we have to exit...
+ printf("PSA_ZMQ_TS: payload_recv thread for topic got a signal and will exit.\n");
+ } else {
+ perror("PSA_ZMQ_TS: payload_recv");
+ }
+ zframe_destroy(&headerMsg);
+ } else {
+
+ //Let's fetch all the messages from the socket
+ array_list_pt msg_list = NULL;
+ arrayList_create(&msg_list);
+ complete_zmq_msg_pt firstMsg = calloc(1, sizeof(struct complete_zmq_msg));
+ firstMsg->header = headerMsg;
+ firstMsg->payload = payloadMsg;
+ arrayList_add(msg_list, firstMsg);
+
+ bool more = zframe_more(payloadMsg);
+ while (more) {
+
+ zframe_t* h_msg = zframe_recv(sub->zmq_socket);
+ if (h_msg == NULL) {
+ if (errno == EINTR) {
+ //It means we got a signal and we have to exit...
+ printf("PSA_ZMQ_TS: h_recv thread for topic got a signal and will exit.\n");
+ } else {
+ perror("PSA_ZMQ_TS: h_recv");
+ }
+ break;
+ }
+
+ zframe_t* p_msg = zframe_recv(sub->zmq_socket);
+ if (p_msg == NULL) {
+ if (errno == EINTR) {
+ //It means we got a signal and we have to exit...
+ printf("PSA_ZMQ_TS: p_recv thread for topic got a signal and will exit.\n");
+ } else {
+ perror("PSA_ZMQ_TS: p_recv");
+ }
+ zframe_destroy(&h_msg);
+ break;
+ }
+
+ complete_zmq_msg_pt c_msg = calloc(1, sizeof(struct complete_zmq_msg));
+ c_msg->header = h_msg;
+ c_msg->payload = p_msg;
+ arrayList_add(msg_list, c_msg);
+
+ if (!zframe_more(p_msg)) {
+ more = false;
+ }
+ }
+
+ celixThreadMutex_lock(&sub->ts_lock);
+ process_msg(sub, msg_list);
+ celixThreadMutex_unlock(&sub->ts_lock);
+
+ }
+
+ } //zframe_more(headerMsg)
+ else {
+ free(headerMsg);
+ printf("PSA_ZMQ_TS: received message %u for topic %s without payload!\n", hdr->type, hdr->topic);
+ }
+
+ } // headerMsg != NULL
+ celixThreadMutex_unlock(&sub->socket_lock);
+ connectPendingPublishers(sub);
+ disconnectPendingPublishers(sub);
+ } // while
+
+ return NULL;
+}
+
+static void connectPendingPublishers(topic_subscription_pt sub) {
+ celixThreadMutex_lock(&sub->pendingConnections_lock);
+ while(!arrayList_isEmpty(sub->pendingConnections)) {
+ char * pubEP = arrayList_remove(sub->pendingConnections, 0);
+ pubsub_topicSubscriptionConnectPublisher(sub, pubEP);
+ free(pubEP);
+ }
+ celixThreadMutex_unlock(&sub->pendingConnections_lock);
+}
+
+static void disconnectPendingPublishers(topic_subscription_pt sub) {
+ celixThreadMutex_lock(&sub->pendingDisconnections_lock);
+ while(!arrayList_isEmpty(sub->pendingDisconnections)) {
+ char * pubEP = arrayList_remove(sub->pendingDisconnections, 0);
+ pubsub_topicSubscriptionDisconnectPublisher(sub, pubEP);
+ free(pubEP);
+ }
+ celixThreadMutex_unlock(&sub->pendingDisconnections_lock);
+}
+
+static void sigusr1_sighandler(int signo){
+ printf("PSA_ZMQ_TS: Topic subscription being shut down...\n");
+ return;
+}
+
+static bool checkVersion(version_pt msgVersion,pubsub_msg_header_pt hdr){
+ bool check=false;
+ int major=0,minor=0;
+
+ if(msgVersion!=NULL){
+ version_getMajor(msgVersion,&major);
+ version_getMinor(msgVersion,&minor);
+ if(hdr->major==((unsigned char)major)){ /* Different major means incompatible */
+ check = (hdr->minor>=((unsigned char)minor)); /* Compatible only if the provider has a minor equals or greater (means compatible update) */
+ }
+ }
+
+ return check;
+}
+
+static int pubsub_localMsgTypeIdForMsgType(void* handle, const char* msgType, unsigned int* msgTypeId){
+ *msgTypeId = utils_stringHash(msgType);
+ return 0;
+}
+
+static int pubsub_getMultipart(void *handle, unsigned int msgTypeId, bool retain, void **part){
+
+ if(handle==NULL){
+ *part = NULL;
+ return -1;
+ }
+
+ mp_handle_pt mp_handle = (mp_handle_pt)handle;
+ msg_map_entry_pt entry = hashMap_get(mp_handle->rcv_msg_map, (void*)(uintptr_t) msgTypeId);
+ if(entry!=NULL){
+ entry->retain = retain;
+ *part = entry->msgInst;
+ }
+ else{
+ printf("TP: getMultipart cannot find msg '%u'\n",msgTypeId);
+ *part=NULL;
+ return -2;
+ }
+
+ return 0;
+
+}
+
+static mp_handle_pt create_mp_handle(hash_map_pt svc_msg_db,array_list_pt rcv_msg_list){
+
+ if(arrayList_size(rcv_msg_list)==1){ //Means it's not a multipart message
+ return NULL;
+ }
+
+ mp_handle_pt mp_handle = calloc(1,sizeof(struct mp_handle));
+ mp_handle->svc_msg_db = svc_msg_db;
+ mp_handle->rcv_msg_map = hashMap_create(NULL, NULL, NULL, NULL);
+
+ int i=1; //We skip the first message, it will be handle differently
+ for(;i<arrayList_size(rcv_msg_list);i++){
+ complete_zmq_msg_pt c_msg = (complete_zmq_msg_pt)arrayList_get(rcv_msg_list,i);
+ pubsub_msg_header_pt header = (pubsub_msg_header_pt)zframe_data(c_msg->header);
+
+ pubsub_msg_serializer_t* msgSer = hashMap_get(svc_msg_db, (void*)(uintptr_t)(header->type));
+
+ if (msgSer!= NULL) {
+ void *msgInst = NULL;
+
+ bool validVersion = checkVersion(msgSer->msgVersion,header);
+
+ if(validVersion){
+ celix_status_t status = msgSer->deserialize(msgSer, (const void*)zframe_data(c_msg->payload), 0, &msgInst);
+
+ if(status == CELIX_SUCCESS){
+ msg_map_entry_pt entry = calloc(1,sizeof(struct msg_map_entry));
+ entry->msgInst = msgInst;
+ hashMap_put(mp_handle->rcv_msg_map, (void*)(uintptr_t)header->type,entry);
+ }
+ }
+ }
+ }
+
+ return mp_handle;
+
+}
+
+static void destroy_mp_handle(mp_handle_pt mp_handle){
+
+ hash_map_iterator_pt iter = hashMapIterator_create(mp_handle->rcv_msg_map);
+ while(hashMapIterator_hasNext(iter)){
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ unsigned int msgId = (unsigned int)(uintptr_t)hashMapEntry_getKey(entry);
+ msg_map_entry_pt msgEntry = hashMapEntry_getValue(entry);
+ pubsub_msg_serializer_t* msgSer = hashMap_get(mp_handle->svc_msg_db, (void*)(uintptr_t)msgId);
+
+ if(msgSer!=NULL){
+ if(!msgEntry->retain){
+ msgSer->freeMsg(msgSer->handle,msgEntry->msgInst);
+ }
+ }
+ else{
+ printf("PSA_ZMQ_TS: ERROR: Cannot find messageSerializer for msg %u, so cannot destroy it!\n",msgId);
+ }
+
+ free(msgEntry);
+ }
+ hashMapIterator_destroy(iter);
+
+ hashMap_destroy(mp_handle->rcv_msg_map,false,false);
+ free(mp_handle);
+}
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/pubsub_discovery/CMakeLists.txt
----------------------------------------------------------------------
diff --cc pubsub/pubsub_discovery/CMakeLists.txt
index f92f81c,42017e7..d034a70
--- a/pubsub/pubsub_discovery/CMakeLists.txt
+++ b/pubsub/pubsub_discovery/CMakeLists.txt
@@@ -18,24 -18,26 +18,24 @@@
find_package(CURL REQUIRED)
find_package(Jansson REQUIRED)
- add_bundle(celix_pubsub_discovery_etcd
-include_directories("${CURL_INCLUDE_DIR}")
-include_directories("${JANSSON_INCLUDE_DIR}")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/api/pubsub")
-include_directories("${PROJECT_SOURCE_DIR}/etcdlib/public/include")
-include_directories("private/include")
-include_directories("public/include")
-
-add_celix_bundle(org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery
++add_celix_bundle(celix_pubsub_discovery_etcd
BUNDLE_SYMBOLICNAME "apache_celix_pubsub_discovery_etcd"
VERSION "1.0.0"
SOURCES
- private/src/psd_activator.c
- private/src/pubsub_discovery_impl.c
- private/src/etcd_common.c
- private/src/etcd_watcher.c
- private/src/etcd_writer.c
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/src/pubsub_endpoint.c
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/src/pubsub_utils.c
+ src/psd_activator.c
+ src/pubsub_discovery_impl.c
+ src/etcd_common.c
+ src/etcd_watcher.c
+ src/etcd_writer.c
+)
+
+target_include_directories(celix_pubsub_discovery_etcd PRIVATE
+ src
+ ${CURL_INCLUDE_DIR}
+ ${JANSSON_INCLUDE_DIR}
)
-target_link_libraries(org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery celix_framework celix_utils etcdlib_static ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
-install_celix_bundle(org.apache.celix.pubsub_discovery.etcd.PubsubDiscovery)
+target_link_libraries(celix_pubsub_discovery_etcd PRIVATE Celix::pubsub_spi Celix::framework Celix::etcdlib_static ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
- install_bundle(celix_pubsub_discovery_etcd)
++install_celix_bundle(celix_pubsub_discovery_etcd)
+
+add_library(Celix::pubsub_discovery_etcd ALIAS celix_pubsub_discovery_etcd)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/pubsub_serializer_json/CMakeLists.txt
----------------------------------------------------------------------
diff --cc pubsub/pubsub_serializer_json/CMakeLists.txt
index 1269cad,2aaa98a..9a486f2
--- a/pubsub/pubsub_serializer_json/CMakeLists.txt
+++ b/pubsub/pubsub_serializer_json/CMakeLists.txt
@@@ -17,24 -17,27 +17,24 @@@
find_package(Jansson REQUIRED)
-include_directories("private/include")
-include_directories("public/include")
-include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/dfi/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/api/pubsub")
-include_directories("${JANSSON_INCLUDE_DIR}")
-
-add_celix_bundle(org.apache.celix.pubsub_serializer.PubSubSerializerJson
+
- add_bundle(celix_pubsub_serializer_json
++add_celix_bundle(celix_pubsub_serializer_json
BUNDLE_SYMBOLICNAME "apache_celix_pubsub_serializer_json"
VERSION "1.0.0"
SOURCES
- private/src/ps_activator.c
- private/src/pubsub_serializer_impl.c
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/src/pubsub_utils.c
+ src/ps_activator.c
+ src/pubsub_serializer_impl.c
+)
+
+target_include_directories(celix_pubsub_serializer_json PRIVATE
+ src
+ ${JANSSON_INCLUDE_DIR}
)
-set_target_properties(org.apache.celix.pubsub_serializer.PubSubSerializerJson PROPERTIES INSTALL_RPATH "$ORIGIN")
-target_link_libraries(org.apache.celix.pubsub_serializer.PubSubSerializerJson celix_framework celix_utils celix_dfi ${JANSSON_LIBRARIES})
+set_target_properties(celix_pubsub_serializer_json PROPERTIES INSTALL_RPATH "$ORIGIN")
+target_link_libraries(celix_pubsub_serializer_json PRIVATE Celix::pubsub_spi Celix::framework Celix::dfi ${JANSSON_LIBRARIES} Celix::log_helper)
+
- install_bundle(celix_pubsub_serializer_json)
++install_celix_bundle(celix_pubsub_serializer_json)
-install_celix_bundle(org.apache.celix.pubsub_serializer.PubSubSerializerJson)
+add_library(Celix::pubsub_serializer_json ALIAS celix_pubsub_serializer_json)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/pubsub_spi/CMakeLists.txt
----------------------------------------------------------------------
diff --cc pubsub/pubsub_spi/CMakeLists.txt
index 118dd3a,0000000..ee9d4b6
mode 100644,000000..100644
--- a/pubsub/pubsub_spi/CMakeLists.txt
+++ b/pubsub/pubsub_spi/CMakeLists.txt
@@@ -1,35 -1,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.
+
- add_library(celix_pubsub_spi STATIC
++add_library(pubsub_spi STATIC
+ src/pubsub_admin_match.c
+ src/pubsub_endpoint.c
+ src/pubsub_utils.c
+)
- target_include_directories(celix_pubsub_spi PUBLIC
++set_target_properties(pubsub_spi PROPERTIES OUTPUT_NAME "celix_pubsub_spi")
++target_include_directories(pubsub_spi PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
+ $<INSTALL_INTERFACE:include/celix/pubsub_spi>
+)
- target_link_libraries(celix_pubsub_spi PUBLIC Celix::framework Celix::pubsub_api)
++target_link_libraries(pubsub_spi PUBLIC Celix::framework Celix::pubsub_api)
+
- set_target_properties(celix_pubsub_spi PROPERTIES TOPIC_INFO_DESCRIPTOR ${CMAKE_CURRENT_LIST_DIR}/include/pubsub_topic_info.descriptor)
++set_target_properties(pubsub_spi PROPERTIES TOPIC_INFO_DESCRIPTOR ${CMAKE_CURRENT_LIST_DIR}/include/pubsub_topic_info.descriptor)
+#TODO how to make this descriptor available for imported targets? $<INSTALL_INTERFACE:include/celix/pubsub_spi/pubsub_topic_info.descriptor>
+
- add_library(Celix::pubsub_spi ALIAS celix_pubsub_spi)
++add_library(Celix::pubsub_spi ALIAS pubsub_spi)
+
- install(TARGETS celix_pubsub_spi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT pubsub)
++install(TARGETS pubsub_spi EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT pubsub)
+install(DIRECTORY include/ DESTINATION include/celix/pubsub_spi COMPONENT pubsub)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/pubsub_topology_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --cc pubsub/pubsub_topology_manager/CMakeLists.txt
index 73b9ecb,a064143..181b30d
--- a/pubsub/pubsub_topology_manager/CMakeLists.txt
+++ b/pubsub/pubsub_topology_manager/CMakeLists.txt
@@@ -15,23 -15,30 +15,23 @@@
# specific language governing permissions and limitations
# under the License.
- add_bundle(celix_pubsub_topology_manager
-include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/pubsub_admin/public/include")
-include_directories("${PROJECT_SOURCE_DIR}/pubsub/api/pubsub")
-include_directories("private/include")
-include_directories("public/include")
-
-add_celix_bundle(org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
++add_celix_bundle(celix_pubsub_topology_manager
BUNDLE_SYMBOLICNAME "apache_celix_pubsub_topology_manager"
VERSION "1.0.0"
SOURCES
- private/src/pstm_activator.c
- private/src/pubsub_topology_manager.c
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/src/pubsub_endpoint.c
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/src/pubsub_utils.c
+ src/pstm_activator.c
+ src/pubsub_topology_manager.c
+ src/pubsub_topology_manager.h
)
+target_link_libraries(celix_pubsub_topology_manager PRIVATE Celix::framework Celix::log_helper Celix::pubsub_spi)
-celix_bundle_files(org.apache.celix.pubsub_topology_manager.PubSubTopologyManager
- ${PROJECT_SOURCE_DIR}/pubsub/pubsub_common/public/include/pubsub_topic_info.descriptor
+get_target_property(DESC Celix::pubsub_spi TOPIC_INFO_DESCRIPTOR)
- bundle_files(celix_pubsub_topology_manager
++celix_bundle_files(celix_pubsub_topology_manager
+ ${DESC}
DESTINATION "META-INF/descriptors/services"
)
- install_bundle(celix_pubsub_topology_manager)
-target_link_libraries(org.apache.celix.pubsub_topology_manager.PubSubTopologyManager celix_framework celix_utils)
-install_celix_bundle(org.apache.celix.pubsub_topology_manager.PubSubTopologyManager)
++install_celix_bundle(celix_pubsub_topology_manager)
+
+add_library(Celix::pubsub_topology_manager ALIAS celix_pubsub_topology_manager)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/pubsub/test/CMakeLists.txt
----------------------------------------------------------------------
diff --cc pubsub/test/CMakeLists.txt
index 9fd324e,41fffe0..13e7d82
--- a/pubsub/test/CMakeLists.txt
+++ b/pubsub/test/CMakeLists.txt
@@@ -20,22 -20,24 +20,22 @@@ find_program(ETCD_CMD NAMES etcd
find_package(CppUTest REQUIRED)
include_directories(${CPPUTEST_INCLUDE_DIR})
- add_bundle(pubsub_sut
-include_directories(
- ${CMAKE_SOURCE_DIR}/pubsub/api
- test
-)
-
+ add_celix_bundle(pubsub_sut
#"Vanilla" bundle which is under test
SOURCES
test/sut_activator.c
VERSION 1.0.0
)
-target_link_libraries(pubsub_sut celix_framework celix_utils)
+target_include_directories(pubsub_sut PRIVATE test)
+target_link_libraries(pubsub_sut PRIVATE Celix::pubsub_spi)
+
- bundle_files(pubsub_sut
+ celix_bundle_files(pubsub_sut
msg_descriptors/msg.descriptor
msg_descriptors/sync.descriptor
DESTINATION "META-INF/descriptors/messages"
)
+
- add_deploy(pubsub_udpmc_sut
+ add_celix_container(pubsub_udpmc_sut
NAME deploy_sut
BUNDLES
org.apache.celix.pubsub_serializer.PubSubSerializerJson
@@@ -64,12 -66,12 +64,12 @@@ add_celix_bundle(pubsub_ts
)
if (APPLE)
#Note that the launcher celix_test_runner is linked with CppuTest, not the bundle libs. Default libCppUTest.a is not compiled for relocation
- target_link_libraries(pubsub_tst celix_framework celix_utils -Wl,-undefined -Wl,dynamic_lookup)
+ target_link_libraries(pubsub_tst PRIVATE Celix::framework -Wl,-undefined -Wl,dynamic_lookup)
else ()
- target_link_libraries(pubsub_tst celix_framework celix_utils)
+ target_link_libraries(pubsub_tst PRIVATE Celix::framework)
endif ()
- bundle_files(pubsub_tst
+ celix_bundle_files(pubsub_tst
msg_descriptors/msg.descriptor
msg_descriptors/sync.descriptor
DESTINATION "META-INF/descriptors/messages"
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/civetweb/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/civetweb/CMakeLists.txt
index a6f7d10,0000000..46b9637
mode 100644,000000..100644
--- a/remote_services/civetweb/CMakeLists.txt
+++ b/remote_services/civetweb/CMakeLists.txt
@@@ -1,26 -1,0 +1,26 @@@
+# 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.
+
+
+add_library(civetweb OBJECT
+ src/civetweb.c
+ src/md5.inl
+)
+target_include_directories(civetweb PUBLIC include)
+
+#Setup target aliases to match external usage
- add_library(Celix::civetweb ALIAS civetweb)
++add_library(Celix::civetweb ALIAS civetweb)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/discovery_common/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/discovery_common/CMakeLists.txt
index 114f485,0000000..97e9676
mode 100644,000000..100644
--- a/remote_services/discovery_common/CMakeLists.txt
+++ b/remote_services/discovery_common/CMakeLists.txt
@@@ -1,39 -1,0 +1,39 @@@
+# 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(LibXml2 REQUIRED)
+
+add_library(rsa_discovery_common OBJECT
+ src/discovery.c
+ src/discovery_activator.c
+ src/endpoint_descriptor_reader.c
+ src/endpoint_descriptor_writer.c
+ src/endpoint_discovery_poller.c
+ src/endpoint_discovery_server.c
+)
+target_include_directories(rsa_discovery_common PUBLIC
+ include src
+ $<TARGET_PROPERTY:Celix::framework,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::utils,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::log_helper,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::rsa_spi,INTERFACE_INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:civetweb,INCLUDE_DIRECTORIES>
+ ${LIBXML2_INCLUDE_DIR})
+
+#Setup target aliases to match external usage
- add_library(Celix::rsa_discovery_common ALIAS rsa_discovery_common)
++add_library(Celix::rsa_discovery_common ALIAS rsa_discovery_common)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/discovery_configured/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/discovery_configured/CMakeLists.txt
index 83b18c7,c3180ad..fe658ca
--- a/remote_services/discovery_configured/CMakeLists.txt
+++ b/remote_services/discovery_configured/CMakeLists.txt
@@@ -19,24 -19,54 +19,24 @@@ if (RSA_DISCOVERY_CONFIGURED
find_package(CURL REQUIRED)
find_package(LibXml2 REQUIRED)
- add_bundle(rsa_discovery_configured
- include_directories("${CURL_INCLUDE_DIR}")
- include_directories("${LIBXML2_INCLUDE_DIR}")
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery_configured/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- include_directories(private/include)
-
- add_celix_bundle(discovery_configured
- VERSION 0.9.0
- SYMBOLIC_NAME "apache_celix_rsa_discovery_configured"
- NAME "Apache Celix RSA Configured Discovery"
- SOURCES
-
- private/src/discovery_impl.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery_activator.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_reader.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_writer.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_poller.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
- ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
- ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
-
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
++ add_celix_bundle(rsa_discovery_configured
+ VERSION 0.9.0
+ SYMBOLIC_NAME "apache_celix_rsa_discovery_configured"
+ NAME "Apache Celix RSA Configured Discovery"
+ SOURCES
+ src/discovery_impl.c
+ $<TARGET_OBJECTS:Celix::rsa_discovery_common>
+ $<TARGET_OBJECTS:Celix::civetweb>
)
+ target_include_directories(rsa_discovery_configured PRIVATE
+ src
+ $<TARGET_PROPERTY:Celix::rsa_discovery_common,INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::civetweb,INCLUDE_DIRECTORIES>
+ )
+ target_link_libraries(rsa_discovery_configured PRIVATE ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} Celix::log_helper Celix::rsa_common)
- install_bundle(rsa_discovery_configured)
- install_celix_bundle(discovery_configured)
-
- target_link_libraries(discovery_configured celix_framework ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES})
-
- if (RSA_ENDPOINT_TEST_READER)
- add_executable(descparser
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_reader.c
- ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c)
-
- target_link_libraries(descparser ${LIBXML2_LIBRARIES} celix_framework celix_utils)
- endif (RSA_ENDPOINT_TEST_READER)
-
- if (RSA_ENDPOINT_TEST_WRITER)
- add_executable(descwriter
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_writer.c
- ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c)
++ install_celix_bundle(rsa_discovery_configured)
- target_link_libraries(descwriter ${LIBXML2_LIBRARIES} celix_framework celix_utils)
- endif(RSA_ENDPOINT_TEST_WRITER)
+ #Setup target aliases to match external usage
+ add_library(Celix::rsa_discovery_configured ALIAS rsa_discovery_configured)
endif (RSA_DISCOVERY_CONFIGURED)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/discovery_etcd/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/discovery_etcd/CMakeLists.txt
index fe88532,ce25d22..776ad93
--- a/remote_services/discovery_etcd/CMakeLists.txt
+++ b/remote_services/discovery_etcd/CMakeLists.txt
@@@ -20,30 -20,42 +20,30 @@@ if (RSA_DISCOVERY_ETCD
find_package(CURL REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Jansson REQUIRED)
-
- include_directories("${CURL_INCLUDE_DIR}")
- include_directories("${JANSSON_INCLUDE_DIR}")
- include_directories("${LIBXML2_INCLUDE_DIR}")
- include_directories("${PROJECT_SOURCE_DIR}/etcdlib/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery_etcd/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- include_directories("private/include")
- add_bundle(rsa_discovery_etcd
- add_celix_bundle(discovery_etcd
++ add_celix_bundle(rsa_discovery_etcd
VERSION 0.9.0
SYMBOLIC_NAME "apache_celix_rsa_discovery_etcd"
NAME "Apache Celix RSA Discovery ETCD"
SOURCES
- private/src/discovery_impl.c
- private/src/etcd_watcher.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery_activator.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_reader.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_writer.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_poller.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
- ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
- ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
-
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+ src/discovery_impl.c
+ src/etcd_watcher.c
+ $<TARGET_OBJECTS:Celix::rsa_discovery_common>
+ $<TARGET_OBJECTS:Celix::civetweb>
)
+ target_link_libraries(rsa_discovery_etcd PRIVATE Celix::log_helper Celix::etcdlib_static Celix::rsa_common)
+ target_include_directories(rsa_discovery_etcd PRIVATE src)
+ target_include_directories(rsa_discovery_etcd PRIVATE
+ $<TARGET_PROPERTY:Celix::rsa_discovery_common,INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::civetweb,INCLUDE_DIRECTORIES>
+ ${CURL_INCLUDE_DIR}
+ ${JANSSON_INCLUDE_DIR}
+ ${LIBXML2_INCLUDE_DIR}
+ )
+ target_link_libraries(rsa_discovery_etcd PRIVATE ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} ${JANSSON_LIBRARIES})
- install_bundle(rsa_discovery_etcd)
- install_celix_bundle(discovery_etcd)
-
- target_link_libraries(discovery_etcd celix_framework etcdlib ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES} ${JANSSON_LIBRARIES})
++ install_celix_bundle(rsa_discovery_etcd)
+ #Setup target aliases to match external usage
+ add_library(Celix::rsa_discovery_etcd ALIAS rsa_discovery_etcd)
endif (RSA_DISCOVERY_ETCD)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/discovery_shm/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/discovery_shm/CMakeLists.txt
index fd822e6,3eec195..5557ae9
--- a/remote_services/discovery_shm/CMakeLists.txt
+++ b/remote_services/discovery_shm/CMakeLists.txt
@@@ -19,30 -19,40 +19,30 @@@ celix_subproject(RSA_DISCOVERY_SHM "Opt
if (RSA_DISCOVERY_SHM)
find_package(CURL REQUIRED)
find_package(LibXml2 REQUIRED)
-
- include_directories("${CURL_INCLUDE_DIR}")
- include_directories("${LIBXML2_INCLUDE_DIR}")
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/discovery_shm/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- include_directories("private/include")
- add_bundle(rsa_discovery_shm
- add_celix_bundle(discovery_shm
++ add_celix_bundle(rsa_discovery_shm
VERSION 0.0.1
SYMBOLIC_NAME "apache_celix_rsa_discovery_shm"
NAME "Apache Celix RSA Discovery SHM"
SOURCES
- private/src/discovery_shm
- private/src/discovery_shmWatcher
- private/src/discovery_impl
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery_activator.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/discovery.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_reader.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_descriptor_writer.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_poller.c
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/src/endpoint_discovery_server.c
- ${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/private/src/endpoint_description.c
- ${PROJECT_SOURCE_DIR}/remote_services/utils/private/src/civetweb.c
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
+ src/discovery_shm.c
+ src/discovery_shmWatcher.c
+ src/discovery_impl.c
+ $<TARGET_OBJECTS:Celix::rsa_discovery_common>
+ $<TARGET_OBJECTS:Celix::civetweb>
)
+ target_include_directories(rsa_discovery_shm PRIVATE
+ src
+ ${LIBXML2_INCLUDE_DIR}
+ ${CURL_INCLUDE_DIR}
+ $<TARGET_PROPERTY:Celix::rsa_discovery_common,INCLUDE_DIRECTORIES>
+ $<TARGET_PROPERTY:Celix::civetweb,INCLUDE_DIRECTORIES>
+ )
+ target_link_libraries(rsa_discovery_shm PRIVATE Celix::framework ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES})
+
- install_bundle(rsa_discovery_shm)
++ install_celix_bundle(rsa_discovery_shm)
- install_celix_bundle(discovery_shm)
-
- target_link_libraries(discovery_shm celix_framework ${CURL_LIBRARIES} ${LIBXML2_LIBRARIES})
+ #Setup target aliases to match external usage
+ add_library(Celix::rsa_discovery_shm ALIAS rsa_discovery_shm)
endif (RSA_DISCOVERY_SHM)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/examples/CMakeLists.txt
index 78bfbac,8916a18..0f8e7a9
--- a/remote_services/examples/CMakeLists.txt
+++ b/remote_services/examples/CMakeLists.txt
@@@ -17,44 -17,98 +17,44 @@@
celix_subproject(RSA_EXAMPLES "Option to enable building the RSA examples" ON DEPS LAUNCHER shell_tui log_writer RSA_TOPOLOGY_MANAGER)
if (RSA_EXAMPLES)
+ add_subdirectory(calculator_api)
add_subdirectory(calculator_service)
-
- add_subdirectory(calculator_endpoint)
- add_subdirectory(calculator_endpoint2)
-
- add_subdirectory(calculator_proxy)
- add_subdirectory(calculator_proxy2)
-
add_subdirectory(calculator_shell)
- if(BUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP AND BUILD_RSA_DISCOVERY_CONFIGURED)
- add_celix_container(remote-services-cfg-server
- NAME "server"
- GROUP "remote-services/remote-services-cfg"
- BUNDLES discovery_configured topology_manager remote_service_admin_http calculator shell shell_tui log_service log_writer
- PROPERTIES
- RSA_PORT=8001
- DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:8082/org.apache.celix.discovery.configured
- DISCOVERY_CFG_SERVER_PORT=8081
- )
- celix_container_bundles_dir(remote-services-cfg-server DIR_NAME "endpoints" BUNDLES
- org.apache.celix.calc.api.Calculator_endpoint
- org.apache.celix.calc.api.Calculator2_endpoint
- )
-
- add_celix_container(remote-services-cfg-client
- NAME "client"
- GROUP "remote-services/remote-services-cfg"
- BUNDLES topology_manager remote_service_admin_http shell shell_tui log_service log_writer calculator_shell discovery_configured
- PROPERTIES
- RSA_PORT=8002
- DISCOVERY_CFG_POLL_ENDPOINTS=http://localhost:8081/org.apache.celix.discovery.configured
- DISCOVERY_CFG_SERVER_PORT=8082
- )
- celix_container_bundles_dir(remote-services-cfg-client DIR_NAME "endpoints"
- BUNDLES org.apache.celix.calc.api.Calculator_proxy org.apache.celix.calc.api.Calculator2_proxy
- )
- endif()
-
- if (BUILD_RSA_REMOTE_SERVICE_ADMIN_SHM AND BUILD_RSA_DISCOVERY_SHM)
- add_celix_container(remote-services-shm
- NAME "server"
- GROUP "remote-services/remote-services-shm"
- BUNDLES discovery_shm topology_manager remote_service_admin_shm calculator shell shell_tui log_service log_writer
- )
- celix_container_bundles_dir(remote-services-shm DIR_NAME "endpoints"
- BUNDLES org.apache.celix.calc.api.Calculator_endpoint
- )
-
- add_celix_container(remote-services-shm-client
- NAME "client"
- GROUP "remote-services/remote-services-shm"
- BUNDLES topology_manager remote_service_admin_shm shell shell_tui log_service log_writer calculator_shell discovery_shm
- )
- celix_container_bundles_dir(remote-services-shm-client DIR_NAME "endpoints"
- BUNDLES org.apache.celix.calc.api.Calculator_proxy
- )
- endif ()
- if (BUILD_RSA_DISCOVERY_ETCD AND BUILD_RSA_REMOTE_SERVICE_ADMIN_HTTP)
- add_celix_container(remote-services-etcd
- NAME "server"
- GROUP "remote-services/remote-services-etcd"
- BUNDLES discovery_etcd topology_manager remote_service_admin_http calculator shell shell_tui log_service log_writer
- )
- celix_container_bundles_dir(remote-services-etcd DIR_NAME "endpoints"
- BUNDLES
- org.apache.celix.calc.api.Calculator_endpoint
- org.apache.celix.calc.api.Calculator2_endpoint
- )
+# TODO refactor shm remote service admin to use dfi
+# if (BUILD_RSA_REMOTE_SERVICE_ADMIN_SHM AND BUILD_RSA_DISCOVERY_SHM)
- # add_deploy(remote-services-shm
++# add_celix_container(remote-services-shm
+# NAME "server"
+# GROUP "remote-services/remote-services-shm"
+# BUNDLES discovery_shm topology_manager remote_service_admin_shm calculator shell shell_tui log_service log_writer
+# )
- # deploy_bundles_dir(remote-services-shm DIR_NAME "endpoints"
++# celix_container_bundles_dir(remote-services-shm DIR_NAME "endpoints"
+# BUNDLES org.apache.celix.calc.api.Calculator_endpoint
+# )
+#
- # add_deploy(remote-services-shm-client
++# add_celix_container(remote-services-shm-client
+# NAME "client"
+# GROUP "remote-services/remote-services-shm"
+# BUNDLES topology_manager remote_service_admin_shm shell shell_tui log_service log_writer calculator_shell discovery_shm
+# )
- # deploy_bundles_dir(remote-services-shm-client DIR_NAME "endpoints"
++# celix_container_bundles_dir(remote-services-shm-client DIR_NAME "endpoints"
+# BUNDLES org.apache.celix.calc.api.Calculator_proxy
+# )
+# endif ()
- add_celix_container("remote-services-etcd-client"
- NAME "client"
- GROUP "remote-services/remote-services-etcd"
- BUNDLES topology_manager remote_service_admin_http shell shell_tui log_service log_writer calculator_shell discovery_etcd
- )
- celix_container_bundles_dir(remote-services-etcd-client DIR_NAME "endpoints"
- BUNDLES org.apache.celix.calc.api.Calculator_proxy
- )
- endif ()
if (BUILD_RSA_DISCOVERY_ETCD AND BUILD_RSA_REMOTE_SERVICE_ADMIN_DFI)
- add_deploy(remote-services-dfi
+ add_celix_container(remote-services-dfi
NAME "server"
GROUP "remote-services/remote-services-dfi"
- BUNDLES discovery_etcd topology_manager remote_service_admin_dfi calculator shell shell_tui log_service log_writer
+ BUNDLES Celix::rsa_discovery_etcd Celix::rsa_topology_manager Celix::rsa_dfi calculator Celix::shell Celix::shell_tui Celix::log_service Celix::log_writer_stdout
)
- add_deploy("remote-services-dfi-client"
+ add_celix_container("remote-services-dfi-client"
NAME "client"
GROUP "remote-services/remote-services-dfi"
- BUNDLES topology_manager remote_service_admin_dfi shell shell_tui log_service log_writer calculator_shell discovery_etcd
+ BUNDLES Celix::rsa_topology_manager Celix::rsa_dfi Celix::shell Celix::shell_tui Celix::log_service Celix::log_writer_stdout calculator_shell Celix::rsa_discovery_etcd
)
endif ()
endif (RSA_EXAMPLES)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/examples/calculator_service/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/examples/calculator_service/CMakeLists.txt
index 167e705,32cbea2..e3e739a
--- a/remote_services/examples/calculator_service/CMakeLists.txt
+++ b/remote_services/examples/calculator_service/CMakeLists.txt
@@@ -15,15 -15,23 +15,15 @@@
# specific language governing permissions and limitations
# under the License.
- add_bundle(calculator
-include_directories("../../../utils/public/include")
-include_directories("../../utils/public/include")
-include_directories("../../remote_service_admin/public/include")
-include_directories("private/include")
-include_directories("public/include")
-
-add_celix_bundle(calculator SOURCES
- private/src/calculator_impl
- private/src/calculator_activator
-
- private/include/calculator_impl.h
-
++add_celix_bundle(calculator
+ SOURCES
+ src/calculator_impl
+ src/calculator_activator
SYMBOLIC_NAME "apache_celix_remoting_calculator_impl"
VERSION 0.0.1
)
+target_include_directories(calculator PRIVATE src)
+target_link_libraries(calculator PRIVATE Celix::rsa_spi calculator_api)
-celix_bundle_files(calculator public/include/org.apache.celix.calc.api.Calculator2.descriptor
- DESTINATION .)
-
-target_link_libraries(calculator celix_framework)
+get_target_property(DESCR calculator_api INTERFACE_CALCULATOR_DESCRIPTOR)
- bundle_files(calculator ${DESCR} DESTINATION .)
++celix_bundle_files(calculator ${DESCR} DESTINATION .)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/examples/calculator_shell/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/examples/calculator_shell/CMakeLists.txt
index 78c0737,2a49b3b..1eef035
--- a/remote_services/examples/calculator_shell/CMakeLists.txt
+++ b/remote_services/examples/calculator_shell/CMakeLists.txt
@@@ -15,21 -15,28 +15,21 @@@
# specific language governing permissions and limitations
# under the License.
- add_bundle(calculator_shell
-include_directories("private/include")
-include_directories("../../../utils/public/include")
-include_directories("../calculator_service/public/include")
-include_directories("../../../shell/public/include")
-
-add_celix_bundle(calculator_shell SOURCES
- private/src/add_command
- private/src/sub_command
- private/src/sqrt_command
- private/src/calculator_shell_activator
-
- private/include/add_command.h
- private/include/sqrt_command.h
- private/include/sub_command.h
-
++add_celix_bundle(calculator_shell
+ SOURCES
+ src/add_command
+ src/sub_command
+ src/sqrt_command
+ src/calculator_shell_activator
VERSION 0.0.1
SYMBOLIC_NAME "apache_celix_remoting_calculator_shell"
)
+target_include_directories(calculator_shell PRIVATE src)
+target_link_libraries(calculator_shell PRIVATE Celix::shell_api calculator_api)
- bundle_files(calculator_shell
+ celix_bundle_files(calculator_shell
- ../calculator_service/public/include/org.apache.celix.calc.api.Calculator2.descriptor
- #private/include/org.apache.celix.calc.api.Calculator2.descriptor ##Use this descriptor in case you want to try out versioning!
+ ../calculator_api/include/org.apache.celix.calc.api.Calculator2.descriptor
+ #src/org.apache.celix.calc.api.Calculator2.descriptor ##Use this descriptor in case you want to try out versioning!
DESTINATION .
)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/remote_service_admin_dfi/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/remote_service_admin_dfi/CMakeLists.txt
index ea79c31,4b28231..349c3ef
--- a/remote_services/remote_service_admin_dfi/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/CMakeLists.txt
@@@ -23,31 -23,21 +23,31 @@@ if (RSA_REMOTE_SERVICE_ADMIN_DFI
find_package(CURL REQUIRED)
find_package(Jansson REQUIRED)
- add_bundle(rsa_dfi
- include_directories(
- ${CURL_INCLUDE_DIRS}
- ${JANSSON_INCLUDE_DIRS}
++ add_celix_bundle(rsa_dfi
+ VERSION 0.9.0
+ SYMBOLIC_NAME "apache_celix_remote_service_admin_dfi"
+ NAME "Apache Celix Remote Service Admin Dynamic Function Interface (DFI)"
+ SOURCES
+ src/remote_service_admin_dfi.c
+ src/remote_service_admin_activator.c
+ src/export_registration_dfi.c
+ src/import_registration_dfi.c
+ src/dfi_utils.c
+ $<TARGET_OBJECTS:Celix::civetweb>
)
+ target_include_directories(rsa_dfi PRIVATE src $<TARGET_PROPERTY:Celix::civetweb,INCLUDE_DIRECTORIES>)
+ target_link_libraries(rsa_dfi PRIVATE
+ Celix::dfi_static
+ Celix::log_helper
+ Celix::rsa_common
+ ${CURL_LIBRARIES} ${JANSSON_LIBRARIES})
- install_bundle(rsa_dfi)
- if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
- include_directories(dynamic_function_interface/memstream)
- endif()
-
- add_subdirectory(rsa)
++ install_celix_bundle(rsa_dfi)
if (ENABLE_TESTING)
- find_package(CppUTest REQUIRED)
- include_directories(${CPPUTEST_INCLUDE_DIR})
- add_subdirectory(rsa_tst)
+ add_subdirectory(test)
endif()
+ #Setup target aliases to match external usage
+ add_library(Celix::rsa_dfi ALIAS rsa_dfi)
endif()
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/remote_service_admin_dfi/test/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/remote_service_admin_dfi/test/CMakeLists.txt
index 153b3d1,0000000..aa10ec3
mode 100644,000000..100644
--- a/remote_services/remote_service_admin_dfi/test/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/test/CMakeLists.txt
@@@ -1,60 -1,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.
+
+find_package(CppUTest REQUIRED)
+include_directories(${CPPUTEST_INCLUDE_DIR})
+
- add_bundle(rsa_dfi_tst_bundle
++add_celix_bundle(rsa_dfi_tst_bundle
+ VERSION 0.0.1
+ SOURCES
+ src/tst_activator.c
+)
+get_target_property(DESCR calculator_api INTERFACE_CALCULATOR_DESCRIPTOR)
- bundle_files(rsa_dfi_tst_bundle ${DESCR} DESTINATION .)
++celix_bundle_files(rsa_dfi_tst_bundle ${DESCR} DESTINATION .)
+target_link_libraries(rsa_dfi_tst_bundle PRIVATE ${CPPUTEST_LIBRARY} calculator_api)
+target_include_directories(rsa_dfi_tst_bundle PRIVATE src)
+
+add_executable(test_rsa_dfi
+ src/run_tests.cpp
+ src/rsa_tests.cpp
+ src/rsa_client_server_tests.cpp
+)
+target_include_directories(test_rsa_dfi PRIVATE src)
+target_link_libraries(test_rsa_dfi PRIVATE ${CURL_LIBRARIES} ${CPPUTEST_LIBRARY}
+ Celix::framework
+ Celix::rsa_common
+ calculator_api)
+
+get_property(rsa_bundle_file TARGET rsa_dfi PROPERTY BUNDLE_FILE)
+get_property(calc_bundle_file TARGET calculator PROPERTY BUNDLE_FILE)
+get_property(calculator_shell_bundle_file TARGET calculator_shell PROPERTY BUNDLE_FILE)
+get_property(discovery_configured_bundle_file TARGET rsa_discovery_configured PROPERTY BUNDLE_FILE)
+get_property(topology_manager_bundle_file TARGET Celix::rsa_topology_manager PROPERTY BUNDLE_FILE)
+get_property(tst_bundle_file TARGET rsa_dfi_tst_bundle PROPERTY BUNDLE_FILE)
+
+configure_file(config.properties.in config.properties)
+configure_file(client.properties.in client.properties)
+configure_file(server.properties.in server.properties)
+
+add_dependencies(test_rsa_dfi
+ rsa_dfi_bundle #note depend on the target creating the bundle zip not the lib target
+ calculator_bundle
+)
+
+add_test(NAME run_test_rsa_dfi COMMAND test_rsa_dfi)
+SETUP_TARGET_FOR_COVERAGE(test_rsa_dfi_cov test_rsa_dfi ${CMAKE_BINARY_DIR}/coverage/test_rsa_dfi/test_rsa_dfi)
+
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/remote_services_api/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/remote_services_api/CMakeLists.txt
index 67656d3,0000000..71f3306
mode 100644,000000..100644
--- a/remote_services/remote_services_api/CMakeLists.txt
+++ b/remote_services/remote_services_api/CMakeLists.txt
@@@ -1,28 -1,0 +1,28 @@@
+# 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.
+
- add_library(celix_remote_services_api INTERFACE)
- target_include_directories(celix_remote_services_api INTERFACE
++add_library(remote_services_api INTERFACE)
++target_include_directories(remote_services_api INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/include>
+ $<INSTALL_INTERFACE:include/celix/remote_services>
+)
+
- install(TARGETS celix_remote_services_api EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT rsa)
++install(TARGETS remote_services_api EXPORT celix DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT rsa)
+install(DIRECTORY include/ DESTINATION include/celix/remote_services COMPONENT rsa)
+
+#Setup target aliases to match external usage
- add_library(Celix::remote_services_api ALIAS celix_remote_services_api)
++add_library(Celix::remote_services_api ALIAS remote_services_api)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/rsa_common/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/rsa_common/CMakeLists.txt
index 27c2dba,0000000..397fa8c
mode 100644,000000..100644
--- a/remote_services/rsa_common/CMakeLists.txt
+++ b/remote_services/rsa_common/CMakeLists.txt
@@@ -1,29 -1,0 +1,30 @@@
+# 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.
+
- add_library(celix_rsa_common STATIC
++add_library(rsa_common STATIC
+ src/endpoint_description.c
+ src/export_registration_impl.c
+ src/import_registration_impl.c
+)
- target_include_directories(celix_rsa_common PRIVATE src)
- target_link_libraries(celix_rsa_common PUBLIC Celix::framework Celix::rsa_spi Celix::log_helper)
++set_target_properties(rsa_common PROPERTIES OUTPUT_NAME "celix_rsa_common")
++target_include_directories(rsa_common PRIVATE src)
++target_link_libraries(rsa_common PUBLIC Celix::framework Celix::rsa_spi Celix::log_helper)
+
- install(TARGETS celix_rsa_common EXPORT celix COMPONENT rsa DESTINATION ${CMAKE_INSTALL_LIBDIR})
++#install(TARGETS rsa_common EXPORT celix COMPONENT rsa DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+#Setup target aliases to match external usage
- add_library(Celix::rsa_common ALIAS celix_rsa_common)
++add_library(Celix::rsa_common ALIAS rsa_common)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/topology_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/topology_manager/CMakeLists.txt
index 6050229,69d14ed..763067d
--- a/remote_services/topology_manager/CMakeLists.txt
+++ b/remote_services/topology_manager/CMakeLists.txt
@@@ -16,21 -16,30 +16,21 @@@
# under the License.
celix_subproject(RSA_TOPOLOGY_MANAGER "Option to enable building the Remote Service Admin Service SHM bundle" ON DEPS REMOTE_SERVICE_ADMIN_DFI)
if (RSA_TOPOLOGY_MANAGER)
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/topology_manager/private/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/endpoint_listener/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/remote_service_admin/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/remote_services/topology_manager/public/include")
- add_bundle(rsa_topology_manager
- add_celix_bundle(topology_manager SOURCES
- private/src/topology_manager
- private/src/scope
- private/src/activator
-
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
- private/include/topology_manager.h
- public/include/tm_scope.h
++ add_celix_bundle(rsa_topology_manager
+ SOURCES
+ src/topology_manager
+ src/scope
+ src/activator
VERSION 0.9.0
SYMBOLIC_NAME "apache_celix_rs_topology_manager"
- NAME
- "Apache Celix RS Topology Manager"
+ NAME "Apache Celix RS Topology Manager"
)
+ target_include_directories(rsa_topology_manager PRIVATE src)
+ target_include_directories(rsa_topology_manager PUBLIC include)
+ target_link_libraries(rsa_topology_manager PRIVATE Celix::log_helper Celix::rsa_spi)
- install_bundle(rsa_topology_manager)
- install_celix_bundle(topology_manager)
++ install_celix_bundle(rsa_topology_manager)
if (ENABLE_TESTING)
find_package(CppUTest REQUIRED)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
index dc5dea5,6cf53fb..c9a9d62
--- a/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
+++ b/remote_services/topology_manager/tms_tst/bundle/CMakeLists.txt
@@@ -27,7 -27,7 +27,7 @@@ add_celix_bundle(topology_manager_test_
SOURCES
tst_activator.c
)
- bundle_files(topology_manager_test_bundle
-celix_bundle_files(topology_manager_test_bundle
++celix_celix_bundle_files(topology_manager_test_bundle
org.apache.celix.test.MyBundle.descriptor
DESTINATION .
)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
index 3e93174,cb88a21..6b8ae43
--- a/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
+++ b/remote_services/topology_manager/tms_tst/disc_mock/CMakeLists.txt
@@@ -15,7 -15,15 +15,7 @@@
# specific language governing permissions and limitations
# under the License.
- add_bundle(topology_manager_disc_mock_bundle
-include_directories(
- ${CPPUTEST_INCLUDE_DIR}
- ${PROJECT_SOURCE_DIR}/framework/public/include
- ${PROJECT_SOURCE_DIR}/utils/public/include
- ${PROJECT_SOURCE_DIR}/remote_services/discovery/private/include
-)
-
-
+ add_celix_bundle(topology_manager_disc_mock_bundle
VERSION 0.0.1
SOURCES
disc_mock_activator.c
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/remote_shell/CMakeLists.txt
----------------------------------------------------------------------
diff --cc remote_shell/CMakeLists.txt
index a7f5d36,aac0366..cd9ed98
--- a/remote_shell/CMakeLists.txt
+++ b/remote_shell/CMakeLists.txt
@@@ -22,23 -22,25 +22,23 @@@ if (REMOTE_SHELL
VERSION "0.0.2"
NAME: "Apache Celix Remote Shell"
SOURCES
- private/src/activator
- private/src/connection_listener
- private/src/shell_mediator
- private/src/remote_shell
-
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
- private/include/remote_shell.h
- private/include/connection_listener.h
+ src/activator
+ src/connection_listener
+ src/shell_mediator
+ src/remote_shell
)
-
+
+ target_include_directories(remote_shell PRIVATE src)
+ target_link_libraries(remote_shell PRIVATE log_helper)
- install_bundle(remote_shell)
+ install_celix_bundle(remote_shell)
-
- include_directories("private/include")
+
include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- target_link_libraries(remote_shell celix_framework)
+ target_link_libraries(remote_shell PRIVATE Celix::shell_api)
+
+ #Alias setup to match external usage
+ add_library(Celix::remote_shell ALIAS remote_shell)
- add_deploy("remote_shell_deploy" NAME "remote_shell" BUNDLES Celix::shell Celix::remote_shell Celix::shell_tui log_service)
- add_celix_container("remote_shell_deploy" NAME "remote_shell" BUNDLES shell remote_shell shell_tui log_service)
++ add_celix_container("remote_shell_deploy" NAME "remote_shell" BUNDLES Celix::shell Celix::remote_shell Celix::shell_tui log_service)
endif (REMOTE_SHELL)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/shell/CMakeLists.txt
----------------------------------------------------------------------
diff --cc shell/CMakeLists.txt
index b8aaac3,a2bf88e..93c066f
--- a/shell/CMakeLists.txt
+++ b/shell/CMakeLists.txt
@@@ -18,35 -18,38 +18,35 @@@ celix_subproject(SHELL "Option to enabl
if (SHELL)
find_package(CURL REQUIRED)
+ add_library(shell_api INTERFACE)
+ target_include_directories(shell_api INTERFACE include)
+
- add_bundle(shell
+ add_celix_bundle(shell
SYMBOLIC_NAME "apache_celix_shell"
VERSION "2.1.0"
NAME "Apache Celix Shell"
-
SOURCES
+ src/activator
+ src/shell
+ src/lb_command
+ src/start_command
+ src/stop_command
+ src/install_command
+ src/update_command
+ src/uninstall_command
+ src/log_command
+ src/inspect_command
+ src/help_command
+ )
+ target_include_directories(shell PRIVATE src ${CURL_INCLUDE_DIRS})
+ target_link_libraries(shell PRIVATE Celix::shell_api ${CURL_LIBRARIES} Celix::log_service_api Celix::log_helper)
- install_bundle(shell
- private/src/activator
- private/src/shell
- private/src/lb_command
- private/src/start_command
- private/src/stop_command
- private/src/install_command
- private/src/update_command
- private/src/uninstall_command
- private/src/log_command
- private/src/inspect_command
- private/src/help_command
-
- ${PROJECT_SOURCE_DIR}/log_service/public/src/log_helper.c
-
- )
-
- install_celix_bundle(shell
++ install_celix_bundle(shell
HEADERS
- public/include/shell.h public/include/command.h public/include/shell_constants.h
- )
+ include/shell.h include/command.h include/shell_constants.h
+ )
- include_directories("public/include")
- include_directories("private/include")
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
- include_directories(${CURL_INCLUDE_DIRS})
- target_link_libraries(shell celix_framework ${CURL_LIBRARIES})
+ #Setup target aliases to match external usage
+ add_library(Celix::shell_api ALIAS shell_api)
+ add_library(Celix::shell ALIAS shell)
endif (SHELL)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/shell/README.md
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/shell_bonjour/CMakeLists.txt
----------------------------------------------------------------------
diff --cc shell_bonjour/CMakeLists.txt
index 2276f09,e12d250..034a4f3
--- a/shell_bonjour/CMakeLists.txt
+++ b/shell_bonjour/CMakeLists.txt
@@@ -26,24 -26,28 +26,24 @@@ if (SHELL_BONJOUR
set(BUNDLE_VERSION "0.1.0")
set(BUNDLE_NAME "bonjour_shell")
- add_bundle(bonjour_shell
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
- include_directories("${LIBXML2_INCLUDE_DIR}")
- include_directories("private/include")
-
- set(MEMSTREAM_SOURCES )
- if (APPLE OR ANDROID)
- set(MEMSTREAM_SOURCES ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/open_memstream.c ${PROJECT_SOURCE_DIR}/utils/private/src/memstream/fmemopen.c)
- include_directories(${PROJECT_SOURCE_DIR}/utils/public/include/memstream)
- endif()
+ add_celix_bundle(bonjour_shell
- VERSION "1.0.0"
+ VERSION "1.0.0"
SOURCES
private/src/activator.c
private/src/bonjour_shell.c
- ${MEMSTREAM_SOURCES}
)
-
- target_link_libraries(bonjour_shell celix_framework celix_utils ${LIBXML2_LIBRARIES} ${DNS_SD_LIB})
+ add_library(Celix::bonjour_shell ALIAS bonjour_shell)
+
+
+ target_include_directories(bonjour_shell PRIVATE
+ "${PROJECT_SOURCE_DIR}/utils/public/include"
+ "${LIBXML2_INCLUDE_DIR}"
+ private/include
+ )
+ target_link_libraries(bonjour_shell PRIVATE ${LIBXML2_LIBRARIES} ${DNS_SD_LIB} Celix::shell_api)
- add_deploy("bonjour_shell_deploy" BUNDLES
+ add_celix_container("bonjour_shell_deploy" BUNDLES
- shell
+ Celix::shell
bonjour_shell
PROPERTIES "bonjour.shell.id=Apache Celix"
)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/shell_tui/CMakeLists.txt
----------------------------------------------------------------------
diff --cc shell_tui/CMakeLists.txt
index bd6b316,35153fe..acfe439
--- a/shell_tui/CMakeLists.txt
+++ b/shell_tui/CMakeLists.txt
@@@ -27,14 -27,10 +27,14 @@@ if (SHELL_TUI
private/src/history
)
+ target_include_directories(shell_tui PRIVATE
+ "${PROJECT_SOURCE_DIR}/utils/public/include"
+ private/include
+ )
+ target_link_libraries(shell_tui PRIVATE Celix::shell_api)
+
- install_bundle(shell_tui)
+ install_celix_bundle(shell_tui)
-
- include_directories("private/include")
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
- target_link_libraries(shell_tui celix_framework)
+
+ #Alias setup to match external usage
+ add_library(Celix::shell_tui ALIAS shell_tui)
endif (SHELL_TUI)
http://git-wip-us.apache.org/repos/asf/celix/blob/0ea8de64/shell_tui/README.md
----------------------------------------------------------------------