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/12/18 13:02:02 UTC
svn commit: r1220372 - in /incubator/celix/trunk: ./ dependency_manager/
deployment_admin/private/src/ framework/private/include/
framework/private/src/ remote_services/discovery/private/src/
remote_services/topology_manager/private/src/
Author: abroekhuis
Date: Sun Dec 18 12:02:01 2011
New Revision: 1220372
URL: http://svn.apache.org/viewvc?rev=1220372&view=rev
Log:
APR and bug fixes
Modified:
incubator/celix/trunk/Hello World.launch
incubator/celix/trunk/Hello world Massif.launch
incubator/celix/trunk/Remote Services.launch
incubator/celix/trunk/dependency_manager/service_component.c
incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
incubator/celix/trunk/framework/private/include/framework.h
incubator/celix/trunk/framework/private/include/headers.h
incubator/celix/trunk/framework/private/include/manifest.h
incubator/celix/trunk/framework/private/include/service_reference.h
incubator/celix/trunk/framework/private/include/service_tracker.h
incubator/celix/trunk/framework/private/src/bundle.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/manifest.c
incubator/celix/trunk/framework/private/src/module.c
incubator/celix/trunk/framework/private/src/service_reference.c
incubator/celix/trunk/framework/private/src/service_registry.c
incubator/celix/trunk/framework/private/src/service_tracker.c
incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
Modified: incubator/celix/trunk/Hello World.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/Hello%20World.launch?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/Hello World.launch (original)
+++ incubator/celix/trunk/Hello World.launch Sun Dec 18 12:02:01 2011
@@ -29,7 +29,7 @@
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="element-next-header-capabilities-parser-manifestParser_getCapabilities-(cast)" val="CAPABILITY"/><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="componentData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="key-hashMapIterator_remove-(cast)" val="char *"/><content id="userData-userData-fw_startBundle-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="userData-data-bundleA
ctivator_start-(cast)" val="log_writer_t"/><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/></contentList>"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-data-bundleActivator_start-(cast)" val="log_writer_t"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-userData-fw_startBundle-(cast)" val="log_writer_t"/><content id="key-hashMapIterator_remove-(cast)" val="char *"/><content id="componentData-bundleActivator_create-(cast)" val=&quo
t;log_writer_t"/><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="element-next-header-capabilities-parser-manifestParser_getCapabilities-(cast)" val="CAPABILITY"/></contentList>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/launcher/launcher"/>
Modified: incubator/celix/trunk/Hello world Massif.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/Hello%20world%20Massif.launch?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/Hello world Massif.launch (original)
+++ incubator/celix/trunk/Hello world Massif.launch Sun Dec 18 12:02:01 2011
@@ -58,7 +58,7 @@
<intAttribute key="org.eclipse.linuxtools.valgrind.massif.MASSIF_PEAKINACCURACY" value="10"/>
<booleanAttribute key="org.eclipse.linuxtools.valgrind.massif.MASSIF_STACKS" value="false"/>
<intAttribute key="org.eclipse.linuxtools.valgrind.massif.MASSIF_THRESHOLD" value="10"/>
-<stringAttribute key="org.eclipse.linuxtools.valgrind.massif.MASSIF_TIMEUNIT" value="i"/>
+<stringAttribute key="org.eclipse.linuxtools.valgrind.massif.MASSIF_TIMEUNIT" value="B"/>
<booleanAttribute key="org.eclipse.linuxtools.valgrind.memcheck.MEMCHECK_ALIGNMENT_BOOL" value="false"/>
<intAttribute key="org.eclipse.linuxtools.valgrind.memcheck.MEMCHECK_ALIGNMENT_VAL" value="0"/>
<intAttribute key="org.eclipse.linuxtools.valgrind.memcheck.MEMCHECK_FREELIST" value="10000000"/>
Modified: incubator/celix/trunk/Remote Services.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/Remote%20Services.launch?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/Remote Services.launch (original)
+++ incubator/celix/trunk/Remote Services.launch Sun Dec 18 12:02:01 2011
@@ -29,7 +29,7 @@
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="ref-fw_addServiceListener-(cast)" val="SERVICE_REGISTRATION"/><content id="*elementData-elementData-listenerHooks-fw_addServiceListener-(cast)" val="listener_hook_service_t"/><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="*table-table-exportedServices-admin-activator-bundleActivator_stop-(cast_to_array)" val="0:1"/><content id="componentData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="key-hashMapIterator_remove-(cast)" val="char *"/><content id="userData-userData-f
w_startBundle-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="userData-data-bundleActivator_start-(cast)" val="log_writer_t"/><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/></contentList>"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="key-hashMap_getEntry-(cast)" val="SERVICE_REFERENCE"/><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="ref-fw_addServiceListener-(cast)" val="SERVICE_REGISTRATION"/><content id="*elementData-elementData-listenerHooks-fw_addServiceListener-(cast)" val="listener_hook_service_t"/><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="*table-table-exportedServices-admin-activator-bundleActivator_stop-(cast_to_array)" val="0:1"/><content id="componentData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="key-hashMapIte
rator_remove-(cast)" val="char *"/><content id="userData-userData-fw_startBundle-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="userData-data-bundleActivator_start-(cast)" val="log_writer_t"/><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/></contentList>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/launcher/launcher"/>
Modified: incubator/celix/trunk/dependency_manager/service_component.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_component.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_component.c (original)
+++ incubator/celix/trunk/dependency_manager/service_component.c Sun Dec 18 12:02:01 2011
@@ -332,7 +332,10 @@ void serviceComponent_destroyService(SER
serviceDependency_invokeRemoved(dependency);
}
}
+
arrayListIterator_destroy(i);
+
+ arrayList_destroy(service->dependencies);
}
void serviceComponent_registerService(SERVICE service) {
Modified: incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c (original)
+++ incubator/celix/trunk/deployment_admin/private/src/deployment_admin.c Sun Dec 18 12:02:01 2011
@@ -95,7 +95,7 @@ static void *APR_THREAD_FUNC deploymentA
extractBundle(test, tmpDir);
char *manifest = apr_pstrcat(admin->pool, tmpDir, "/META-INF/MANIFEST.MF", NULL);
MANIFEST mf = NULL;
- manifest_read(manifest, &mf);
+ manifest_createFromFile(admin->pool, manifest, &mf);
deployment_package_t source = NULL;
deploymentPackage_create(admin->pool, admin->context, mf, &source);
char *name = NULL;
Modified: incubator/celix/trunk/framework/private/include/framework.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework.h?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework.h (original)
+++ incubator/celix/trunk/framework/private/include/framework.h Sun Dec 18 12:02:01 2011
@@ -70,7 +70,7 @@ celix_status_t fw_isServiceAssignable(FR
//BUNDLE_ARCHIVE fw_createArchive(long id, char * location);
//void revise(BUNDLE_ARCHIVE archive, char * location);
-celix_status_t getManifest(BUNDLE_ARCHIVE archive, MANIFEST *manifest);
+celix_status_t getManifest(BUNDLE_ARCHIVE archive, apr_pool_t *pool, MANIFEST *manifest);
BUNDLE findBundle(BUNDLE_CONTEXT context);
SERVICE_REGISTRATION findRegistration(SERVICE_REFERENCE reference);
Modified: incubator/celix/trunk/framework/private/include/headers.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/headers.h?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/headers.h (original)
+++ incubator/celix/trunk/framework/private/include/headers.h Sun Dec 18 12:02:01 2011
@@ -175,11 +175,6 @@ struct serviceTrackerCustomizer {
typedef struct serviceTrackerCustomizer * SERVICE_TRACKER_CUSTOMIZER;
-struct serviceTracker {
- BUNDLE_CONTEXT context;
- char * filter;
-};
-
typedef struct serviceTracker * SERVICE_TRACKER;
#endif /* HEADERS_H_ */
Modified: incubator/celix/trunk/framework/private/include/manifest.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/manifest.h?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/manifest.h (original)
+++ incubator/celix/trunk/framework/private/include/manifest.h Sun Dec 18 12:02:01 2011
@@ -26,23 +26,27 @@
#ifndef MANIFEST_H_
#define MANIFEST_H_
+#include <apr_general.h>
+
#include "properties.h"
#include "celix_errno.h"
struct manifest {
+ apr_pool_t *pool;
PROPERTIES mainAttributes;
HASH_MAP attributes;
};
typedef struct manifest * MANIFEST;
-void manifest_destroy(MANIFEST manifest);
+celix_status_t manifest_create(apr_pool_t *pool, MANIFEST *manifest);
+celix_status_t manifest_createFromFile(apr_pool_t *pool, char *filename, MANIFEST *manifest);
void manifest_clear(MANIFEST manifest);
PROPERTIES manifest_getMainAttributes(MANIFEST manifest);
celix_status_t manifest_getEntries(MANIFEST manifest, HASH_MAP *map);
-celix_status_t manifest_read(char *filename, MANIFEST *manifest);
+celix_status_t manifest_read(MANIFEST manifest, char *filename);
void manifest_write(MANIFEST manifest, char * filename);
char * manifest_getValue(MANIFEST manifest, const char * name);
Modified: incubator/celix/trunk/framework/private/include/service_reference.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_reference.h?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_reference.h (original)
+++ incubator/celix/trunk/framework/private/include/service_reference.h Sun Dec 18 12:02:01 2011
@@ -40,5 +40,7 @@ bool serviceReference_isAssignableTo(SER
celix_status_t serviceReference_getUsingBundles(SERVICE_REFERENCE reference, apr_pool_t *pool, ARRAY_LIST *bundles);
celix_status_t serviceReference_equals(SERVICE_REFERENCE reference, SERVICE_REFERENCE compareTo, bool *equal);
+unsigned int serviceReference_hashCode(void *referenceP);
+int serviceReference_equals2(void *reference1, void *reference2);
#endif /* SERVICE_REFERENCE_H_ */
Modified: incubator/celix/trunk/framework/private/include/service_tracker.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_tracker.h?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_tracker.h (original)
+++ incubator/celix/trunk/framework/private/include/service_tracker.h Sun Dec 18 12:02:01 2011
@@ -61,6 +61,4 @@ void * tracker_getServiceByReference(SER
void tracker_serviceChanged(SERVICE_LISTENER listener, SERVICE_EVENT event);
-FW_SERVICE_TRACKER findFwServiceTracker(SERVICE_TRACKER tracker);
-
#endif /* SERVICE_TRACKER_H_ */
Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Sun Dec 18 12:02:01 2011
@@ -202,7 +202,7 @@ celix_status_t bundle_setManifest(BUNDLE
celix_status_t bundle_createModule(BUNDLE bundle, MODULE *module) {
celix_status_t status = CELIX_SUCCESS;
MANIFEST headerMap = NULL;
- status = getManifest(bundle->archive, &headerMap);
+ status = getManifest(bundle->archive, bundle->memoryPool, &headerMap);
if (status == CELIX_SUCCESS) {
long bundleId;
status = bundleArchive_getId(bundle->archive, &bundleId);
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Sun Dec 18 12:02:01 2011
@@ -205,7 +205,9 @@ celix_status_t framework_destroy(FRAMEWO
arrayList_destroy(framework->globalLockWaitersList);
arrayList_destroy(framework->serviceListeners);
- //bundleCache_destroy(framework->cache);
+ hashMap_destroy(framework->installedBundleMap, false, false);
+
+ bundleCache_destroy(framework->cache);
apr_pool_destroy(framework->mp);
@@ -541,7 +543,7 @@ celix_status_t fw_startBundle(FRAMEWORK
MANIFEST manifest = NULL;
char *library;
- if (getManifest(bundle_getArchive(bundle), &manifest) == CELIX_SUCCESS) {
+ if (getManifest(bundle_getArchive(bundle), bundle->memoryPool, &manifest) == CELIX_SUCCESS) {
bundle_setManifest(bundle, manifest);
library = manifest_getValue(manifest, HEADER_LIBRARY);
}
@@ -745,8 +747,6 @@ celix_status_t fw_stopBundle(FRAMEWORK f
MANIFEST manifest = NULL;
bundle_getManifest(bundle, &manifest);
- manifest_destroy(manifest);
-
framework_setBundleStateAndNotify(framework, bundle, BUNDLE_RESOLVED);
framework_releaseBundleLock(framework, bundle);
@@ -1199,10 +1199,13 @@ void fw_serviceChanged(FRAMEWORK framewo
element = (FW_SERVICE_LISTENER) arrayList_get(framework->serviceListeners, i);
matched = (element->filter == NULL) || filter_match(element->filter, registration->properties);
if (matched) {
+ apr_pool_t *spool = NULL;
+ apr_pool_create(&spool, element->listener->pool);
+
SERVICE_REFERENCE reference = NULL;
- SERVICE_EVENT event = (SERVICE_EVENT) apr_palloc(element->listener->pool, sizeof(*event));
+ SERVICE_EVENT event = (SERVICE_EVENT) apr_palloc(spool, sizeof(*event));
- serviceRegistry_createServiceReference(framework->registry, element->listener->pool, registration, &reference);
+ serviceRegistry_createServiceReference(framework->registry, spool, registration, &reference);
event->type = eventType;
event->reference = reference;
@@ -1241,7 +1244,7 @@ void fw_serviceChanged(FRAMEWORK framewo
// return status;
//}
-celix_status_t getManifest(BUNDLE_ARCHIVE archive, MANIFEST *manifest) {
+celix_status_t getManifest(BUNDLE_ARCHIVE archive, apr_pool_t *pool, MANIFEST *manifest) {
celix_status_t status = CELIX_SUCCESS;
char mf[256];
long refreshCount;
@@ -1260,7 +1263,7 @@ celix_status_t getManifest(BUNDLE_ARCHIV
refreshCount,
revisionNumber
);
- status = manifest_read(mf, manifest);
+ status = manifest_createFromFile(pool, mf, manifest);
}
}
}
Modified: incubator/celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest.c Sun Dec 18 12:02:01 2011
@@ -32,6 +32,46 @@
int fpeek(FILE *stream);
celix_status_t manifest_readAttributes(MANIFEST manifest, PROPERTIES properties, FILE *file);
+apr_status_t manifest_destroy(void *manifestP);
+
+celix_status_t manifest_create(apr_pool_t *pool, MANIFEST *manifest) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ *manifest = apr_palloc(pool, sizeof(**manifest));
+ if (!*manifest) {
+ status = CELIX_ENOMEM;
+ } else {
+ apr_pool_pre_cleanup_register(pool, *manifest, manifest_destroy);
+ (*manifest)->pool = pool;
+ (*manifest)->mainAttributes = properties_create();
+ (*manifest)->attributes = hashMap_create(string_hash, NULL, string_equals, NULL);
+ }
+
+ return status;
+}
+
+apr_status_t manifest_destroy(void *manifestP) {
+ MANIFEST manifest = manifestP;
+ if (manifest != NULL) {
+ properties_destroy(manifest->mainAttributes);
+ hashMap_destroy(manifest->attributes, false, false);
+ manifest->mainAttributes = NULL;
+ manifest->attributes = NULL;
+ manifest = NULL;
+ }
+ return APR_SUCCESS;
+}
+
+celix_status_t manifest_createFromFile(apr_pool_t *pool, char *filename, MANIFEST *manifest) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ status = manifest_create(pool, manifest);
+ if (status == CELIX_SUCCESS) {
+ manifest_read(*manifest, filename);
+ }
+
+ return status;
+}
void manifest_clear(MANIFEST manifest) {
@@ -46,110 +86,90 @@ celix_status_t manifest_getEntries(MANIF
return CELIX_SUCCESS;
}
-celix_status_t manifest_read(char *filename, MANIFEST *manifest) {
+celix_status_t manifest_read(MANIFEST manifest, char *filename) {
celix_status_t status = CELIX_SUCCESS;
- MANIFEST mf = NULL;
- mf = (MANIFEST) malloc(sizeof(*mf));
- if (mf != NULL) {
- mf->mainAttributes = properties_create();
- mf->attributes = hashMap_create(string_hash, NULL, string_equals, NULL);
-
- FILE *file = fopen ( filename, "r" );
- if (file != NULL) {
- char lbuf[512];
- manifest_readAttributes(mf, mf->mainAttributes, file);
-
- int len;
- char * name = NULL;
- bool skipEmptyLines = true;
- char * lastline;
-
- while (fgets(lbuf, sizeof(lbuf), file) != NULL ) {
- len = strlen(lbuf);
- if (lbuf[--len] != '\n') {
- printf("MANIFEST: Line too long\n");
+ FILE *file = fopen ( filename, "r" );
+ if (file != NULL) {
+ char lbuf[512];
+ manifest_readAttributes(manifest, manifest->mainAttributes, file);
+
+ int len;
+ char * name = NULL;
+ bool skipEmptyLines = true;
+ char * lastline;
+
+ while (fgets(lbuf, sizeof(lbuf), file) != NULL ) {
+ len = strlen(lbuf);
+ if (lbuf[--len] != '\n') {
+ printf("MANIFEST: Line too long\n");
+ return CELIX_FILE_IO_EXCEPTION;
+ }
+ if (len > 0 && lbuf[len - 1] == '\r') {
+ --len;
+ }
+ if (len == 0 && skipEmptyLines) {
+ continue;
+ }
+ skipEmptyLines = false;
+
+ if (name == NULL) {
+ if ((tolower(lbuf[0]) == 'n') && (tolower(lbuf[1]) == 'a') &&
+ (tolower(lbuf[2]) == 'm') && (tolower(lbuf[3]) == 'e') &&
+ (lbuf[4] == ':') && (lbuf[5] == ' ')) {
+ name = (char *) malloc((len + 1) - 6);
+ name = strncpy(name, lbuf+6, len - 6);
+ name[len - 6] = '\0';
+ } else {
+ printf("MANIFEST: Invalid manifest format\n");
return CELIX_FILE_IO_EXCEPTION;
}
- if (len > 0 && lbuf[len - 1] == '\r') {
- --len;
- }
- if (len == 0 && skipEmptyLines) {
+
+ if (fpeek(file) == ' ') {
+ int newlen = len - 6;
+ lastline = (char *) malloc(newlen + 1);
+ lastline = strncpy(lastline, lbuf+6, len - 6);
+ lastline[newlen] = '\0';
continue;
}
- skipEmptyLines = false;
-
- if (name == NULL) {
- if ((tolower(lbuf[0]) == 'n') && (tolower(lbuf[1]) == 'a') &&
- (tolower(lbuf[2]) == 'm') && (tolower(lbuf[3]) == 'e') &&
- (lbuf[4] == ':') && (lbuf[5] == ' ')) {
- name = (char *) malloc((len + 1) - 6);
- name = strncpy(name, lbuf+6, len - 6);
- name[len - 6] = '\0';
- } else {
- printf("MANIFEST: Invalid manifest format\n");
- return CELIX_FILE_IO_EXCEPTION;
- }
-
- if (fpeek(file) == ' ') {
- int newlen = len - 6;
- lastline = (char *) malloc(newlen + 1);
- lastline = strncpy(lastline, lbuf+6, len - 6);
- lastline[newlen] = '\0';
- continue;
- }
- } else {
- int newlen = strlen(lastline) + len;
- char buf[newlen];
- strcpy(buf, lastline);
- strncat(buf, lbuf+1, len - 1);
- buf[newlen] = '\0';
-
- if (fpeek(file) == ' ') {
- lastline = realloc(lastline, strlen(buf) + 1);
- lastline = strcpy(lastline, buf);
- continue;
- }
- name = (char *) malloc(strlen(buf) + 1);
- name = strcpy(name, buf);
- name[strlen(buf)] = '\0';
- lastline = NULL;
+ } else {
+ int newlen = strlen(lastline) + len;
+ char buf[newlen];
+ strcpy(buf, lastline);
+ strncat(buf, lbuf+1, len - 1);
+ buf[newlen] = '\0';
+
+ if (fpeek(file) == ' ') {
+ lastline = realloc(lastline, strlen(buf) + 1);
+ lastline = strcpy(lastline, buf);
+ continue;
}
+ name = (char *) malloc(strlen(buf) + 1);
+ name = strcpy(name, buf);
+ name[strlen(buf)] = '\0';
+ lastline = NULL;
+ }
- PROPERTIES attributes = hashMap_get(mf->attributes, name);
- if (attributes == NULL) {
- attributes = properties_create();
- hashMap_put(mf->attributes, strdup(name), attributes);
- }
- manifest_readAttributes(mf, attributes, file);
+ PROPERTIES attributes = hashMap_get(manifest->attributes, name);
+ if (attributes == NULL) {
+ attributes = properties_create();
+ hashMap_put(manifest->attributes, strdup(name), attributes);
+ }
+ manifest_readAttributes(manifest, attributes, file);
- free(name);
- name = NULL;
- skipEmptyLines = true;
- }
- fclose(file);
-
- *manifest = mf;
- } else {
- printf("Could not read manifest file.\n");
- status = CELIX_FILE_IO_EXCEPTION;
- }
+ free(name);
+ name = NULL;
+ skipEmptyLines = true;
+ }
+ fclose(file);
} else {
- status = CELIX_ENOMEM;
+ printf("Could not read manifest file.\n");
+ status = CELIX_FILE_IO_EXCEPTION;
}
return status;
}
-void manifest_destroy(MANIFEST manifest) {
- if (manifest != NULL) {
- properties_destroy(manifest->mainAttributes);
- manifest->mainAttributes = NULL;
- free(manifest);
- manifest = NULL;
- }
-}
-
void manifest_write(MANIFEST manifest, char * filename) {
}
@@ -207,6 +227,7 @@ celix_status_t manifest_readAttributes(M
}
value = (char *) malloc(strlen(buf) + 1);
value = strcpy(value, buf);
+ free(lastLine);
lastLine = NULL;
} else {
while (lbuf[i++] != ':') {
Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Sun Dec 18 12:02:01 2011
@@ -133,9 +133,6 @@ void module_destroy(MODULE module) {
arrayList_destroy(module->dependentImporters);
- if (module->headerMap != NULL) {
- manifest_destroy(module->headerMap);
- }
module->headerMap = NULL;
}
Modified: incubator/celix/trunk/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_reference.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_reference.c (original)
+++ incubator/celix/trunk/framework/private/src/service_reference.c Sun Dec 18 12:02:01 2011
@@ -56,7 +56,6 @@ celix_status_t serviceReference_create(a
apr_status_t serviceReference_destroy(void *referenceP) {
SERVICE_REFERENCE reference = referenceP;
- printf("SERVICE_REFERENCE: Destroy\n");
reference->bundle = NULL;
reference->registration = NULL;
return APR_SUCCESS;
@@ -113,3 +112,24 @@ celix_status_t serviceReference_equals(S
return CELIX_SUCCESS;
}
+int serviceReference_equals2(void *reference1, void *reference2) {
+ bool equal;
+ serviceReference_equals(reference1, reference2, &equal);
+ return equal;
+}
+
+unsigned int serviceReference_hashCode(void *referenceP) {
+ SERVICE_REFERENCE reference = referenceP;
+ int prime = 31;
+ int result = 1;
+ result = prime * result;
+
+ if (reference != NULL) {
+ intptr_t bundleA = (intptr_t) reference->bundle;
+ intptr_t registrationA = (intptr_t) reference->registration;
+
+ result += bundleA + registrationA;
+ }
+ return result;
+}
+
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=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Sun Dec 18 12:02:01 2011
@@ -333,46 +333,12 @@ apr_status_t serviceRegistry_removeRefer
serviceReference_getServiceRegistration(reference, ®istration);
if (registration != NULL) {
- printf("SERVICE_REGISTRY: Destroy: %s\n", registration->className);
arrayList_removeElement(registration->references, reference);
}
return APR_SUCCESS;
}
-//ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, const char * serviceName, FILTER filter) {
-// ARRAY_LIST references = NULL;
-// arrayList_create(registry->framework->mp, &references);
-//
-// HASH_MAP_VALUES registrations = hashMapValues_create(registry->serviceRegistrations);
-// HASH_MAP_ITERATOR iterator = hashMapValues_iterator(registrations);
-// while (hashMapIterator_hasNext(iterator)) {
-// ARRAY_LIST regs = (ARRAY_LIST) hashMapIterator_nextValue(iterator);
-// int regIdx;
-// for (regIdx = 0; (regs != NULL) && regIdx < arrayList_size(regs); regIdx++) {
-// SERVICE_REGISTRATION registration = (SERVICE_REGISTRATION) arrayList_get(regs, regIdx);
-//
-// bool matched = false;
-// if ((serviceName == NULL) && ((filter == NULL) || filter_match(filter, registration->properties))) {
-// matched = true;
-// } else if (serviceName != NULL) {
-// if ((strcmp(registration->className, serviceName) == 0) && ((filter == NULL) || filter_match(filter, registration->properties))) {
-// matched = true;
-// }
-// }
-// if (matched) {
-// if (serviceRegistration_isValid(registration)) {
-// arrayList_add(references, registration->reference);
-// }
-// }
-// }
-// }
-// hashMapIterator_destroy(iterator);
-// hashMapValues_destroy(registrations);
-//
-// return references;
-//}
-
ARRAY_LIST serviceRegistry_getServicesInUse(SERVICE_REGISTRY registry, BUNDLE bundle) {
ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
if (usages != NULL) {
Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Sun Dec 18 12:02:01 2011
@@ -30,8 +30,15 @@
#include "constants.h"
#include "service_reference.h"
+struct serviceTracker {
+ BUNDLE_CONTEXT context;
+ char * filter;
+
+ FW_SERVICE_TRACKER fwTracker;
+};
+
// #todo: Remove this, make SERVICE_TRACKER an ADT to keep "hidden" information
-ARRAY_LIST m_trackers;
+//ARRAY_LIST m_trackers;
void * addingService(FW_SERVICE_TRACKER, SERVICE_REFERENCE);
celix_status_t serviceTracker_track(FW_SERVICE_TRACKER, SERVICE_REFERENCE, SERVICE_EVENT);
@@ -72,9 +79,9 @@ celix_status_t tracker_createWithFilter(
apr_pool_t *pool;
bundleContext_getMemoryPool(context, &pool);
- if (m_trackers == NULL) {
- arrayList_create(pool, &m_trackers);
- }
+// if (m_trackers == NULL) {
+// arrayList_create(pool, &m_trackers);
+// }
(*tracker)->context = context;
(*tracker)->filter = filter;
@@ -84,7 +91,9 @@ celix_status_t tracker_createWithFilter(
arrayList_create(pool, &fw_tracker->tracked);
fw_tracker->customizer = customizer;
- arrayList_add(m_trackers, fw_tracker);
+ (*tracker)->fwTracker = fw_tracker;
+
+// arrayList_add(m_trackers, fw_tracker);
return CELIX_SUCCESS;
}
@@ -92,7 +101,7 @@ celix_status_t tracker_createWithFilter(
celix_status_t serviceTracker_open(SERVICE_TRACKER tracker) {
celix_status_t status = CELIX_SUCCESS;
SERVICE_LISTENER listener = (SERVICE_LISTENER) malloc(sizeof(*listener));
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+// FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
ARRAY_LIST initial = NULL;
status = bundleContext_getServiceReferences(tracker->context, NULL, tracker->filter, &initial);
@@ -100,15 +109,16 @@ celix_status_t serviceTracker_open(SERVI
SERVICE_REFERENCE initial_reference;
unsigned int i;
- listener->pool = fwTracker->pool;
+ listener->pool = tracker->fwTracker->pool;
+ listener->handle = tracker;
listener->serviceChanged = (void *) tracker_serviceChanged;
status = bundleContext_addServiceListener(tracker->context, listener, tracker->filter);
if (status == CELIX_SUCCESS) {
- fwTracker->listener = listener;
+ tracker->fwTracker->listener = listener;
for (i = 0; i < arrayList_size(initial); i++) {
initial_reference = (SERVICE_REFERENCE) arrayList_get(initial, i);
- serviceTracker_track(fwTracker, initial_reference, NULL);
+ serviceTracker_track(tracker->fwTracker, initial_reference, NULL);
}
arrayList_clear(initial);
arrayList_destroy(initial);
@@ -123,7 +133,7 @@ celix_status_t serviceTracker_open(SERVI
celix_status_t serviceTracker_close(SERVICE_TRACKER tracker) {
celix_status_t status = CELIX_SUCCESS;
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
status = bundleContext_removeServiceListener(tracker->context, fwTracker->listener);
if (status == CELIX_SUCCESS) {
ARRAY_LIST refs = tracker_getServiceReferences(tracker);
@@ -141,9 +151,10 @@ celix_status_t serviceTracker_close(SERV
}
void tracker_destroy(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
bundleContext_removeServiceListener(tracker->context, fwTracker->listener);
- arrayList_destroy(m_trackers);
+// arrayList_destroy(m_trackers);
+ arrayList_destroy(fwTracker->tracked);
free(fwTracker->listener);
free(fwTracker);
tracker = NULL;
@@ -151,7 +162,7 @@ void tracker_destroy(SERVICE_TRACKER tra
}
SERVICE_REFERENCE tracker_getServiceReference(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
TRACKED tracked;
unsigned int i;
for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
@@ -162,7 +173,7 @@ SERVICE_REFERENCE tracker_getServiceRefe
}
ARRAY_LIST tracker_getServiceReferences(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
int size = arrayList_size(fwTracker->tracked);
ARRAY_LIST references = NULL;
arrayList_create(fwTracker->pool, &references);
@@ -176,7 +187,7 @@ ARRAY_LIST tracker_getServiceReferences(
}
void * tracker_getService(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
TRACKED tracked;
unsigned int i;
if (fwTracker != NULL) {
@@ -189,7 +200,7 @@ void * tracker_getService(SERVICE_TRACKE
}
ARRAY_LIST tracker_getServices(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
int size = arrayList_size(fwTracker->tracked);
ARRAY_LIST references = NULL;
arrayList_create(fwTracker->pool, &references);
@@ -203,7 +214,7 @@ ARRAY_LIST tracker_getServices(SERVICE_T
}
void * tracker_getServiceByReference(SERVICE_TRACKER tracker, SERVICE_REFERENCE reference) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ FW_SERVICE_TRACKER fwTracker = tracker->fwTracker;
TRACKED tracked;
unsigned int i;
for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
@@ -218,24 +229,17 @@ void * tracker_getServiceByReference(SER
}
void tracker_serviceChanged(SERVICE_LISTENER listener, SERVICE_EVENT event) {
- FW_SERVICE_TRACKER fwTracker;
- unsigned int i;
- for (i = 0; i < arrayList_size(m_trackers); i++) {
- fwTracker = (FW_SERVICE_TRACKER) arrayList_get(m_trackers, i);
- if (fwTracker->listener == listener) {
- switch (event->type) {
- case REGISTERED:
- case MODIFIED:
- serviceTracker_track(fwTracker, event->reference, event);
- break;
- case UNREGISTERING:
- serviceTracker_untrack(fwTracker, event->reference, event);
- break;
- case MODIFIED_ENDMATCH:
- break;
- }
+ SERVICE_TRACKER tracker = listener->handle;
+ switch (event->type) {
+ case REGISTERED:
+ case MODIFIED:
+ serviceTracker_track(tracker->fwTracker, event->reference, event);
+ break;
+ case UNREGISTERING:
+ serviceTracker_untrack(tracker->fwTracker, event->reference, event);
+ break;
+ case MODIFIED_ENDMATCH:
break;
- }
}
}
@@ -318,16 +322,16 @@ celix_status_t serviceTracker_untrack(FW
return status;
}
-FW_SERVICE_TRACKER findFwServiceTracker(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker;
- unsigned int i;
- if (m_trackers != NULL) {
- for (i = 0; i < arrayList_size(m_trackers); i++) {
- fwTracker = (FW_SERVICE_TRACKER) arrayList_get(m_trackers, i);
- if (fwTracker->tracker == tracker) {
- return fwTracker;
- }
- }
- }
- return NULL;
-}
+//FW_SERVICE_TRACKER findFwServiceTracker(SERVICE_TRACKER tracker) {
+// FW_SERVICE_TRACKER fwTracker;
+// unsigned int i;
+// if (m_trackers != NULL) {
+// for (i = 0; i < arrayList_size(m_trackers); i++) {
+// fwTracker = (FW_SERVICE_TRACKER) arrayList_get(m_trackers, i);
+// if (fwTracker->tracker == tracker) {
+// return fwTracker;
+// }
+// }
+// }
+// return NULL;
+//}
Modified: incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ incubator/celix/trunk/remote_services/discovery/private/src/discovery.c Sun Dec 18 12:02:01 2011
@@ -66,7 +66,7 @@ celix_status_t discovery_create(apr_pool
} else {
(*discovery)->context = context;
(*discovery)->pool = pool;
- (*discovery)->listenerReferences = hashMap_create(NULL, NULL, NULL, NULL);
+ (*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
(*discovery)->slpServices = hashMap_create(string_hash, NULL, string_equals, NULL);
(*discovery)->running = true;
(*discovery)->rsaPort = getenv("RSA_PORT");
Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1220372&r1=1220371&r2=1220372&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c Sun Dec 18 12:02:01 2011
@@ -55,7 +55,7 @@ celix_status_t topologyManager_create(BU
(*manager)->context = context;
(*manager)->rsaList = NULL;
arrayList_create(pool, &(*manager)->rsaList);
- (*manager)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
+ (*manager)->exportedServices = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL);
(*manager)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
(*manager)->importInterests = hashMap_create(string_hash, NULL, string_equals, NULL);
}