Ejemplo n.º 1
0
celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
    celix_status_t status = CELIX_SUCCESS;
    struct activator *activator = userData;

    if (serviceTracker_close(activator->remoteServiceAdminTracker) == CELIX_SUCCESS) {
        serviceTracker_destroy(activator->remoteServiceAdminTracker);
    }

    if (serviceTracker_close(activator->endpointListenerTracker) == CELIX_SUCCESS) {
        serviceTracker_destroy(activator->endpointListenerTracker);
    }

    bundleContext_removeServiceListener(context, activator->serviceListener);
    free(activator->serviceListener);

    serviceRegistration_unregister(activator->hook);
    free(activator->hookService);

    serviceRegistration_unregister(activator->endpointListenerService);
    free(activator->endpointListener);

    serviceRegistration_unregister(activator->scopeReg);

    topologyManager_closeImports(activator->manager);

    return status;
}
Ejemplo n.º 2
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **out) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *act = calloc(1, sizeof(*act));
	if (act != NULL) {
		act->context = context;
		act->serv.handle = act;
		act->serv.test = test;

		status = serviceTrackerCustomizer_create(act, NULL, addCalc, NULL, removeCalc, &act->cust);
		status = CELIX_DO_IF(status, serviceTracker_create(context, CALCULATOR2_SERVICE, act->cust, &act->tracker));

	} else {
		status = CELIX_ENOMEM;
	}

	if (status == CELIX_SUCCESS) {
		*out = act;
	} else if (act != NULL) {
		if (act->cust != NULL) {
			free(act->cust);
			act->cust = NULL;
		}
		if (act->tracker != NULL) {
			serviceTracker_destroy(act->tracker);
			act->tracker = NULL;
		}
		free(act);
	}

	return CELIX_SUCCESS;
}
Ejemplo n.º 3
0
celix_status_t wiringAdmin_removeExportedWiringEndpoint(wiring_admin_pt admin, wiring_endpoint_description_pt wEndpointDescription) {
    celix_status_t status = CELIX_SUCCESS;

    if (wEndpointDescription == NULL) {
        status = CELIX_ILLEGAL_ARGUMENT;
    } else {
        celixThreadMutex_lock(&admin->exportedWiringEndpointLock);
        service_tracker_pt wiringReceiveTracker = NULL;

        wiringReceiveTracker = hashMap_remove(admin->wiringReceiveTracker, wEndpointDescription);

        if (wiringReceiveTracker != NULL) {
            if (serviceTracker_close(wiringReceiveTracker) == CELIX_SUCCESS) {
                serviceTracker_destroy(wiringReceiveTracker);
            }

            if (hashMap_size(admin->wiringReceiveTracker) == 0) {
                wiringAdmin_stopWebserver(admin);
            }
        }

        wiringEndpointDescription_destroy(&wEndpointDescription);

        celixThreadMutex_unlock(&admin->exportedWiringEndpointLock);
    }

    return status;
}
Ejemplo n.º 4
0
celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
	celix_status_t status = CELIX_SUCCESS;
    celix_status_t tmp_status;

	if (!dependency) {
		status = CELIX_ILLEGAL_ARGUMENT;
	}

	if (status == CELIX_SUCCESS) {
		if (dependency->tracker) {
            tmp_status = serviceTracker_close(dependency->tracker);
            if (tmp_status != CELIX_SUCCESS) {
                status = tmp_status;
            }
			tmp_status = serviceTracker_destroy(dependency->tracker);
            if (tmp_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
                status = tmp_status;
            }
		}
	}

	if (status == CELIX_SUCCESS) {
		dependency->isStarted = false;
	}

	return status;
}
Ejemplo n.º 5
0
celix_status_t wiringAdmin_stop(wiring_admin_pt admin) {
    celix_status_t status = CELIX_SUCCESS;

    celixThreadMutex_lock(&admin->exportedWiringEndpointLock);

    // stop tracker
    hash_map_iterator_pt iter = hashMapIterator_create(admin->wiringReceiveTracker);

    while (hashMapIterator_hasNext(iter)) {
        service_tracker_pt wiringReceiveTracker = (service_tracker_pt) hashMapIterator_nextValue(iter);

        if (serviceTracker_close(wiringReceiveTracker) == CELIX_SUCCESS) {
            serviceTracker_destroy(wiringReceiveTracker);
        }
    }
    hashMapIterator_destroy(iter);

    hashMap_clear(admin->wiringReceiveTracker, false, false);

    wiringAdmin_stopWebserver(admin);

    iter = hashMapIterator_create(admin->wiringReceiveServices);

    while (hashMapIterator_hasNext(iter)) {
        array_list_pt wiringReceiveServiceList = hashMapIterator_nextValue(iter);
        arrayList_destroy(wiringReceiveServiceList);
    }

    hashMapIterator_destroy(iter);
    hashMap_clear(admin->wiringReceiveServices, false, false);

    celixThreadMutex_unlock(&admin->exportedWiringEndpointLock);

    return status;
}
Ejemplo n.º 6
0
celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
	struct activator *act = userData;
	if (act != NULL) {
		if (act->tracker != NULL) {
			serviceTracker_destroy(act->tracker);
			act->tracker = NULL;
		}
		free(act);
	}
	return CELIX_SUCCESS;
}
Ejemplo n.º 7
0
celix_status_t wiringAdmin_exportWiringEndpoint(wiring_admin_pt admin, wiring_endpoint_description_pt* wEndpointDescription) {
    celix_status_t status = CELIX_SUCCESS;

    celixThreadMutex_lock(&admin->exportedWiringEndpointLock);

    if (hashMap_size(admin->wiringReceiveTracker) == 0) {
        status = wiringAdmin_startWebserver(admin->context, &admin);
    }

    if (status == CELIX_SUCCESS) {
        char* fwuuid = NULL;

        status = bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &fwuuid);

        if (status == CELIX_SUCCESS) {
            char* wireId = NULL;
            properties_pt props = properties_create();

            printf("%s: HTTP Wiring Endpoint running at %s\n", TAG, admin->url);

            status = wiringEndpointDescription_create(NULL, props, wEndpointDescription);

            properties_set(props, WIRING_ADMIN_PROPERTIES_CONFIG_KEY, WIRING_ADMIN_PROPERTIES_CONFIG_VALUE);
            properties_set(props, WIRING_ENDPOINT_DESCRIPTION_HTTP_URL_KEY, admin->url);
            properties_set(props, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, fwuuid);

            wireId = properties_get(props, WIRING_ENDPOINT_DESCRIPTION_WIRE_ID_KEY);

            printf("%s: wiringEndpointDescription_create w/ wireId %s started\n", TAG, wireId);

            if (status == CELIX_SUCCESS) {
                service_tracker_pt tracker = NULL;
                status = wiringAdmin_createWiringReceiveTracker(admin, &tracker, wireId);

                if (status == CELIX_SUCCESS) {
                    status = serviceTracker_open(tracker);

                    if (status == CELIX_SUCCESS) {
                        hashMap_put(admin->wiringReceiveTracker, *wEndpointDescription, tracker);
                        printf("%s: WiringReceiveTracker w/ wireId %s started\n", TAG, wireId);
                    } else {
                        serviceTracker_destroy(tracker);
                    }
                }
            }
        }
    } else {
        printf("%s: Cannot export Wiring Endpoint\n", TAG);
    }

    celixThreadMutex_unlock(&admin->exportedWiringEndpointLock);

    return status;
}
Ejemplo n.º 8
0
celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;

	serviceTracker_destroy(activator->serializerTracker);
	pubsubAdmin_destroy(activator->admin);
	activator->admin = NULL;

	free(activator);

	return status;
}
Ejemplo n.º 9
0
celix_status_t managedServiceTracker_destroy(bundle_context_pt context, managed_service_tracker_pt mgServTr, service_tracker_pt tracker) {
	updatedThreadPool_destroy(mgServTr->updatedThreadPool);
	celixThreadMutex_destroy(&mgServTr->managedServicesReferencesMutex);
	serviceTracker_destroy(tracker);

	hashMap_destroy(mgServTr->managedServices, true, true);
	hashMap_destroy(mgServTr->managedServicesReferences, true, true);

    free(mgServTr);

	return CELIX_SUCCESS;
}
Ejemplo n.º 10
0
celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	bundle_activator_pt activator = userData;

	printf("PROCESSOR: Stopping bundle...\n");
	serviceTracker_close(activator->queueTracker);
	serviceTracker_close(activator->dataStoreTracker);

	serviceTracker_destroy(activator->queueTracker);
	serviceTracker_destroy(activator->dataStoreTracker);

	serviceRegistration_unregister(activator->processorStatsRegistration);

	processor_stop(activator->processor);

	free(activator->processorStatsService);

	processor_destroy(activator->processor);

	return status;
}
Ejemplo n.º 11
0
celix_status_t importRegistrationFactory_destroy(import_registration_factory_pt* registration_factory) {
	celix_status_t status = CELIX_SUCCESS;

	if (*registration_factory != NULL)
	{
		free((*registration_factory)->serviceName);
		arrayList_destroy((*registration_factory)->registrations);

		serviceTracker_destroy((*registration_factory)->proxyFactoryTracker);
		free(*registration_factory);

		*registration_factory = NULL;
	}


	return status;
}
Ejemplo n.º 12
0
celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	bundle_activator_pt activator = (bundle_activator_pt) userData;

	printf("PRODUCER: Stopping bundle...\n");

	serviceTracker_close(activator->tracker);
	serviceTracker_destroy(activator->tracker);

	serviceRegistration_unregister(activator->producerStatsRegistration);
	serviceRegistration_unregister(activator->producerRegistration);

	producer_stop(activator->producer);


	return status;
}
Ejemplo n.º 13
0
celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;

	status = serviceTracker_destroy(activator->endpointListenerTracker);

