You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2011/05/30 08:34:10 UTC
svn commit: r1129004 - in /incubator/celix/trunk: framework/private/include/
framework/private/src/ launcher/
Author: abroekhuis
Date: Mon May 30 06:34:09 2011
New Revision: 1129004
URL: http://svn.apache.org/viewvc?rev=1129004&view=rev
Log:
Removed global vars from the framework. Now located in the FRAMEWORK struct
Modified:
incubator/celix/trunk/framework/private/include/framework.h
incubator/celix/trunk/framework/private/include/headers.h
incubator/celix/trunk/framework/private/include/service_registry.h
incubator/celix/trunk/framework/private/src/bundle_context.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/service_registry.c
incubator/celix/trunk/launcher/launcher.c
Modified: incubator/celix/trunk/framework/private/include/framework.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework.h?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework.h (original)
+++ incubator/celix/trunk/framework/private/include/framework.h Mon May 30 06:34:09 2011
@@ -53,9 +53,9 @@ celix_status_t fw_getServiceReferences(F
void * fw_getService(FRAMEWORK framework, BUNDLE bundle, SERVICE_REFERENCE reference);
bool framework_ungetService(FRAMEWORK framework, BUNDLE bundle, SERVICE_REFERENCE reference);
-void fw_addServiceListener(BUNDLE bundle, SERVICE_LISTENER listener, char * filter);
-void fw_removeServiceListener(BUNDLE bundle, SERVICE_LISTENER listener);
-void fw_serviceChanged(SERVICE_EVENT event, PROPERTIES oldprops);
+void fw_addServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener, char * filter);
+void fw_removeServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener);
+void fw_serviceChanged(FRAMEWORK framework, SERVICE_EVENT event, PROPERTIES oldprops);
//BUNDLE_ARCHIVE fw_createArchive(long id, char * location);
//void revise(BUNDLE_ARCHIVE archive, char * location);
Modified: incubator/celix/trunk/framework/private/include/headers.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/headers.h?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/headers.h (original)
+++ incubator/celix/trunk/framework/private/include/headers.h Mon May 30 06:34:09 2011
@@ -57,6 +57,9 @@
struct framework {
struct bundle * bundle;
HASH_MAP installedBundleMap;
+ HASH_MAP installRequestMap;
+ ARRAY_LIST serviceListeners;
+
long nextBundleId;
struct serviceRegistry * registry;
BUNDLE_CACHE cache;
@@ -134,9 +137,10 @@ struct serviceEvent {
typedef struct serviceEvent * SERVICE_EVENT;
struct serviceRegistry {
+ FRAMEWORK framework;
HASH_MAP serviceRegistrations;
HASH_MAP inUseMap;
- void (*serviceChanged)(SERVICE_EVENT, PROPERTIES);
+ void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES);
long currentServiceId;
Modified: incubator/celix/trunk/framework/private/include/service_registry.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registry.h?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registry.h (original)
+++ incubator/celix/trunk/framework/private/include/service_registry.h Mon May 30 06:34:09 2011
@@ -32,7 +32,7 @@
#include "properties.h"
#include "filter.h"
-SERVICE_REGISTRY serviceRegistry_create(void (*serviceChanged)(SERVICE_EVENT, PROPERTIES));
+SERVICE_REGISTRY serviceRegistry_create(FRAMEWORK framework, void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES));
ARRAY_LIST serviceRegistry_getRegisteredServices(SERVICE_REGISTRY registry, BUNDLE bundle);
SERVICE_REGISTRATION serviceRegistry_registerService(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES dictionary);
void serviceRegistry_unregisterService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REGISTRATION registration);
Modified: incubator/celix/trunk/framework/private/src/bundle_context.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_context.c?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Mon May 30 06:34:09 2011
@@ -235,7 +235,7 @@ celix_status_t bundleContext_addServiceL
celix_status_t status = CELIX_SUCCESS;
if (context != NULL && listener != NULL) {
- fw_addServiceListener(context->bundle, listener, filter);
+ fw_addServiceListener(context->framework, context->bundle, listener, filter);
} else {
status = CELIX_ILLEGAL_ARGUMENT;
}
@@ -247,7 +247,7 @@ celix_status_t bundleContext_removeServi
celix_status_t status = CELIX_SUCCESS;
if (context != NULL && listener != NULL) {
- fw_removeServiceListener(context->bundle, listener);
+ fw_removeServiceListener(context->framework, context->bundle, listener);
} else {
status = CELIX_ILLEGAL_ARGUMENT;
}
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon May 30 06:34:09 2011
@@ -58,10 +58,6 @@ struct activator {
void (*destroy)(void * userData, BUNDLE_CONTEXT context);
};
-ARRAY_LIST m_serviceListeners;
-
-HASH_MAP m_installRequestMap;
-
celix_status_t framework_setBundleStateAndNotify(FRAMEWORK framework, BUNDLE bundle, int state);
celix_status_t framework_markBundleResolved(FRAMEWORK framework, MODULE module);
@@ -113,12 +109,6 @@ celix_status_t framework_create(FRAMEWOR
if (apr_status != CELIX_SUCCESS) {
status = CELIX_FRAMEWORK_EXCEPTION;
} else {
- (*framework)->bundle = bundle;
- (*framework)->bundle->framework = (*framework);
-
- (*framework)->installedBundleMap = NULL;
- (*framework)->registry = NULL;
-
apr_status_t apr_status = apr_thread_cond_create(&(*framework)->condition, (*framework)->mp);
if (apr_status != APR_SUCCESS) {
status = CELIX_FRAMEWORK_EXCEPTION;
@@ -135,6 +125,12 @@ celix_status_t framework_create(FRAMEWOR
if (apr_status != APR_SUCCESS) {
status = CELIX_FRAMEWORK_EXCEPTION;
} else {
+ (*framework)->bundle = bundle;
+ (*framework)->bundle->framework = (*framework);
+
+ (*framework)->installedBundleMap = NULL;
+ (*framework)->registry = NULL;
+
(*framework)->interrupted = false;
(*framework)->globalLockWaitersList = arrayList_create();
@@ -143,7 +139,9 @@ celix_status_t framework_create(FRAMEWOR
(*framework)->nextBundleId = 1l;
(*framework)->cache = NULL;
- m_installRequestMap = hashMap_create(string_hash, string_hash, string_equals, string_equals);
+ (*framework)->installRequestMap = hashMap_create(string_hash, string_hash, string_equals, string_equals);
+ (*framework)->serviceListeners = NULL;
+ (*framework)->shutdownGate = NULL;
}
}
}
@@ -244,7 +242,7 @@ celix_status_t fw_init(FRAMEWORK framewo
}
}
arrayList_destroy(archives);
- framework->registry = serviceRegistry_create(fw_serviceChanged);
+ framework->registry = serviceRegistry_create(framework, fw_serviceChanged);
framework_setBundleStateAndNotify(framework, framework->bundle, BUNDLE_STARTING);
@@ -289,7 +287,7 @@ celix_status_t fw_init(FRAMEWORK framewo
start(userData, bundle_getContext(framework->bundle));
}
- m_serviceListeners = arrayList_create();
+ framework->serviceListeners = arrayList_create();
framework_releaseBundleLock(framework, framework->bundle);
status = CELIX_SUCCESS;
@@ -900,7 +898,7 @@ bool framework_ungetService(FRAMEWORK fr
return serviceRegistry_ungetService(framework->registry, bundle, reference);
}
-void fw_addServiceListener(BUNDLE bundle, SERVICE_LISTENER listener, char * sfilter) {
+void fw_addServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener, char * sfilter) {
FW_SERVICE_LISTENER fwListener = (FW_SERVICE_LISTENER) malloc(sizeof(*fwListener));
fwListener->bundle = bundle;
if (sfilter != NULL) {
@@ -908,16 +906,16 @@ void fw_addServiceListener(BUNDLE bundle
fwListener->filter = filter;
}
fwListener->listener = listener;
- arrayList_add(m_serviceListeners, fwListener);
+ arrayList_add(framework->serviceListeners, fwListener);
}
-void fw_removeServiceListener(BUNDLE bundle, SERVICE_LISTENER listener) {
+void fw_removeServiceListener(FRAMEWORK framework, BUNDLE bundle, SERVICE_LISTENER listener) {
unsigned int i;
FW_SERVICE_LISTENER element;
- for (i = 0; i < arrayList_size(m_serviceListeners); i++) {
- element = (FW_SERVICE_LISTENER) arrayList_get(m_serviceListeners, i);
+ for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
+ element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
if (element->listener == listener && element->bundle == bundle) {
- arrayList_remove(m_serviceListeners, i);
+ arrayList_remove(framework->serviceListeners, i);
i--;
element->bundle = NULL;
filter_destroy(element->filter);
@@ -930,14 +928,14 @@ void fw_removeServiceListener(BUNDLE bun
}
}
-void fw_serviceChanged(SERVICE_EVENT event, PROPERTIES oldprops) {
+void fw_serviceChanged(FRAMEWORK framework, SERVICE_EVENT event, PROPERTIES oldprops) {
unsigned int i;
FW_SERVICE_LISTENER element;
SERVICE_REGISTRATION registration = event->reference->registration;
- if (arrayList_size(m_serviceListeners) > 0) {
- for (i = 0; i < arrayList_size(m_serviceListeners); i++) {
+ if (arrayList_size(framework->serviceListeners) > 0) {
+ for (i = 0; i < arrayList_size(framework->serviceListeners); i++) {
int matched = 0;
- element = (FW_SERVICE_LISTENER) arrayList_get(m_serviceListeners, i);
+ element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
matched = (element->filter == NULL) || filter_match(element->filter, registration->properties);
if (matched) {
element->listener->serviceChanged(element->listener, event);
@@ -1038,10 +1036,10 @@ BUNDLE framework_getBundleById(FRAMEWORK
celix_status_t framework_acquireInstallLock(FRAMEWORK framework, char * location) {
apr_thread_mutex_lock(framework->installRequestLock);
- while (hashMap_get(m_installRequestMap, location) != NULL) {
+ while (hashMap_get(framework->installRequestMap, location) != NULL) {
apr_thread_cond_wait(framework->condition, framework->installRequestLock);
}
- hashMap_put(m_installRequestMap, location, location);
+ hashMap_put(framework->installRequestMap, location, location);
apr_thread_mutex_unlock(framework->installRequestLock);
@@ -1051,7 +1049,7 @@ celix_status_t framework_acquireInstallL
celix_status_t framework_releaseInstallLock(FRAMEWORK framework, char * location) {
apr_thread_mutex_lock(framework->installRequestLock);
- hashMap_remove(m_installRequestMap, location);
+ hashMap_remove(framework->installRequestMap, location);
apr_thread_cond_broadcast(framework->condition);
apr_thread_mutex_unlock(framework->installRequestLock);
Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Mon May 30 06:34:09 2011
@@ -85,11 +85,12 @@ void serviceRegistry_flushUsageCount(SER
}
}
-SERVICE_REGISTRY serviceRegistry_create(void (*serviceChanged)(SERVICE_EVENT, PROPERTIES)) {
+SERVICE_REGISTRY serviceRegistry_create(FRAMEWORK framework, void (*serviceChanged)(FRAMEWORK, SERVICE_EVENT, PROPERTIES)) {
SERVICE_REGISTRY registry = (SERVICE_REGISTRY) malloc(sizeof(*registry));
registry->serviceChanged = serviceChanged;
registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
+ registry->framework = framework;
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
@@ -135,7 +136,7 @@ SERVICE_REGISTRATION serviceRegistry_reg
SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
event->type = REGISTERED;
event->reference = reg->reference;
- registry->serviceChanged(event, NULL);
+ registry->serviceChanged(registry->framework, event, NULL);
free(event);
event = NULL;
}
@@ -158,7 +159,7 @@ void serviceRegistry_unregisterService(S
SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
event->type = UNREGISTERING;
event->reference = registration->reference;
- registry->serviceChanged(event, NULL);
+ registry->serviceChanged(registry->framework, event, NULL);
free(event);
}
Modified: incubator/celix/trunk/launcher/launcher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/launcher.c?rev=1129004&r1=1129003&r2=1129004&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/launcher.c (original)
+++ incubator/celix/trunk/launcher/launcher.c Mon May 30 06:34:09 2011
@@ -69,7 +69,6 @@ int main(void) {
linkedList_addElement(bundles, location);
result = strtok(NULL, delims);
}
- // Update according to Felix Main
// First install all bundles
// Afterwards start them
ARRAY_LIST installed = arrayList_create();