celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { celix_status_t status = CELIX_SUCCESS; service_tracker_customizer_pt queueCustomizer = NULL; service_tracker_customizer_pt dataStoreCustomizer = NULL; bundle_activator_pt activator = (bundle_activator_pt) userData; char *name = NULL; char *uuid = NULL; char uuidName[128]; memset(uuidName, 0, 128); bundleContext_getProperty(context, "inaetics.demonstrator.processor.name", &name); bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); if (name != NULL) { snprintf(uuidName, 128, "%s %s",PROCESSOR_STATS_SERVICE_NAME_PREFIX, name); } else if (name == NULL && uuid != NULL) { snprintf(uuidName, 128, "%s %.8s",PROCESSOR_STATS_SERVICE_NAME_PREFIX, uuid); } else { snprintf(uuidName, 128, "%s (unknown ID)",PROCESSOR_STATS_SERVICE_NAME_PREFIX); } printf("PROCESSOR: Starting bundle...\n"); status = processor_create(uuidName, &activator->processor); if (status == CELIX_SUCCESS) { bundleActivator_createStatsService(activator); if (activator->processorStatsService != NULL) { bundleActivator_registerStatsService(activator); } if (activator->processorStatsService == NULL || activator->processorStatsRegistration == NULL) { printf("PROCESSOR: Error creating/registering statService\n"); } else { printf("PROCESSOR: Created processor with name %s\n", uuidName); } } /*Track QueueService*/ serviceTrackerCustomizer_create(activator->processor, NULL, processor_queueServiceAdded, NULL, processor_queueServiceRemoved, &queueCustomizer); serviceTracker_create(context, INAETICS_DEMONSTRATOR_API__SAMPLE_QUEUE_SERVICE_NAME, queueCustomizer, &activator->queueTracker); serviceTracker_open(activator->queueTracker); /*Track DataStoreService*/ serviceTrackerCustomizer_create(activator->processor, NULL, processor_dataStoreServiceAdded, NULL, processor_dataStoreServiceRemoved, &dataStoreCustomizer); serviceTracker_create(context, INAETICS_DEMONSTRATOR_API__DATA_STORE_SERVICE_NAME, dataStoreCustomizer, &activator->dataStoreTracker); serviceTracker_open(activator->dataStoreTracker); return status; }
celix_status_t managedServiceTracker_createCustomized(bundle_context_pt context, managed_service_tracker_pt trackerHandle, service_tracker_pt *tracker) { celix_status_t status; service_tracker_customizer_pt customizer = NULL; service_tracker_pt managedServiceTracker = NULL; status = serviceTrackerCustomizer_create(trackerHandle, managedServiceTracker_addingService, managedServiceTracker_addedService, managedServiceTracker_modifiedService, managedServiceTracker_removedService, &customizer); if (status != CELIX_SUCCESS) { printf("[ ERROR ]: TrackerCustomized - Not initialized(ENOMEM) \n"); *tracker = NULL; return CELIX_ENOMEM; } serviceTracker_create(context, (char *) MANAGED_SERVICE_SERVICE_NAME, customizer, &managedServiceTracker); if (status != CELIX_SUCCESS) { printf("[ ERROR ]: TrackerCustomized - Not created \n"); *tracker = NULL; return status; } *tracker = managedServiceTracker; return CELIX_SUCCESS; }
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; }
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { celix_status_t status = CELIX_SUCCESS; struct activator *activator = userData; event_admin_service_pt event_admin_service = NULL; apr_pool_t *pool; status = bundleContext_getMemoryPool(context, &pool); if(status == CELIX_SUCCESS) { struct activator * data = (struct activator *) userData; service_tracker_customizer_pt cust = NULL; service_tracker_pt tracker = NULL; data->context = context; serviceTrackerCustomizer_create(data->event_admin_service->eventAdmin, eventAdmin_addingService, eventAdmin_addedService, eventAdmin_modifiedService, eventAdmin_removedService, &cust); serviceTracker_create(context, (char *) EVENT_HANDLER_SERVICE, cust, &tracker); data->tracker = tracker; serviceTracker_open(tracker); properties_pt properties = NULL; properties = properties_create(); event_admin_service = activator->event_admin_service; //printf("pointer of event admin service %p\n",event_admin_service); bundleContext_registerService(context, (char *) EVENT_ADMIN_NAME, event_admin_service, properties, &activator->registration); logHelper_start(activator->loghelper); } return status; }
celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt *instance) { celix_status_t status = CELIX_SUCCESS; service_tracker_customizer_pt customizer = NULL; (*instance) = (shell_mediator_pt) calloc(1, sizeof(**instance)); if ((*instance) != NULL) { (*instance)->context = context; (*instance)->tracker = NULL; (*instance)->shellService = NULL; status = logHelper_create(context, &(*instance)->loghelper); status = CELIX_DO_IF(status, celixThreadMutex_create(&(*instance)->mutex, NULL)); status = CELIX_DO_IF(status, serviceTrackerCustomizer_create((*instance), shellMediator_addingService, shellMediator_addedService, shellMediator_modifiedService, shellMediator_removedService, &customizer)); status = CELIX_DO_IF(status, serviceTracker_create(context, (char * )OSGI_SHELL_SERVICE_NAME, customizer, &(*instance)->tracker)); if (status == CELIX_SUCCESS) { logHelper_start((*instance)->loghelper); serviceTracker_open((*instance)->tracker); } } else { status = CELIX_ENOMEM; } if (status != CELIX_SUCCESS) { logHelper_log((*instance)->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating shell_mediator, error code is %i\n", status); } return status; }
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { celix_status_t status = CELIX_SUCCESS; struct activator *activator = userData; properties_pt properties = NULL; properties = properties_create(); properties_set(properties,(char*)EVENT_HANDLER_SERVICE,(char *)EVENT_HANDLER_NAME); properties_set(properties,(char*)EVENT_TOPIC, (char*) "log/error/eventpublishers/event"); event_handler_service_pt event_handler_service = activator->event_handler_service; bundleContext_registerService(context, (char *) EVENT_HANDLER_SERVICE, event_handler_service, properties, &activator->registration); apr_pool_t *pool; status = bundleContext_getMemoryPool(context, &pool); if (status == CELIX_SUCCESS) { service_tracker_customizer_pt customizer = NULL; service_tracker_pt tracker = NULL; serviceTrackerCustomizer_create(activator->event_handler_service->event_handler, eventHandlerAddingService, eventHandlerAddedService, eventHandlerModifiedService, eventHandlerRemovedService, &customizer); serviceTracker_create(context, (char *) EVENT_ADMIN_NAME, customizer, &tracker); activator->eventAdminTracker = tracker; serviceTracker_open(tracker); properties_pt properties = NULL; properties = properties_create(); } return status; }
static celix_status_t bundleActivator_createRSATracker(struct activator *activator, service_tracker_pt *tracker) { celix_status_t status; service_tracker_customizer_pt customizer = NULL; status = serviceTrackerCustomizer_create(activator->manager, topologyManager_rsaAdding, topologyManager_rsaAdded, topologyManager_rsaModified, topologyManager_rsaRemoved, &customizer); if (status == CELIX_SUCCESS) { status = serviceTracker_create(activator->context, OSGI_RSA_REMOTE_SERVICE_ADMIN, customizer, tracker); } return status; }
celix_status_t wiringTopologyManager_createWaTracker(wiring_topology_manager_pt manager, service_tracker_pt *tracker) { celix_status_t status = CELIX_SUCCESS; service_tracker_customizer_pt customizer = NULL; status = serviceTrackerCustomizer_create(manager, wiringTopologyManager_waAdding, wiringTopologyManager_waAdded, wiringTopologyManager_waModified, wiringTopologyManager_waRemoved, &customizer); if (status == CELIX_SUCCESS) { status = serviceTracker_create(manager->context, (char*) INAETICS_WIRING_ADMIN, customizer, tracker); } return status; }
celix_status_t wiringTopologyManager_createWiringEndpointListenerTracker(wiring_topology_manager_pt manager, service_tracker_pt *tracker) { celix_status_t status; service_tracker_customizer_pt customizer = NULL; status = serviceTrackerCustomizer_create(manager, wiringTopologyManager_wiringEndpointListenerAdding, wiringTopologyManager_wiringEndpointListenerAdded, wiringTopologyManager_wiringEndpointListenerModified, wiringTopologyManager_wiringEndpointListenerRemoved, &customizer); if (status == CELIX_SUCCESS) { status = serviceTracker_create(manager->context, (char *) INAETICS_WIRING_ENDPOINT_LISTENER_SERVICE, customizer, tracker); } return status; }
static celix_status_t bundleActivator_createEPLTracker(struct activator *activator, service_tracker_pt *tracker) { celix_status_t status; service_tracker_customizer_pt customizer = NULL; status = serviceTrackerCustomizer_create(activator->manager, topologyManager_endpointListenerAdding, topologyManager_endpointListenerAdded, topologyManager_endpointListenerModified, topologyManager_endpointListenerRemoved, &customizer); if (status == CELIX_SUCCESS) { status = serviceTracker_create(activator->context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE, customizer, tracker); } return status; }
celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) { celix_status_t status = CELIX_SUCCESS; bundle_context_pt context = NULL; if (!dependency || !dependency->component || (!dependency->tracked_service_name && !dependency->tracked_filter)) { status = CELIX_ILLEGAL_ARGUMENT; } if (status == CELIX_SUCCESS) { status = component_getBundleContext(dependency->component, &context); if (!context) { status = CELIX_BUNDLE_EXCEPTION; } } if (status == CELIX_SUCCESS) { dependency->tracker_customizer = NULL; status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer); } if (status == CELIX_SUCCESS) { if (dependency->tracked_filter) { status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker); } else if (dependency->tracked_service_name) { status = serviceTracker_create(context, dependency->tracked_service_name, dependency->tracker_customizer, &dependency->tracker); } } if (status == CELIX_SUCCESS) { status = serviceTracker_open(dependency->tracker); } if (status == CELIX_SUCCESS) { dependency->isStarted = true; } return status; }
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) { celix_status_t status = CELIX_SUCCESS; struct activator *activator; activator = calloc(1, sizeof(*activator)); if (!activator) { status = CELIX_ENOMEM; } else{ *userData = activator; status = pubsubAdmin_create(context, &(activator->admin)); if(status == CELIX_SUCCESS){ service_tracker_customizer_pt customizer = NULL; status = serviceTrackerCustomizer_create(activator->admin, NULL, pubsubAdmin_serializerAdded, NULL, pubsubAdmin_serializerRemoved, &customizer); if(status == CELIX_SUCCESS){ status = serviceTracker_create(context, PUBSUB_SERIALIZER_SERVICE, customizer, &(activator->serializerTracker)); if(status != CELIX_SUCCESS){ serviceTrackerCustomizer_destroy(customizer); pubsubAdmin_destroy(activator->admin); } } else{ pubsubAdmin_destroy(activator->admin); } } } return status; }