Beispiel #1
0
celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
	printf("phase3: dm_init\n");
    celix_status_t status = CELIX_SUCCESS;

    struct phase3_activator_struct *act = (struct phase3_activator_struct *)userData;

	act->phase3Cmp = phase3_create();
	if (act->phase3Cmp != NULL) {

		properties_pt props = properties_create();
		properties_set(props, "id", "phase3");

		dm_component_pt cmp;
		component_create(context, "PHASE3_PROCESSING_COMPONENT", &cmp);
		component_setImplementation(cmp, act->phase3Cmp);
		component_setCallbacksSafe(cmp, phase3_cmp_t *, phase3_init, phase3_start, phase3_stop, phase3_deinit);

		dm_service_dependency_pt dep;
		serviceDependency_create(&dep);
		serviceDependency_setService(dep, PHASE2_NAME, NULL);
        serviceDependency_setCallbacksSafe(dep, phase3_cmp_t *, phase2_t *, NULL, phase3_addPhase2, NULL, phase3_removePhase2, NULL);
		serviceDependency_setRequired(dep, true);
		component_addServiceDependency(cmp, dep);

		dependencyManager_add(manager, cmp);
	} else {
		status = CELIX_ENOMEM;
	}

    return status;
}
Beispiel #2
0
celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
	printf("PHASE1: dm_init\n");
    celix_status_t status = CELIX_SUCCESS;


    struct phase1_activator_struct *act = (struct phase1_activator_struct *)userData;

	act->phase1Cmp = phase1_create();
	if (act->phase1Cmp != NULL) {

		act->phase1Serv.handle = act->phase1Cmp;
		act->phase1Serv.getData = (void *)phase1_getData;

		properties_pt props = properties_create();
		properties_set(props, "id", "phase1");

		dm_component_pt cmp;
		component_create(context, "PHASE1_PROCESSING_COMPONENT", &cmp);
		component_setImplementation(cmp, act->phase1Cmp);
		component_setCallbacksSafe(cmp, phase1_cmp_t *, phase1_init, phase1_start, phase1_stop, phase1_deinit);
		component_addInterface(cmp, PHASE1_NAME, &act->phase1Serv, props);

		dependencyManager_add(manager, cmp);
	} else {
		status = CELIX_ENOMEM;
	}

    return status;
}
Beispiel #3
0
celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
	printf("Init\n");
	struct data * data = (struct data *) userData;
	dm_component_pt service = NULL;
	dm_service_dependency_pt dep1 = NULL;
	dm_service_dependency_pt dep2 = NULL;

	data->context = context;

	component_create(context, "ExampleCmp", &service);
	component_setImplementation(service, data);
	component_setCallbacks(service, service_init, service_start, service_stop, service_deinit);

	serviceDependency_create(&dep1);
	serviceDependency_setRequired(dep1, true);
	serviceDependency_setService(dep1, PUBLISHER_NAME, "(|(id=A)(id=B))");
	serviceDependency_setCallbacksWithServiceReference(dep1, NULL /*tracker_setServ*/, tracker_addedServ, tracker_modifiedServ, tracker_removedServ, NULL);
	component_addServiceDependency(service, dep1);

	serviceDependency_create(&dep2);
    serviceDependency_setRequired(dep2, false);
    serviceDependency_setService(dep2, (char *) OSGI_LOGSERVICE_NAME, NULL);
    serviceDependency_setCallbacksWithServiceReference(dep2, NULL  /*tracker_setLog*/, tracker_addLog, tracker_modifiedLog, tracker_removeLog, NULL);
	serviceDependency_setAutoConfigure(dep2, &data->logger_lock, (void **) &data->logger);
    component_addServiceDependency(service, dep2);

	data->service = service;
	data->dep = dep1;
	data->dep2 = dep2;

	dependencyManager_add(manager, service);

	return CELIX_SUCCESS;
}
Beispiel #4
0
celix_status_t dm_init(void *userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
    celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;

	dm_component_pt cmp = NULL;
	component_create(context, "BAR", &cmp);
	component_setImplementation(cmp, activator->bar);
	component_addInterface(cmp, EXAMPLE_NAME, EXAMPLE_VERSION, &activator->exampleService, NULL);

	dependencyManager_add(manager, cmp);
    return status;
}
Beispiel #5
0
celix_status_t dm_init(void * userData, bundle_context_pt context, dm_dependency_manager_pt manager) {
    printf("phase2a: dm_init\n");
    celix_status_t status = CELIX_SUCCESS;

    struct phase2a_activator_struct *act = (struct phase2a_activator_struct *)userData;

    act->phase2aCmp = phase2a_create();
    if (act->phase2aCmp != NULL) {

        act->phase2Serv.handle = act->phase2aCmp;
        act->phase2Serv.getData = (void *)phase2a_getData;

        properties_pt props = properties_create();
        properties_set(props, "id", "phase2a");

        dm_component_pt cmp;
        component_create(context, "PHASE2A_PROCESSING_COMPONENT", &cmp);
        component_setImplementation(cmp, act->phase2aCmp);
        component_setCallbacksSafe(cmp, phase2a_cmp_t *, phase2a_init, phase2a_start, phase2a_stop, phase2a_deinit);
        component_addInterface(cmp, PHASE2_NAME, PHASE2_VERSION, &act->phase2Serv, props);


        dm_service_dependency_pt dep;
        serviceDependency_create(&dep);
        serviceDependency_setService(dep, PHASE1_NAME, PHASE1_RANGE_ALL, NULL);

        serviceDependency_setCallbacksSafe(dep, phase2a_cmp_t *, phase1_t *, phase2a_setPhase1, NULL, NULL, NULL, NULL);
        serviceDependency_setRequired(dep, true);
        component_addServiceDependency(cmp, dep);

        dependencyManager_add(manager, cmp);
    } else {
        status = CELIX_ENOMEM;
    }

    return status;
}