Пример #1
0
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;
}
Пример #2
0
service_pt serviceComponent_create(bundle_context_pt context, dependency_manager_pt manager) {
    service_pt service;
    apr_pool_t *pool;
	apr_pool_t *mypool;

	bundleContext_getMemoryPool(context, &pool);
	apr_pool_create(&mypool, pool);

	if (mypool) {
        service = (service_pt) apr_pcalloc(mypool, sizeof(*service));
        service->pool = mypool;
        service->impl = NULL;
        service->serviceName = NULL;
        service->serviceRegistration = NULL;
        service->dependencies = NULL;
        arrayList_create(&service->dependencies);

        service->init = service_init;
        service->start= service_start;
        service->stop = service_stop;
        service->destroy = service_destroy;

        service->context = context;
        service->manager = manager;
        service->state = state_create(arrayList_clone(service->dependencies), false);
        service->executor = executor_create(mypool);

		apr_thread_mutex_create(&service->mutex, APR_THREAD_MUTEX_UNNESTED, mypool);
	}

	return service;
}
Пример #3
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	celix_status_t status = CELIX_SUCCESS;
	apr_pool_t *parentPool = NULL;
	apr_pool_t *pool = NULL;
	struct activator *activator;

	status = bundleContext_getMemoryPool(context, &parentPool);
	if (status == CELIX_SUCCESS) {
		if (apr_pool_create(&pool, parentPool) != APR_SUCCESS) {
			status = CELIX_BUNDLE_EXCEPTION;
		} else {
			activator = apr_palloc(pool, sizeof(*activator));
			if (!activator) {
				status = CELIX_ENOMEM;
			} else {
				activator->pool = pool;
				activator->admin = NULL;
				activator->registration = NULL;

				*userData = activator;
			}
		}
	}

	return status;
}
Пример #4
0
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;
}
Пример #5
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	celix_status_t status = CELIX_SUCCESS;
	apr_pool_t *pool = NULL;
	apr_pool_t *parentPool;
	struct activator *activator;

	status = bundleContext_getMemoryPool(context, &parentPool);
	if (status == CELIX_SUCCESS) {
		if (apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
			status = CELIX_BUNDLE_EXCEPTION;
		} else {
			activator = apr_palloc(pool, sizeof(*activator));
			activator->pool = pool;
			activator->registration = NULL;
			*userData = activator;

			event_handler_pt event_handler = NULL;
			event_handler_service_pt event_handler_service = NULL;

			status = eventHandlerCreate(activator->pool, context, &event_handler);
			if (status == CELIX_SUCCESS) {
				event_handler_service = apr_palloc(activator->pool, sizeof(event_handler_service));
				if (!event_handler_service) {
					status = CELIX_ENOMEM;
				} else {
					event_handler_service->event_handler = event_handler;
					event_handler_service->handle_event = eventHandlerHandleEvent;
				}
			}
			activator->event_handler_service = event_handler_service;
		}
	}

	return status;
}
Пример #6
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	apr_pool_t *pool;
	struct activator *activator;
	celix_status_t status = bundleContext_getMemoryPool(context, &pool);
	if (status == CELIX_SUCCESS) {
		*userData = apr_palloc(pool, sizeof(struct activator));
		activator = *userData;
		activator->reg = NULL;
		activator->pool = pool;
	}
	return status;
}
Пример #7
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	apr_pool_t *pool;
	greeting_activator_pt activator;
	celix_status_t status = bundleContext_getMemoryPool(context, &pool);
	if (status == CELIX_SUCCESS) {
		*userData = apr_palloc(pool, sizeof(struct greetingActivator));
		activator = *userData;
		activator->reg = NULL;
		activator->pool = pool;
	}
	printf("Triangle created %d\n", status);
	return status;
}
Пример #8
0
command_pt subCommand_create(bundle_context_pt context) {
	apr_pool_t *pool;
	bundleContext_getMemoryPool(context, &pool);

    command_pt command = (command_pt) apr_palloc(pool, sizeof(*command));
    if (command) {
		command->bundleContext = context;
		command->name = "sub";
		command->shortDescription = "subtract the given doubles";
		command->usage = "sub <double> <double>";
		command->executeCommand = subCommand_execute;
    }
    return command;
}
Пример #9
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
    celix_status_t status = CELIX_SUCCESS;
    apr_pool_t *pool = NULL;
    apr_pool_t *parentPool;
    struct activator *activator;
    status = bundleContext_getMemoryPool(context, &parentPool);
    if( status == CELIX_SUCCESS ) {
        if(apr_pool_create(&pool,parentPool) != APR_SUCCESS) {
            status = CELIX_BUNDLE_EXCEPTION;
        } else {
            activator = apr_palloc(pool,sizeof(*activator));
            activator->pool = pool;
            activator->registration = NULL;
            logHelper_create(context, &activator->loghelper);

            *userData = activator;
            event_admin_pt event_admin = NULL;
            event_admin_service_pt event_admin_service = NULL;
            status = eventAdmin_create(activator->pool,context, &event_admin);
            if(status == CELIX_SUCCESS) {
                activator->event_admin = event_admin;
                event_admin_service = apr_palloc(activator->pool, sizeof(event_admin_service));
                if(!event_admin_service) {
                    status = CELIX_ENOMEM;
                } else {
                    event_admin->context = context;
                    event_admin->loghelper = &activator->loghelper;
                    event_admin_service->eventAdmin = event_admin;
                    event_admin_service->postEvent = eventAdmin_postEvent;
                    event_admin_service->sendEvent = eventAdmin_sendEvent;
                    event_admin_service->createEvent = eventAdmin_createEvent;
                    event_admin_service->containsProperty = eventAdmin_containsProperty;
                    event_admin_service->event_equals = eventAdmin_event_equals;
                    event_admin_service->getProperty = eventAdmin_getProperty;
                    event_admin_service->getPropertyNames = eventAdmin_getPropertyNames;
                    event_admin_service->getTopic = eventAdmin_getTopic;
                    event_admin_service->hashCode = eventAdmin_hashCode;
                    event_admin_service->matches = eventAdmin_matches;
                    event_admin_service->toString = eventAdmin_toString;

                }
            }
            activator->event_admin_service = event_admin_service;
        }
    }

    return status;
}
Пример #10
0
celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
	printf("REFINING_DRIVER: creating bundle\n");
	celix_status_t status = CELIX_SUCCESS;
	apr_pool_t *pool;
	status = bundleContext_getMemoryPool(context, &pool);
	if (status == CELIX_SUCCESS) {
		refining_driver_bundle_instance_pt instance = apr_palloc(pool, sizeof(*instance));
		if (instance != NULL) {
			instance->context = context;
			instance->pool = pool;
			instance->registration = NULL;
			(*userData) = instance;
		} else {
			status = CELIX_ENOMEM;
		}
	}
	return status;
}