コード例 #1
0
ファイル: disc_mock_activator.c プロジェクト: apache/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status;
    struct disc_mock_activator * act = userData;
    const char *uuid = NULL;

    act->reg = NULL;
    status = bundleContext_registerService(context, DISC_MOCK_SERVICE_NAME, act->serv, NULL, &act->reg);

    bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);

    if (!uuid) {
        return CELIX_ILLEGAL_STATE;
    }

    size_t len = 11 + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + strlen(OSGI_RSA_ENDPOINT_FRAMEWORK_UUID) + strlen(uuid);
    char *scope = malloc(len + 1);
    if (!scope) {
        return CELIX_ENOMEM;
    }

    sprintf(scope, "(&(%s=*)(%s=%s))", OSGI_FRAMEWORK_OBJECTCLASS, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);
    scope[len] = 0;

    properties_pt props = properties_create();
    properties_set(props, "DISCOVERY", "true");
    properties_set(props, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, scope);

    if (status == CELIX_SUCCESS) {
        endpoint_listener_pt endpointListener = calloc(1, sizeof(struct endpoint_listener));

        if (endpointListener) {
            endpointListener->handle = act;
            endpointListener->endpointAdded = discovery_endpointAdded;
            endpointListener->endpointRemoved = discovery_endpointRemoved;

            status = bundleContext_registerService(context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE, endpointListener, props, &act->endpointListenerService);

            if (status == CELIX_SUCCESS) {
                act->endpointListener = endpointListener;
            } else {
                free(endpointListener);
            }
        }
    }
    // We can release the scope, as properties_set makes a copy of the key & value...
    free(scope);

    return status;
}
コード例 #2
0
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status = CELIX_SUCCESS;
    struct activator * activator = userData;

    pthread_mutex_init(&activator->mutex, NULL);

    serviceTrackerCustomizer_create(activator, benchmarkRunner_addingService, benchmarkRunner_addedService, benchmarkRunner_modifiedService, benchmarkRunner_removedService, &activator->customizer);

    char filter[128];
    sprintf(filter, "(|(%s=%s)(%s=%s))", "objectClass", BENCHMARK_SERVICE_NAME, "objectClass", FREQUENCY_SERVICE_NAME);
    serviceTracker_createWithFilter(context, filter, activator->customizer, &activator->tracker);
    serviceTracker_open(activator->tracker);


    activator->reg = NULL;
    activator->command = calloc(1, sizeof(*activator->command));
    activator->command->handle = activator;
    activator->command->executeCommand = benchmarkRunner_execute;
    properties_pt props = properties_create();
    properties_set(props, OSGI_SHELL_COMMAND_NAME, "benchmark");
    properties_set(props, OSGI_SHELL_COMMAND_USAGE, "benchmark run");
    properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION, "run the available benchmark");

    bundleContext_registerService(context, (char *)OSGI_SHELL_COMMAND_SERVICE_NAME, activator->command, props, &activator->reg);

    return status;
}
コード例 #3
0
ファイル: calculator_proxy_impl.c プロジェクト: jawi/celix
celix_status_t calculatorProxy_registerProxyService(void* proxyFactoryService, endpoint_description_pt endpointDescription, void* rsa, sendToHandle sendToCallback) {
	celix_status_t status = CELIX_SUCCESS;

	remote_proxy_factory_service_pt calculatorProxyFactoryService = (remote_proxy_factory_service_pt) proxyFactoryService;
	calculator_pt calculator = NULL;
	calculator_service_pt calculatorService = NULL;

	calculatorProxy_create(calculatorProxyFactoryService->pool, calculatorProxyFactoryService->context, &calculator);
	calculatorService = apr_palloc(calculatorProxyFactoryService->pool, sizeof(*calculatorService));
	calculatorService->calculator = calculator;
	calculatorService->add = calculatorProxy_add;
	calculatorService->sub = calculatorProxy_sub;
	calculatorService->sqrt = calculatorProxy_sqrt;

	properties_pt srvcProps = properties_create();
	properties_set(srvcProps, (char *) "proxy.interface", (char *) CALCULATOR_SERVICE);
	properties_set(srvcProps, (char *) "endpoint.framework.uuid", (char *) endpointDescription->frameworkUUID);

	service_registration_pt proxyReg = NULL;

	calculatorProxy_setEndpointDescription(calculator, endpointDescription);
	calculatorProxy_setHandler(calculator, rsa);
	calculatorProxy_setCallback(calculator, sendToCallback);

	if (bundleContext_registerService(calculatorProxyFactoryService->context, CALCULATOR_SERVICE, calculatorService, srvcProps, &proxyReg) != CELIX_SUCCESS)
	{
		printf("CALCULATOR_PROXY: error while registering calculator service\n");
	}

	hashMap_put(calculatorProxyFactoryService->proxy_registrations, endpointDescription, proxyReg);


	return status;
}
コード例 #4
0
ファイル: calculator_activator.c プロジェクト: jawi/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;
	calculator_pt calculator = NULL;
	calculator_service_pt service = NULL;
	properties_pt properties = NULL;

	status = calculator_create(activator->pool, &calculator);
	if (status == CELIX_SUCCESS) {
		service = apr_palloc(activator->pool, sizeof(*service));
		if (!service) {
			status = CELIX_ENOMEM;
		} else {
			service->calculator = calculator;
			service->add = calculator_add;
			service->sub = calculator_sub;
			service->sqrt = calculator_sqrt;

			properties = properties_create();
			properties_set(properties, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) CALCULATOR_SERVICE);

			bundleContext_registerService(context, (char *) CALCULATOR_SERVICE, service, properties, &activator->calculatorReg);
		}
	}

	return status;
}
コード例 #5
0
celix_status_t remoteProxyFactory_register(remote_proxy_factory_pt remote_proxy_factory_ptr) {
	celix_status_t status = CELIX_SUCCESS;

	remote_proxy_factory_ptr->remote_proxy_factory_service_ptr = calloc(1, sizeof(*remote_proxy_factory_ptr->remote_proxy_factory_service_ptr));
	if (!remote_proxy_factory_ptr->remote_proxy_factory_service_ptr) {
		status = CELIX_ENOMEM;
	}

	if (status == CELIX_SUCCESS) {
		remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->factory = remote_proxy_factory_ptr;
		remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->registerProxyService = remoteProxyFactory_registerProxyService;
		remote_proxy_factory_ptr->remote_proxy_factory_service_ptr->unregisterProxyService = remoteProxyFactory_unregisterProxyService;

		remote_proxy_factory_ptr->properties = properties_create();
		if (!remote_proxy_factory_ptr->properties) {
			status = CELIX_BUNDLE_EXCEPTION;
		} else {
			properties_set(remote_proxy_factory_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service);
		}
	}

	if (status == CELIX_SUCCESS) {
		status = bundleContext_registerService(remote_proxy_factory_ptr->context_ptr, OSGI_RSA_REMOTE_PROXY_FACTORY,
				remote_proxy_factory_ptr->remote_proxy_factory_service_ptr, remote_proxy_factory_ptr->properties, &remote_proxy_factory_ptr->registration);
	}

	return status;
}
コード例 #6
0
ファイル: dm_shell_activator.c プロジェクト: leckie711/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status = CELIX_SUCCESS;
    bundle_instance_pt bi = (bundle_instance_pt) userData;
    command_service_pt commandService = calloc(1, sizeof(*commandService));

    if (commandService != NULL) {
        commandService->handle = context;
        commandService->executeCommand = dmListCommand_execute;

        properties_pt props = properties_create();
        properties_set(props, OSGI_SHELL_COMMAND_NAME, "dm");
        properties_set(props, OSGI_SHELL_COMMAND_USAGE, "dm");
        properties_set(props, OSGI_SHELL_COMMAND_DESCRIPTION,
                       "Gives an overview of the component managemend by a dependency manager.");

        bi->dmCommand = commandService;

        status = bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, commandService, props,
                                               &bi->reg);
    } else {
        status = CELIX_ENOMEM;
        free(commandService);
    }

    return status;
}
コード例 #7
0
celix_status_t wiringAdmin_importWiringEndpoint(wiring_admin_pt admin, wiring_endpoint_description_pt wEndpointDescription) {
    celix_status_t status = CELIX_SUCCESS;

    wiring_send_service_pt wiringSendService = calloc(1, sizeof(*wiringSendService));

    if (!wiringSendService) {
        status = CELIX_ENOMEM;
    } else {
        service_registration_pt wiringSendServiceReg = NULL;
        char* wireId = properties_get(wEndpointDescription->properties, WIRING_ENDPOINT_DESCRIPTION_WIRE_ID_KEY);

        properties_pt props = properties_create();
        properties_set(props, (char*) INAETICS_WIRING_WIRE_ID, wireId);

        wiringSendService->wiringEndpointDescription = wEndpointDescription;
        wiringSendService->send = wiringAdmin_send;
        wiringSendService->admin = admin;
        wiringSendService->errorCount = 0;

        status = bundleContext_registerService(admin->context, (char *) INAETICS_WIRING_SEND_SERVICE, wiringSendService, props, &wiringSendServiceReg);

        if (status == CELIX_SUCCESS) {

            hashMap_put(admin->wiringSendServices, wEndpointDescription, wiringSendService);
            hashMap_put(admin->wiringSendRegistrations, wEndpointDescription, wiringSendServiceReg);

            printf("%s: SEND SERVICE sucessfully registered w/ wireId %s\n", TAG, wireId);
        } else {
            printf("%s: could not register SEND SERVICE w/ wireId %s\n", TAG, wireId);

        }
    }

    return status;
}
コード例 #8
0
ファイル: event_handler_activator.c プロジェクト: jawi/celix
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;
}
コード例 #9
0
ファイル: activator.c プロジェクト: apache/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	printf("CONSUMING_DRIVER: starting bundle\n");
	celix_status_t status = CELIX_SUCCESS;
	consuming_driver_bundle_instance_pt bi = userData;

	consuming_driver_pt driver = NULL;
	status = consumingDriver_create(context, &driver);
	if (status == CELIX_SUCCESS) {
		driver_service_pt service = NULL;
		status = consumingDriver_createService(driver, &service);
		if (status == CELIX_SUCCESS) {
			properties_pt props = properties_create();
			properties_set(props, "DRIVER_ID", CONSUMING_DRIVER_ID);
			status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME, service, props, &bi->registration);
		}
	}

	if (status == CELIX_SUCCESS) {
		printf("CONSUMING_DRIVER: registered driver service.\n");
	} else {
		char error[256];
		printf("CONSUMING_DRIVER: Could not register driver service. Get error %s\n", celix_strerror(status, error, 256));
	}

	return status;
}
コード例 #10
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;
}
コード例 #11
0
ファイル: psa_activator.c プロジェクト: apache/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;
	pubsub_admin_service_pt pubsubAdminSvc = calloc(1, sizeof(*pubsubAdminSvc));

	if (!pubsubAdminSvc) {
		status = CELIX_ENOMEM;
	}
	else{
		pubsubAdminSvc->admin = activator->admin;

		pubsubAdminSvc->addPublication = pubsubAdmin_addPublication;
		pubsubAdminSvc->removePublication = pubsubAdmin_removePublication;

		pubsubAdminSvc->addSubscription = pubsubAdmin_addSubscription;
		pubsubAdminSvc->removeSubscription = pubsubAdmin_removeSubscription;

		pubsubAdminSvc->closeAllPublications = pubsubAdmin_closeAllPublications;
		pubsubAdminSvc->closeAllSubscriptions = pubsubAdmin_closeAllSubscriptions;

		pubsubAdminSvc->matchEndpoint = pubsubAdmin_matchEndpoint;

		activator->adminService = pubsubAdminSvc;

		status = bundleContext_registerService(context, PUBSUB_ADMIN_SERVICE, pubsubAdminSvc, NULL, &activator->registration);

		status += serviceTracker_open(activator->serializerTracker);

	}


	return status;
}
コード例 #12
0
ファイル: activator.c プロジェクト: leckie711/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
	struct greetingActivator * act = (struct greetingActivator *) userData;
	celix_status_t status = CELIX_SUCCESS;
	simple_shape_pt es = triangleShape_create(ctx);
	properties_pt props = properties_create();
	properties_set(props, "name", "triangle");
    status = bundleContext_registerService(ctx, SIMPLE_SHAPE_SERVICE_NAME, es, props, &act->reg);
	printf("Triangle activated %d\n", status);
	return status;
}
コード例 #13
0
ファイル: activator.c プロジェクト: INAETICS/demonstrator
static celix_status_t bundleActivator_registerProducerService(bundle_activator_pt act) {
	celix_status_t status = CELIX_SUCCESS;
	properties_pt props = NULL;
	props = properties_create();
	properties_set(props, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) INAETICS_DEMONSTRATOR_API__PRODUCER_SERVICE_NAME);

	status = bundleContext_registerService(act->context, (char *) INAETICS_DEMONSTRATOR_API__PRODUCER_SERVICE_NAME, act->producerService, props, &act->producerRegistration);

	return status;
}
コード例 #14
0
ファイル: activator.c プロジェクト: INAETICS/demonstrator
static celix_status_t bundleActivator_registerQueueService(struct activator *act) {
    celix_status_t status = CELIX_SUCCESS;
    properties_pt props = NULL;
    props = properties_create();
    properties_set(props, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, (char *) INAETICS_DEMONSTRATOR_API__SAMPLE_QUEUE_SERVICE_NAME);

    status = bundleContext_registerService(act->context, (char *)INAETICS_DEMONSTRATOR_API__SAMPLE_QUEUE_SERVICE_NAME,
                                           act->queueService, props, &act->queueRegistration);

    return status;
}
コード例 #15
0
ファイル: activator.c プロジェクト: leckie711/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt ctx) {
	struct activator * act = (struct activator *) userData;
	celix_status_t status = CELIX_SUCCESS;
	simple_shape_pt es = NULL;
	properties_pt props = NULL;

	circleShape_create(ctx, &es);
	props = properties_create();
	properties_set(props, "name", "circle");
    status = bundleContext_registerService(ctx, SIMPLE_SHAPE_SERVICE_NAME, es, props, &act->reg);
	return status;
}
コード例 #16
0
ファイル: activator.c プロジェクト: bpetri/node-wiring-c
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;

	struct echoActivator * activator = (struct echoActivator *) userData;

	if (sendCommand_create(context, &activator->sendCmd) == CELIX_SUCCESS) {
		echoServer_createCommandService(activator->sendCmd, &activator->sendCmdSrv);
		bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, activator->sendCmdSrv, NULL, &activator->sendCommand);
	} else {
		printf("ECHO_SERVER: creation of sendCommand failed.\n");
	}

	if (exportCommand_create(context, &activator->exportCmd) == CELIX_SUCCESS) {
		echoServer_createCommandService(activator->exportCmd, &activator->exportCmdSrv);
		bundleContext_registerService(context, (char *) OSGI_SHELL_COMMAND_SERVICE_NAME, activator->exportCmdSrv, NULL, &activator->exportCommand);
	} else {
		printf("ECHO_SERVER: creation of exportCommand failed.\n");
	}

	return status;
}
コード例 #17
0
ファイル: tst_activator.c プロジェクト: apache/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status = CELIX_SUCCESS;
	struct activator * act = userData;

	act->reg = NULL;
	status = bundleContext_registerService(context, (char *)TST_SERVICE_NAME, &act->serv, NULL, &act->reg);

	status = CELIX_DO_IF(status, serviceTracker_open(act->tracker));


	return status;
}
コード例 #18
0
ファイル: discovery_activator.c プロジェクト: jawi/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;

	char *uuid = NULL;
	status = bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
	if (!uuid) {
		printf("DISCOVERY_CONFIGURED: no framework UUID defined?!\n");
		return CELIX_ILLEGAL_STATE;
	}

	size_t len = 11 + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + strlen(OSGI_RSA_ENDPOINT_FRAMEWORK_UUID) + strlen(uuid);
	char *scope = malloc(len);
	if (!scope) {
		return CELIX_ENOMEM;
	}

	sprintf(scope, "(&(%s=*)(%s=%s))", OSGI_FRAMEWORK_OBJECTCLASS, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);
	scope[len] = 0;

	printf("DISCOVERY_CONFIGURED: using scope %s.\n", scope);

	endpoint_listener_pt endpointListener = malloc(sizeof(struct endpoint_listener));
	if (!endpointListener) {
		return CELIX_ENOMEM;
	}

	endpointListener->handle = activator->discovery;
	endpointListener->endpointAdded = discovery_endpointAdded;
	endpointListener->endpointRemoved = discovery_endpointRemoved;

	properties_pt props = properties_create();
	properties_set(props, "DISCOVERY", "true");
	properties_set(props, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, scope);

	status = bundleContext_registerService(context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE, endpointListener, props, &activator->endpointListenerService);

	if (status == CELIX_SUCCESS) {
		status = serviceTracker_open(activator->endpointListenerTracker);
	}

	if (status == CELIX_SUCCESS) {
		status = discovery_start(activator->discovery);
	}

	// We can release the scope, as properties_set makes a copy of the key & value...
	free(scope);

	return status;
}
コード例 #19
0
ファイル: echo_server_activator.c プロジェクト: jawi/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	struct echoActivator * act = (struct echoActivator *) userData;

	echo_service_pt es = malloc(sizeof(*es));
	echo_server_pt server = echoServer_create();
	es->server = server;
	es->echo = echoServer_echo;

	act->es = es;

    bundleContext_registerService(context, ECHO_SERVICE_NAME, es, NULL, &act->reg);

    return CELIX_SUCCESS;
}
コード例 #20
0
static celix_status_t remoteProxyFactory_registerProxyService(remote_proxy_factory_pt remote_proxy_factory_ptr, endpoint_description_pt endpointDescription, remote_service_admin_pt rsa, sendToHandle sendToCallback) {
	celix_status_t status = CELIX_SUCCESS;
	proxy_instance_pt proxy_instance_ptr = NULL;

	if (!remote_proxy_factory_ptr || !remote_proxy_factory_ptr->create_proxy_service_ptr) {
		status = CELIX_ILLEGAL_ARGUMENT;
	}

	if (status == CELIX_SUCCESS) {
		proxy_instance_ptr = calloc(1, sizeof(*proxy_instance_ptr));
		if (!proxy_instance_ptr) {
			status = CELIX_ENOMEM;
		}
	}

	if (status == CELIX_SUCCESS) {
		proxy_instance_ptr->properties = properties_create();
		if (!proxy_instance_ptr->properties) {
			status = CELIX_BUNDLE_EXCEPTION;
		}
	}

	if (status == CELIX_SUCCESS) {
		status = remote_proxy_factory_ptr->create_proxy_service_ptr(remote_proxy_factory_ptr->handle, endpointDescription, rsa, sendToCallback, proxy_instance_ptr->properties, &proxy_instance_ptr->service);
	}

	if (status == CELIX_SUCCESS) {
		properties_set(proxy_instance_ptr->properties, "proxy.interface", remote_proxy_factory_ptr->service);

		hash_map_iterator_pt iter = hashMapIterator_create(endpointDescription->properties);
		while (hashMapIterator_hasNext(iter)) {
			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
			char *key = hashMapEntry_getKey(entry);
			char *value = hashMapEntry_getValue(entry);
			properties_set(proxy_instance_ptr->properties, key, value);
		}
	}

	if (status == CELIX_SUCCESS) {
		status = bundleContext_registerService(remote_proxy_factory_ptr->context_ptr, remote_proxy_factory_ptr->service, proxy_instance_ptr->service, proxy_instance_ptr->properties, &proxy_instance_ptr->registration_ptr);
	}

	if (status == CELIX_SUCCESS) {
		hashMap_put(remote_proxy_factory_ptr->proxy_instances, endpointDescription, proxy_instance_ptr);
	}

	return status;
}
コード例 #21
0
ファイル: activator.c プロジェクト: ecros/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status = CELIX_SUCCESS;
	properties_pt props = properties_create();

	struct activatorData * data = (struct activatorData *) userData;
	data->ps = calloc(1, sizeof(*(data->ps)));
	data->pub = calloc(1, sizeof(*(data->pub)));
	data->ps->invoke = publisher_invoke;
	data->ps->publisher = data->pub;
	data->reg = NULL;

	properties_set(props, "id", "B");

	bundleContext_registerService(context, PUBLISHER_NAME, data->ps, props, &data->reg);
    return status;
}
コード例 #22
0
ファイル: refining_driver.c プロジェクト: ecros/celix
static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, refining_driver_device_pt device, char *serial) {
	celix_status_t status = CELIX_SUCCESS;
	refining_driver_device_service_pt service = NULL;
	status = refiningDriverDevice_createService(device, &service);
	if (status == CELIX_SUCCESS) {
		properties_pt props = properties_create();
		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
	}

	if (status == CELIX_SUCCESS) {
		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
	}
	return status;
}
コード例 #23
0
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;
	remote_endpoint_pt endpoint = NULL;
	remote_endpoint_service_pt endpointService = NULL;

	calculatorEndpoint_create(activator->pool, &endpoint);
	endpointService = apr_palloc(activator->pool, sizeof(*endpointService));
	endpointService->endpoint = endpoint;
	endpointService->handleRequest = calculatorEndpoint_handleRequest;
	endpointService->setService = calculatorEndpoint_setService;

	bundleContext_registerService(context, OSGI_RSA_REMOTE_ENDPOINT, endpointService, NULL, &activator->endpoint);


	return status;
}
コード例 #24
0
ファイル: dm_activator_base.c プロジェクト: ErjanAltena/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status;
	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;


    status = dm_init(dependency_activator->userData, context, dependency_activator->manager);

    if (status == CELIX_SUCCESS) {
        //Create the service
        dependency_activator->info->handle = dependency_activator->manager;
        dependency_activator->info->getInfo = (void *) dependencyManager_getInfo;
        dependency_activator->info->destroyInfo = (void *) dependencyManager_destroyInfo;

        status = bundleContext_registerService(context, DM_INFO_SERVICE_NAME, dependency_activator->info, NULL,
                                               &(dependency_activator->reg));
    }

	return status;
}
コード例 #25
0
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;
	remote_endpoint_pt endpoint = NULL;
	remote_endpoint_service_pt endpointService = NULL;

	calculatorEndpoint_create(&endpoint);
	endpointService = calloc(1, sizeof(*endpointService));
	endpointService->endpoint = endpoint;
	endpointService->handleRequest = calculatorEndpoint_handleRequest;
        endpointService->setService = calculatorEndpoint_setService;

        properties_pt props = properties_create();
        properties_set(props, (char *) "remote.interface", (char *) CALCULATOR2_SERVICE);

        bundleContext_registerService(context, OSGI_RSA_REMOTE_ENDPOINT, endpointService, props, &activator->endpointServiceRegistration);

	activator->endpointService = endpointService;

	return status;
}
コード例 #26
0
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
{
        celix_status_t result = CELIX_SUCCESS;
        struct web_console_activator *wca = (struct web_console_activator*) userData;

        wca->webConsole = calloc(sizeof(struct web_console_service),1);
        if(wca->webConsole) {
                wca->webConsole->webConsole = webConsoleServicesCreate(context);
                wca->webConsole->getServiceName = webConsoleServicesServiceName;
                wca->webConsole->getWebEntry = webConsoleServicesServiceWebEntry;
                wca->webConsole->copyRecourcesToWebDirectory = webConsoleServicesServiceCopyResources;
                wca->webConsole->removeRecourcesFromWebDirectory = webConsoleServicesServiceRemoveResources;
                wca->webConsole->getJsonData = webConsoleServicesServiceGetJsonData;
                wca->webConsole->getMainWebPage = webConsoleServicesServiceGetMainWebPage;
                bundleContext_registerService(context, WEB_CONSOLE_SERVICE, wca->webConsole, NULL, &wca->reg);
        } else {
                wca->webConsole = NULL;
                result = CELIX_START_ERROR;
        }
        return result;
}
コード例 #27
0
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
	celix_status_t status = CELIX_SUCCESS;
	struct activator *activator = userData;
	remote_service_admin_service_pt remoteServiceAdmin = NULL;

	status = remoteServiceAdmin_create(context, &activator->admin);
	if (status == CELIX_SUCCESS) {
		remoteServiceAdmin = calloc(1, sizeof(*remoteServiceAdmin));
		if (!remoteServiceAdmin) {
			status = CELIX_ENOMEM;
		} else {
			remoteServiceAdmin->admin = activator->admin;
			remoteServiceAdmin->exportService = remoteServiceAdmin_exportService;

			remoteServiceAdmin->getExportedServices = remoteServiceAdmin_getExportedServices;
			remoteServiceAdmin->getImportedEndpoints = remoteServiceAdmin_getImportedEndpoints;
			remoteServiceAdmin->importService = remoteServiceAdmin_importService;

			remoteServiceAdmin->exportReference_getExportedEndpoint = exportReference_getExportedEndpoint;
			remoteServiceAdmin->exportReference_getExportedService = exportReference_getExportedService;

			remoteServiceAdmin->exportRegistration_close = exportRegistration_close;
			remoteServiceAdmin->exportRegistration_getException = exportRegistration_getException;
			remoteServiceAdmin->exportRegistration_getExportReference = exportRegistration_getExportReference;

			remoteServiceAdmin->importReference_getImportedEndpoint = importReference_getImportedEndpoint;
			remoteServiceAdmin->importReference_getImportedService = importReference_getImportedService;

			remoteServiceAdmin->importRegistration_close = remoteServiceAdmin_removeImportedService;
			remoteServiceAdmin->importRegistration_getException = importRegistration_getException;
			remoteServiceAdmin->importRegistration_getImportReference = importRegistration_getImportReference;

			status = bundleContext_registerService(context, OSGI_RSA_REMOTE_SERVICE_ADMIN, remoteServiceAdmin, NULL, &activator->registration);
			activator->adminService = remoteServiceAdmin;
		}
	}

	return status;
}
コード例 #28
0
ファイル: activator.c プロジェクト: ErjanAltena/celix
celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
    celix_status_t status;
    struct activator *activator = userData;

    endpoint_listener_pt endpointListener = malloc(sizeof(*endpointListener));
    endpointListener->handle = activator->manager;
    endpointListener->endpointAdded = topologyManager_addImportedService;
    endpointListener->endpointRemoved = topologyManager_removeImportedService;
    activator->endpointListener = endpointListener;

    char *uuid = NULL;
    status = bundleContext_getProperty(activator->context, (char *) OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid);
    if (!uuid) {
        logHelper_log(activator->loghelper, OSGI_LOGSERVICE_ERROR, "TOPOLOGY_MANAGER: no framework UUID defined?!");
        return CELIX_ILLEGAL_STATE;
    }

    size_t len = 14 + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + strlen(OSGI_RSA_ENDPOINT_FRAMEWORK_UUID) + strlen(uuid);
    char *scope = malloc(len);
    if (!scope) {
        return CELIX_ENOMEM;
    }

    snprintf(scope, len, "(&(%s=*)(!(%s=%s)))", OSGI_FRAMEWORK_OBJECTCLASS, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID, uuid);

    logHelper_log(activator->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: endpoint listener scope is %s", scope);

    properties_pt props = properties_create();
    properties_set(props, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, scope);

    // We can release the scope, as properties_set makes a copy of the key & value...
    free(scope);

    bundleContext_registerService(context, (char *) OSGI_ENDPOINT_LISTENER_SERVICE, endpointListener, props, &activator->endpointListenerService);

    listener_hook_service_pt hookService = malloc(sizeof(*hookService));
    hookService->handle = activator->manager;
    hookService->added = topologyManager_listenerAdded;
    hookService->removed = topologyManager_listenerRemoved;
    activator->hookService = hookService;

    bundleContext_registerService(context, (char *) OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, hookService, NULL, &activator->hook);
    bundleContext_addServiceListener(context, activator->serviceListener, "(service.exported.interfaces=*)");

    if (status == CELIX_SUCCESS) {
        serviceTracker_open(activator->remoteServiceAdminTracker);
    }

    if (status == CELIX_SUCCESS) {
        status = serviceTracker_open(activator->endpointListenerTracker);
    }

	bundleContext_registerService(context, (char *) TOPOLOGYMANAGER_SCOPE_SERVICE, activator->scopeService, NULL, &activator->scopeReg);

    array_list_pt references = NULL;
    bundleContext_getServiceReferences(context, NULL, "(service.exported.interfaces=*)", &references);
    int i;
    for (i = 0; i < arrayList_size(references); i++) {
        service_reference_pt reference = arrayList_get(references, i);
        char *serviceId = NULL;
        status = CELIX_DO_IF(status, serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_ID, &serviceId));

        CELIX_DO_IF(status, topologyManager_addExportedService(activator->manager, reference, serviceId));
    }
    arrayList_destroy(references);

    return status;
}