static void setupFm(void) { int rc = 0; bundle_pt bundle = NULL; //server rc = celixLauncher_launch("server.properties", &serverFramework); CHECK_EQUAL(CELIX_SUCCESS, rc); bundle = NULL; rc = framework_getFrameworkBundle(serverFramework, &bundle); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundle_getContext(bundle, &serverContext); CHECK_EQUAL(CELIX_SUCCESS, rc); //client rc = celixLauncher_launch("client.properties", &clientFramework); CHECK_EQUAL(CELIX_SUCCESS, rc); bundle = NULL; rc = framework_getFrameworkBundle(clientFramework, &bundle); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundle_getContext(bundle, &clientContext); CHECK_EQUAL(CELIX_SUCCESS, rc); }
static void setupFm(void) { int rc = 0; rc = celixLauncher_launch("config.properties", &framework); CHECK_EQUAL(CELIX_SUCCESS, rc); bundle_pt bundle = NULL; rc = framework_getFrameworkBundle(framework, &bundle); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundle_getContext(bundle, &context); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char *)OSGI_RSA_REMOTE_SERVICE_ADMIN, &rsaRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(rsaRef != NULL); rc = bundleContext_getService(context, rsaRef, (void **)&rsa); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char *)CALCULATOR2_SERVICE, &calcRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(calcRef != NULL); rc = bundleContext_getService(context, calcRef, (void **)&calc); CHECK_EQUAL(CELIX_SUCCESS, rc); }
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; }
static void setupFmImport(void) { int rc = 0; rc = celixLauncher_launch("config_import.properties", &framework); CHECK_EQUAL(CELIX_SUCCESS, rc); bundle_pt bundle = NULL; rc = framework_getFrameworkBundle(framework, &bundle); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundle_getContext(bundle, &context); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char *)OSGI_RSA_REMOTE_SERVICE_ADMIN, &rsaRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(rsaRef != NULL); rc = bundleContext_getService(context, rsaRef, (void **)&rsa); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char *)TOPOLOGYMANAGER_SCOPE_SERVICE, &scopeServiceRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(scopeServiceRef != NULL); rc = bundleContext_getService(context, scopeServiceRef, (void **)&tmScopeService); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char *)TST_SERVICE_NAME, &testRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(testRef != NULL); rc = bundleContext_getService(context, testRef, (void **)&testImport); CHECK_EQUAL(CELIX_SUCCESS, rc); rc = bundleContext_getServiceReference(context, (char*)OSGI_ENDPOINT_LISTENER_SERVICE, &eplRef); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK(eplRef != NULL); rc = bundleContext_getService(context, eplRef, (void **)&eplService); CHECK_EQUAL(CELIX_SUCCESS, rc); }