//	status = serviceRegistration_destroy(activator->endpointListenerService);

	status = discovery_destroy(activator->discovery);

	activator->endpointListenerTracker = NULL;
	activator->endpointListenerService = NULL;
	activator->discovery = NULL;
	activator->context = NULL;

	free(activator);

	return status;
}
Ejemplo n.º 14
0
celix_status_t pubsub_topicSubscriptionDestroy(topic_subscription_pt ts){
	celix_status_t status = CELIX_SUCCESS;

	celixThreadMutex_lock(&ts->ts_lock);
	ts->running = false;
	free(ts->ifIpAddress);
	serviceTracker_destroy(ts->tracker);
	arrayList_clear(ts->sub_ep_list);
	arrayList_destroy(ts->sub_ep_list);
	hashMap_destroy(ts->servicesMap,false,false);

	celixThreadMutex_lock(&ts->socketMap_lock);
	hashMap_destroy(ts->socketMap,true,true);
	celixThreadMutex_unlock(&ts->socketMap_lock);
	celixThreadMutex_destroy(&ts->socketMap_lock);

	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);

	largeUdp_destroy(ts->largeUdpHandle);
#if defined(__APPLE__) && defined(__MACH__)
	//TODO: Use kqueue for OSX
#else
	close(ts->topicEpollFd);
#endif

	celixThreadMutex_unlock(&ts->ts_lock);

	celixThreadMutex_destroy(&ts->ts_lock);

	free(ts);

	return status;
}