Skip to content

Commit

Permalink
Allow async import of Wiring Endpoints/Services
Browse files Browse the repository at this point in the history
  • Loading branch information
bpetri committed Sep 24, 2015
1 parent 2f63862 commit 58c2d0d
Show file tree
Hide file tree
Showing 11 changed files with 375 additions and 110 deletions.
11 changes: 7 additions & 4 deletions node_discovery/private/src/node_discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ celix_status_t node_discovery_removeNode(node_discovery_pt node_discovery, node_
char* wireId = properties_get(wep->properties, WIRING_ENDPOINT_DESCRIPTION_WIRE_ID_KEY);

if (strcmp(wireId, rmWireId) == 0) {
printf("NODE_DISCOVERY: Removing Wiring Endpoint %s - %s\n", node_desc->nodeId, rmWireId);
node_discovery_informWiringEndpointListeners(node_discovery, wep, false);
arrayListIterator_remove(wep_it);
}
Expand Down Expand Up @@ -298,23 +299,22 @@ celix_status_t node_discovery_informWiringEndpointListeners(node_discovery_pt no
if (status == CELIX_SUCCESS) {
if (node_discovery->listenerReferences != NULL) {
hash_map_iterator_pt iter = hashMapIterator_create(node_discovery->listenerReferences);

while (hashMapIterator_hasNext(iter)) {
hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);

service_reference_pt reference = hashMapEntry_getKey(entry);
wiring_endpoint_listener_pt listener = NULL;

char* scope = NULL;
char* rsa = NULL;
serviceReference_getProperty(reference, (char *) INAETICS_WIRING_ENDPOINT_LISTENER_SCOPE, &scope);
serviceReference_getProperty(reference, (char *) "RSA", &rsa);

filter_pt filter = filter_create(scope);
bool matchResult = false;

filter_match(filter, wEndpoint->properties, &matchResult);

if (matchResult && rsa == NULL) {
if (matchResult) {
bundleContext_getService(node_discovery->context, reference, (void**) &listener);
if (wEndpointAdded) {
listener->wiringEndpointAdded(listener->handle, wEndpoint, scope);
Expand Down Expand Up @@ -422,8 +422,10 @@ celix_status_t node_discovery_wiringEndpointListenerAdded(void * handle, service

node_discovery_pt nodeDiscovery = handle;

char *nodeDiscoveryListener = NULL;
char* nodeDiscoveryListener = NULL;

serviceReference_getProperty(reference, "NODE_DISCOVERY", &nodeDiscoveryListener);

char *scope = NULL;
serviceReference_getProperty(reference, (char *) INAETICS_WIRING_ENDPOINT_LISTENER_SCOPE, &scope);

Expand All @@ -447,6 +449,7 @@ celix_status_t node_discovery_wiringEndpointListenerAdded(void * handle, service

bool matchResult = false;
filter_match(filter, ep_desc->properties, &matchResult);

if (matchResult) {
wiring_endpoint_listener_pt listener = service;
listener->wiringEndpointAdded(listener->handle, ep_desc, NULL);
Expand Down
2 changes: 1 addition & 1 deletion node_discovery/public/include/node_discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define NODE_DISCOVERY_ZONE_IDENTIFIER "NODE_DISCOVERY_ZONE_IDENTIFIER"
#define NODE_DISCOVERY_NODE_IDENTIFIER "NODE_DISCOVERY_NODE_IDENTIFIER"

typedef struct node_discovery *node_discovery_pt;
typedef struct node_discovery* node_discovery_pt;


#endif /* NODE_DISCOVERY_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdlib.h>

#include <constants.h>
#include <string.h>

#include "celix_errno.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

#include <stdlib.h>
#include <string.h>

#include "bundle_activator.h"
#include "constants.h"
Expand Down Expand Up @@ -70,6 +71,11 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
if (status != CELIX_SUCCESS) {
printf("RSA: Creation of WTMTracker failed\n");
} else {

/* the rsa also has a wiringEndpointListener because it needs to be informed, when a
* wiring endpoint has been sucessfully exported/imported and therefore it
* the according services can be exported/imported.
*/
wEndpointListener->handle = (void*) activator->admin;
wEndpointListener->wiringEndpointAdded = remoteServiceAdmin_addWiringEndpoint;
wEndpointListener->wiringEndpointRemoved = remoteServiceAdmin_removeWiringEndpoint;
Expand Down
Loading

0 comments on commit 58c2d0d

Please sign in to comment.