celix_status_t importRegistrationFactory_open(import_registration_factory_pt registration_factory)
{
	celix_status_t status;

	char *bundleStore = NULL;
	bundleContext_getProperty(registration_factory->context, BUNDLE_STORE_PROPERTY_NAME, &bundleStore);

	if (bundleStore == NULL) {
		bundleStore = DEFAULT_BUNDLE_STORE;
	}

	char name[256];
	snprintf(name, 256, "%s/%s_proxy.zip", bundleStore, registration_factory->serviceName);

	status = bundleContext_installBundle(registration_factory->context, name, &registration_factory->bundle);

	if (status == CELIX_SUCCESS) {
		status = bundle_start(registration_factory->bundle);
		if (status == CELIX_SUCCESS) {
			logHelper_log(registration_factory->loghelper, OSGI_LOGSERVICE_INFO, "%s successfully started.", name);
		}
	}
	else {
		logHelper_log(registration_factory->loghelper, OSGI_LOGSERVICE_ERROR, "%s could not be installed.", name);
	}

	return status;
}
Example #2
0
celix_status_t importRegistrationFactory_open(import_registration_factory_pt registration_factory)
{
	celix_status_t status = CELIX_SUCCESS;

	char *bundleStore = NULL;
	bundleContext_getProperty(registration_factory->context, BUNDLE_STORE_PROPERTY_NAME, &bundleStore);

	if (bundleStore == NULL) {
		bundleStore = DEFAULT_BUNDLE_STORE;
	}

	char *name = apr_pstrcat(registration_factory->pool, bundleStore, "/", registration_factory->serviceName, "_proxy.zip", NULL);
	status = bundleContext_installBundle(registration_factory->context, name, &registration_factory->bundle);

	if (status == CELIX_SUCCESS) {
		status = bundle_start(registration_factory->bundle);
		if (status == CELIX_SUCCESS) {
			printf("%s sucessfully started\n", name);
		}
	}
	else
	{

		printf("%s could not be installed.\n", name);
	}

	return status;
}
Example #3
0
int main(void) {
	apr_status_t rv = APR_SUCCESS;
	apr_status_t s = APR_SUCCESS;
	properties_pt config = NULL;
	char *autoStart = NULL;
    apr_pool_t *pool = NULL;
    bundle_pt fwBundle = NULL;

	rv = apr_initialize();
    if (rv != APR_SUCCESS) {
        return CELIX_START_ERROR;
    }
    apr_pool_t *memoryPool;
    s = apr_pool_create(&memoryPool, NULL);
    if (s != APR_SUCCESS) {
        return CELIX_START_ERROR;
    }

    struct framework * framework = NULL;
    celix_status_t status = CELIX_SUCCESS;
    status = framework_create(&framework, memoryPool, config);
    if (status == CELIX_SUCCESS) {
		status = fw_init(framework);
		if (status == CELIX_SUCCESS) {
            // Start the system bundle
            framework_getFrameworkBundle(framework, &fwBundle);
            bundle_start(fwBundle);
            bundle_context_pt context = NULL;
            bundle_getContext(fwBundle, &context);

            // do some stuff
            bundle_pt bundle = NULL;
            status = CELIX_DO_IF(status, bundleContext_installBundle(context, "../test_bundle1/test_bundle1.zip", &bundle));
            status = CELIX_DO_IF(status, bundle_start(bundle));

            // Stop the system bundle, sleep a bit to let stuff settle down
            sleep(5);
            bundle_stop(fwBundle);

            framework_destroy(framework);
		}
    }

    if (status != CELIX_SUCCESS) {
        printf("Problem creating framework\n");
    }

	apr_pool_destroy(memoryPool);
	apr_terminate();

	printf("LAUNCHER: Exit\n");

    return 0;
}