Author: pnoltes
Date: Wed Jun 4 13:30:18 2014
New Revision: 1600201
URL: http://svn.apache.org/r1600201
Log:
CELIX-119: removed apr usage from service_registration
Modified:
incubator/celix/trunk/framework/private/include/service_registration_private.h
incubator/celix/trunk/framework/private/mock/service_registration_mock.c
incubator/celix/trunk/framework/private/src/service_registration.c
incubator/celix/trunk/framework/private/src/service_registry.c
incubator/celix/trunk/framework/public/include/service_registration.h
Modified:
incubator/celix/trunk/framework/private/include/service_registration_private.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registration_private.h?rev=1600201&r1=1600200&r2=1600201&view=diff
==============================================================================
---
incubator/celix/trunk/framework/private/include/service_registration_private.h
(original)
+++
incubator/celix/trunk/framework/private/include/service_registration_private.h
Wed Jun 4 13:30:18 2014
@@ -44,7 +44,7 @@ struct serviceRegistration {
void * svcObj;
long serviceId;
- apr_thread_mutex_t *mutex;
+ celix_thread_mutex_t mutex;
bool isUnregistering;
bool isServiceFactory;
Modified:
incubator/celix/trunk/framework/private/mock/service_registration_mock.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/service_registration_mock.c?rev=1600201&r1=1600200&r2=1600201&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/service_registration_mock.c
(original)
+++ incubator/celix/trunk/framework/private/mock/service_registration_mock.c
Wed Jun 4 13:30:18 2014
@@ -29,7 +29,6 @@
service_registration_pt serviceRegistration_create(service_registry_pt
registry, bundle_pt bundle, char * serviceName, long serviceId, void *
serviceObject, properties_pt dictionary) {
mock_c()->actualCall("serviceRegistration_create")
- ->withPointerParameters("pool", pool)
->withPointerParameters("registry", registry)
->withPointerParameters("bundle", bundle)
->withStringParameters("serviceName", serviceName)
@@ -39,9 +38,8 @@ service_registration_pt serviceRegistrat
return mock_c()->returnValue().value.pointerValue;
}
-service_registration_pt serviceRegistration_createServiceFactory(apr_pool_t
*pool, service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId, void * serviceObject, properties_pt dictionary) {
+service_registration_pt
serviceRegistration_createServiceFactory(service_registry_pt registry,
bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject,
properties_pt dictionary) {
mock_c()->actualCall("serviceRegistration_createServiceFactory")
- ->withPointerParameters("pool", pool)
->withPointerParameters("registry", registry)
->withPointerParameters("bundle", bundle)
->withStringParameters("serviceName", serviceName)
@@ -51,7 +49,8 @@ service_registration_pt serviceRegistrat
return mock_c()->returnValue().value.pointerValue;
}
-void serviceRegistration_destroy(service_registration_pt registration) {
+celix_status_t serviceRegistration_destroy(service_registration_pt
registration) {
+ return mock_c()->returnValue().value.intValue;
}
Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1600201&r1=1600200&r2=1600201&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c
(original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Wed Jun
4 13:30:18 2014
@@ -34,64 +34,72 @@
#include "service_factory.h"
#include "service_reference.h"
#include "celix_log.h"
+#include "celix_threads.h"
static celix_status_t
serviceRegistration_initializeProperties(service_registration_pt registration,
properties_pt properties);
-celix_status_t serviceRegistration_createInternal(apr_pool_t *pool,
service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId,
+celix_status_t serviceRegistration_createInternal(service_registry_pt
registry, bundle_pt bundle, char * serviceName, long serviceId,
void * serviceObject, properties_pt dictionary, bool isFactory,
service_registration_pt *registration);
-service_registration_pt serviceRegistration_create(apr_pool_t *pool,
service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId, void * serviceObject, properties_pt dictionary) {
+service_registration_pt serviceRegistration_create(service_registry_pt
registry, bundle_pt bundle, char * serviceName, long serviceId, void *
serviceObject, properties_pt dictionary) {
service_registration_pt registration = NULL;
- serviceRegistration_createInternal(pool, registry, bundle, serviceName,
serviceId, serviceObject, dictionary, false, ®istration);
+ serviceRegistration_createInternal(registry, bundle, serviceName,
serviceId, serviceObject, dictionary, false, ®istration);
return registration;
}
-service_registration_pt serviceRegistration_createServiceFactory(apr_pool_t
*pool, service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId, void * serviceObject, properties_pt dictionary) {
+service_registration_pt
serviceRegistration_createServiceFactory(service_registry_pt registry,
bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject,
properties_pt dictionary) {
service_registration_pt registration = NULL;
- serviceRegistration_createInternal(pool, registry, bundle, serviceName,
serviceId, serviceObject, dictionary, true, ®istration);
+ serviceRegistration_createInternal(registry, bundle, serviceName,
serviceId, serviceObject, dictionary, true, ®istration);
return registration;
}
-celix_status_t serviceRegistration_createInternal(apr_pool_t *pool,
service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId,
+celix_status_t serviceRegistration_createInternal(service_registry_pt
registry, bundle_pt bundle, char * serviceName, long serviceId,
void * serviceObject, properties_pt dictionary, bool isFactory,
service_registration_pt *registration) {
celix_status_t status = CELIX_SUCCESS;
- *registration = (service_registration_pt) apr_palloc(pool,
sizeof(**registration));
- (*registration)->isServiceFactory = isFactory;
- (*registration)->registry = registry;
- (*registration)->className = apr_pstrdup(pool,serviceName);
- (*registration)->bundle = bundle;
- (*registration)->references = NULL;
- arrayList_create(&(*registration)->references);
+ *registration = malloc(sizeof(**registration));
+ if (*registration) {
+ (*registration)->isServiceFactory = isFactory;
+ (*registration)->registry = registry;
+ (*registration)->className = strdup(serviceName);
+ (*registration)->bundle = bundle;
+ (*registration)->references = NULL;
+ arrayList_create(&(*registration)->references);
+
+ (*registration)->serviceId = serviceId;
+ (*registration)->svcObj = serviceObject;
+ if (isFactory) {
+ (*registration)->serviceFactory = (service_factory_pt)
(*registration)->svcObj;
+ } else {
+ (*registration)->serviceFactory = NULL;
+ }
- (*registration)->serviceId = serviceId;
- (*registration)->svcObj = serviceObject;
- if (isFactory) {
- (*registration)->serviceFactory = (service_factory_pt)
(*registration)->svcObj;
- } else {
- (*registration)->serviceFactory = NULL;
- }
+ // serviceReference_create(pool, bundle, *registration,
&(*registration)->reference);
-// serviceReference_create(pool, bundle, *registration,
&(*registration)->reference);
+ (*registration)->isUnregistering = false;
+ celixThreadMutex_create(&(*registration)->mutex, NULL);
- (*registration)->isUnregistering = false;
- apr_thread_mutex_create(&(*registration)->mutex, 0, pool);
-
- serviceRegistration_initializeProperties(*registration, dictionary);
+ serviceRegistration_initializeProperties(*registration,
dictionary);
+ } else {
+ status = CELIX_ENOMEM;
+ }
return CELIX_SUCCESS;
}
-void serviceRegistration_destroy(service_registration_pt registration) {
+celix_status_t serviceRegistration_destroy(service_registration_pt
registration) {
registration->className = NULL;
registration->registry = NULL;
properties_destroy(registration->properties);
arrayList_destroy(registration->references);
- apr_thread_mutex_destroy(registration->mutex);
+ celixThreadMutex_destroy(®istration->mutex);
+
+ free(registration->className);
+ free(registration);
-// free(registration);
+ return CELIX_SUCCESS;
}
static celix_status_t
serviceRegistration_initializeProperties(service_registration_pt registration,
properties_pt dictionary) {
@@ -116,21 +124,21 @@ bool serviceRegistration_isValid(service
}
void serviceRegistration_invalidate(service_registration_pt registration) {
- apr_thread_mutex_lock(registration->mutex);
+ celixThreadMutex_lock(®istration->mutex);
registration->svcObj = NULL;
- apr_thread_mutex_unlock(registration->mutex);
+ celixThreadMutex_unlock(®istration->mutex);
}
celix_status_t serviceRegistration_unregister(service_registration_pt
registration) {
celix_status_t status = CELIX_SUCCESS;
- apr_thread_mutex_lock(registration->mutex);
+ celixThreadMutex_lock(®istration->mutex);
if (!serviceRegistration_isValid(registration) ||
registration->isUnregistering) {
printf("Service is already unregistered\n");
status = CELIX_ILLEGAL_STATE;
} else {
registration->isUnregistering = true;
}
- apr_thread_mutex_unlock(registration->mutex);
+ celixThreadMutex_unlock(®istration->mutex);
// bundle_pt bundle = NULL;
// status = serviceReference_getBundle(registration->reference, &bundle);
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=1600201&r1=1600200&r2=1600201&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Wed Jun 4
13:30:18 2014
@@ -200,9 +200,9 @@ celix_status_t serviceRegistry_registerS
bundle_getMemoryPool(bundle, &pool);
if (isFactory) {
- *registration = serviceRegistration_createServiceFactory(pool,
registry, bundle, serviceName, ++registry->currentServiceId, serviceObject,
dictionary);
+ *registration = serviceRegistration_createServiceFactory(registry,
bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
} else {
- *registration = serviceRegistration_create(pool, registry, bundle,
serviceName, ++registry->currentServiceId, serviceObject, dictionary);
+ *registration = serviceRegistration_create(registry, bundle,
serviceName, ++registry->currentServiceId, serviceObject, dictionary);
}
serviceRegistry_addHooks(registry, serviceName, serviceObject,
*registration);
Modified: incubator/celix/trunk/framework/public/include/service_registration.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/service_registration.h?rev=1600201&r1=1600200&r2=1600201&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/service_registration.h
(original)
+++ incubator/celix/trunk/framework/public/include/service_registration.h Wed
Jun 4 13:30:18 2014
@@ -36,9 +36,9 @@ typedef struct serviceRegistration * ser
#include "bundle.h"
#include "framework_exports.h"
-service_registration_pt serviceRegistration_create(apr_pool_t *pool,
service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId, void * serviceObject, properties_pt dictionary);
-service_registration_pt serviceRegistration_createServiceFactory(apr_pool_t
*pool, service_registry_pt registry, bundle_pt bundle, char * serviceName, long
serviceId, void * serviceObject, properties_pt dictionary);
-void serviceRegistration_destroy(service_registration_pt registration);
+service_registration_pt serviceRegistration_create(service_registry_pt
registry, bundle_pt bundle, char * serviceName, long serviceId, void *
serviceObject, properties_pt dictionary);
+service_registration_pt
serviceRegistration_createServiceFactory(service_registry_pt registry,
bundle_pt bundle, char * serviceName, long serviceId, void * serviceObject,
properties_pt dictionary);
+celix_status_t serviceRegistration_destroy(service_registration_pt
registration);
FRAMEWORK_EXPORT bool serviceRegistration_isValid(service_registration_pt
registration);
FRAMEWORK_EXPORT void serviceRegistration_invalidate(service_registration_pt
registration);