Skip to content

Commit

Permalink
Merge 0e00a43 into e7d0b65
Browse files Browse the repository at this point in the history
  • Loading branch information
rwalraven343 committed Nov 19, 2019
2 parents e7d0b65 + 0e00a43 commit f08d947
Show file tree
Hide file tree
Showing 9 changed files with 2,681 additions and 0 deletions.
1 change: 1 addition & 0 deletions bundles/pubsub/CMakeLists.txt
Expand Up @@ -29,6 +29,7 @@ if (PUBSUB)
add_subdirectory(pubsub_topology_manager)
add_subdirectory(pubsub_discovery)
add_subdirectory(pubsub_serializer_json)
add_subdirectory(pubsub_serializer_avrobin)
add_subdirectory(pubsub_admin_zmq)
add_subdirectory(pubsub_admin_tcp)
add_subdirectory(pubsub_admin_udp_mc)
Expand Down
37 changes: 37 additions & 0 deletions bundles/pubsub/pubsub_serializer_avrobin/CMakeLists.txt
@@ -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(Jansson REQUIRED)

add_celix_bundle(celix_pubsub_serializer_avrobin
BUNDLE_SYMBOLICNAME "apache_celix_pubsub_serializer_avrobin"
VERSION "1.0.0"
GROUP "Celix/PubSub"
SOURCES
src/ps_avrobin_serializer_activator.c
src/pubsub_avrobin_serializer_impl.c
)
target_include_directories(celix_pubsub_serializer_avrobin PRIVATE
src
${JANSSON_INCLUDE_DIR}
)
set_target_properties(celix_pubsub_serializer_avrobin PROPERTIES INSTALL_RPATH "$ORIGIN")
target_link_libraries(celix_pubsub_serializer_avrobin PRIVATE Celix::pubsub_spi Celix::framework Celix::dfi ${JANSSON_LIBRARIES} Celix::log_helper)

install_celix_bundle(celix_pubsub_serializer_avrobin EXPORT celix COMPONENT pubsub)

add_library(Celix::pubsub_serializer_avrobin ALIAS celix_pubsub_serializer_avrobin)
@@ -0,0 +1,58 @@
/**
*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.
*/

#include <stdlib.h>
#include <pubsub_constants.h>

#include "celix_api.h"
#include "pubsub_avrobin_serializer_impl.h"

typedef struct psav_activator {
pubsub_avrobin_serializer_t *serializer;
pubsub_serializer_service_t serializerSvc;
long serializerSvcId;
} psav_activator_t;

static int psav_start(psav_activator_t *act, celix_bundle_context_t *ctx) {
act->serializerSvcId = -1L;

celix_status_t status = pubsubAvrobinSerializer_create(ctx, &(act->serializer));
if (status == CELIX_SUCCESS) {
act->serializerSvc.handle = act->serializer;

act->serializerSvc.createSerializerMap = pubsubAvrobinSerializer_createSerializerMap;
act->serializerSvc.destroySerializerMap = pubsubAvrobinSerializer_destroySerializerMap;

/* Set serializer type */
celix_properties_t *props = celix_properties_create();
celix_properties_set(props, PUBSUB_SERIALIZER_TYPE_KEY, PUBSUB_AVROBIN_SERIALIZER_TYPE);

act->serializerSvcId = celix_bundleContext_registerService(ctx, &act->serializerSvc, PUBSUB_SERIALIZER_SERVICE_NAME, props);
}
return status;
}

static int psav_stop(psav_activator_t *act, celix_bundle_context_t *ctx) {
celix_bundleContext_unregisterService(ctx, act->serializerSvcId);
act->serializerSvcId = -1L;
pubsubAvrobinSerializer_destroy(act->serializer);
return CELIX_SUCCESS;
}

CELIX_GEN_BUNDLE_ACTIVATOR(psav_activator_t, psav_start, psav_stop)

0 comments on commit f08d947

Please sign in to comment.