Author: abroekhuis
Date: Tue Oct 18 11:24:15 2011
New Revision: 1185583
URL: http://svn.apache.org/viewvc?rev=1185583&view=rev
Log:
Several small fixes and changes
Added:
incubator/celix/trunk/shell/inspect_command.c
incubator/celix/trunk/shell/inspect_command.h
Modified:
incubator/celix/trunk/cmake/run.sh.in
incubator/celix/trunk/dependency_manager/service_dependency.c
incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
incubator/celix/trunk/examples/sender/test_activator.c
incubator/celix/trunk/examples/whiteboard/tracker/activator.c
incubator/celix/trunk/framework/private/include/bundle.h
incubator/celix/trunk/framework/private/include/bundle_context.h
incubator/celix/trunk/framework/private/include/framework.h
incubator/celix/trunk/framework/private/include/headers.h
incubator/celix/trunk/framework/private/include/service_registration.h
incubator/celix/trunk/framework/private/include/service_registry.h
incubator/celix/trunk/framework/private/include/service_tracker.h
incubator/celix/trunk/framework/private/src/bundle.c
incubator/celix/trunk/framework/private/src/bundle_context.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/service_registration.c
incubator/celix/trunk/framework/private/src/service_registry.c
incubator/celix/trunk/framework/private/src/service_tracker.c
incubator/celix/trunk/launcher/launcher.c
incubator/celix/trunk/log_service/private/src/log_service_activator.c
incubator/celix/trunk/shell/CMakeLists.txt
incubator/celix/trunk/shell/shell.c
incubator/celix/trunk/shell/start_command.c
incubator/celix/trunk/shell/stop_command.c
Modified: incubator/celix/trunk/cmake/run.sh.in
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/cmake/run.sh.in?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/cmake/run.sh.in (original)
+++ incubator/celix/trunk/cmake/run.sh.in Tue Oct 18 11:24:15 2011
@@ -1,2 +1,2 @@
-@LIBRARY_PATH@=@FW_PATH@:@UTILS_PATH@
+export @LIBRARY_PATH@=@FW_PATH@:@UTILS_PATH@
@LAUNCHER@
\ No newline at end of file
Modified: incubator/celix/trunk/dependency_manager/service_dependency.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_dependency.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_dependency.c (original)
+++ incubator/celix/trunk/dependency_manager/service_dependency.c Tue Oct 18
11:24:15 2011
@@ -30,10 +30,10 @@
#include "bundle_context.h"
#include "constants.h"
-void * serviceDependency_addingService(void * handle, SERVICE_REFERENCE
reference);
-void serviceDependency_addedService(void * handle, SERVICE_REFERENCE
reference, void * service);
-void serviceDependency_modifiedService(void * handle, SERVICE_REFERENCE
reference, void * service);
-void serviceDependency_removedService(void * handle, SERVICE_REFERENCE
reference, void * service);
+celix_status_t serviceDependency_addingService(void * handle,
SERVICE_REFERENCE reference, void **service);
+celix_status_t serviceDependency_addedService(void * handle, SERVICE_REFERENCE
reference, void * service);
+celix_status_t serviceDependency_modifiedService(void * handle,
SERVICE_REFERENCE reference, void * service);
+celix_status_t serviceDependency_removedService(void * handle,
SERVICE_REFERENCE reference, void * service);
SERVICE_DEPENDENCY serviceDependency_create(BUNDLE_CONTEXT context) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY)
malloc(sizeof(*dependency));
@@ -82,29 +82,28 @@ void serviceDependency_start(SERVICE_DEP
if (dependency->trackedServiceFilter != NULL) {
tracker_createWithFilter(dependency->context,
dependency->trackedServiceFilter, cust, &dependency->tracker);
} else if (dependency->trackedServiceName != NULL) {
- tracker_create(dependency->context,
dependency->trackedServiceName, cust, &dependency->tracker);
+ serviceTracker_create(dependency->context,
dependency->trackedServiceName, cust, &dependency->tracker);
} else {
}
dependency->started = true;
- tracker_open(dependency->tracker);
+ serviceTracker_open(dependency->tracker);
}
void serviceDependency_stop(SERVICE_DEPENDENCY dependency, SERVICE service) {
dependency->started = true;
- tracker_close(dependency->tracker);
+ serviceTracker_close(dependency->tracker);
}
-void * serviceDependency_addingService(void * handle, SERVICE_REFERENCE
reference) {
+celix_status_t serviceDependency_addingService(void * handle,
SERVICE_REFERENCE reference, void **service) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) handle;
- void * service = NULL;
- bundleContext_getService(dependency->context, reference, &service);
+ bundleContext_getService(dependency->context, reference, service);
dependency->reference = reference;
- dependency->serviceInstance = service;
- return service;
+ dependency->serviceInstance = *service;
+ return CELIX_SUCCESS;
}
-void serviceDependency_addedService(void * handle, SERVICE_REFERENCE
reference, void * service) {
+celix_status_t serviceDependency_addedService(void * handle, SERVICE_REFERENCE
reference, void * service) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) handle;
if (!dependency->available) {
dependency->available = true;
@@ -115,6 +114,7 @@ void serviceDependency_addedService(void
if (!dependency->required && dependency->added != NULL) {
dependency->added(dependency->service->impl, reference,
service);
}
+ return CELIX_SUCCESS;
}
void serviceDependency_invokeAdded(SERVICE_DEPENDENCY dependency) {
@@ -123,7 +123,7 @@ void serviceDependency_invokeAdded(SERVI
}
}
-void serviceDependency_modifiedService(void * handle, SERVICE_REFERENCE
reference, void * service) {
+celix_status_t serviceDependency_modifiedService(void * handle,
SERVICE_REFERENCE reference, void * service) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) handle;
dependency->reference = reference;
dependency->serviceInstance = service;
@@ -132,9 +132,10 @@ void serviceDependency_modifiedService(v
if (dependency->service->registered && dependency->changed != NULL) {
dependency->changed(dependency->service->impl, reference,
service);
}
+ return CELIX_SUCCESS;
}
-void serviceDependency_removedService(void * handle, SERVICE_REFERENCE
reference, void * service) {
+celix_status_t serviceDependency_removedService(void * handle,
SERVICE_REFERENCE reference, void * service) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) handle;
if (dependency->available && tracker_getService(dependency->tracker) ==
NULL) {
dependency->available = false;
@@ -147,6 +148,7 @@ void serviceDependency_removedService(vo
bool result;
bundleContext_ungetService(dependency->context, reference, &result);
+ return CELIX_SUCCESS;
}
void serviceDependency_invokeRemoved(SERVICE_DEPENDENCY dependency) {
Modified:
incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
(original)
+++ incubator/celix/trunk/examples/echo_service/client/echo_client_activator.c
Tue Oct 18 11:24:15 2011
@@ -50,21 +50,21 @@ celix_status_t bundleActivator_start(voi
struct echoActivator * act = (struct echoActivator *) userData;
SERVICE_TRACKER tracker = NULL;
- tracker_create(context, ECHO_SERVICE_NAME, NULL, &tracker);
+ serviceTracker_create(context, ECHO_SERVICE_NAME, NULL, &tracker);
act->tracker = tracker;
ECHO_CLIENT client = echoClient_create(tracker);
act->client = client;
echoClient_start(act->client);
- tracker_open(act->tracker);
+ serviceTracker_open(act->tracker);
return CELIX_SUCCESS;
}
celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
struct echoActivator * act = (struct echoActivator *) userData;
- tracker_close(act->tracker);
+ serviceTracker_close(act->tracker);
echoClient_stop(act->client);
return CELIX_SUCCESS;
Modified:
incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
---
incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
(original)
+++
incubator/celix/trunk/examples/osgi-in-action/chapter04-paint-example/paint/private/src/activator.c
Tue Oct 18 11:24:15 2011
@@ -37,10 +37,10 @@ struct paintFrameActivatorData {
BUNDLE_CONTEXT context;
PAINT_FRAME paint_frame;
};
-void *addingServ(void * handle, SERVICE_REFERENCE reference);
-void addedServ(void * handle, SERVICE_REFERENCE reference, void * service);
-void modifiedServ(void * handle, SERVICE_REFERENCE reference, void * service);
-void removedServ(void * handle, SERVICE_REFERENCE reference, void * service);
+celix_status_t addingServ(void * handle, SERVICE_REFERENCE ref, void
**service);
+celix_status_t addedServ(void * handle, SERVICE_REFERENCE reference, void *
service);
+celix_status_t modifiedServ(void * handle, SERVICE_REFERENCE reference, void *
service);
+celix_status_t removedServ(void * handle, SERVICE_REFERENCE reference, void *
service);
typedef struct paintFrameActivatorData *GREETING_ACTIVATOR;
@@ -63,8 +63,8 @@ celix_status_t bundleActivator_create(BU
cust->addingService = addingServ;
cust->modifiedService = modifiedServ;
cust->removedService = removedServ;
- tracker_create(context, SIMPLE_SHAPE_SERVICE_NAME, cust,
&activator->tracker);
- tracker_open(activator->tracker);
+ serviceTracker_create(context, SIMPLE_SHAPE_SERVICE_NAME, cust,
&activator->tracker);
+ serviceTracker_open(activator->tracker);
}
return status;
}
@@ -79,7 +79,7 @@ celix_status_t bundleActivator_start(voi
celix_status_t bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
struct paintFrameActivatorData * act = (struct paintFrameActivatorData
*) userData;
- tracker_close(act->tracker);
+ serviceTracker_close(act->tracker);
return CELIX_SUCCESS;
}
@@ -88,26 +88,28 @@ celix_status_t bundleActivator_destroy(v
return CELIX_SUCCESS;
}
-void *addingServ(void * handle, SERVICE_REFERENCE ref) {
+celix_status_t addingServ(void * handle, SERVICE_REFERENCE ref, void
**service) {
struct paintFrameActivatorData * data = (struct paintFrameActivatorData
*) handle;
- void *svc = NULL;
- bundleContext_getService(data->context, ref, &svc);
- return svc;
+ bundleContext_getService(data->context, ref, service);
+ return CELIX_SUCCESS;
}
-void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t addedServ(void * handle, SERVICE_REFERENCE ref, void * service)
{
struct paintFrameActivatorData * data = (struct paintFrameActivatorData
*) handle;
char * serviceName = properties_get(ref->registration->properties,
"name");
data->paint_frame->paintFrame_addShape(data->context, serviceName,
NULL, service);
+ return CELIX_SUCCESS;
}
-void modifiedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t modifiedServ(void * handle, SERVICE_REFERENCE ref, void *
service) {
struct paintFrameActivatorData * data = (struct paintFrameActivatorData
*) handle;
char * serviceName = properties_get(ref->registration->properties,
"name");
+ return CELIX_SUCCESS;
}
-void removedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t removedServ(void * handle, SERVICE_REFERENCE ref, void *
service) {
struct paintFrameActivatorData * data = (struct paintFrameActivatorData
*) handle;
char * serviceName = properties_get(ref->registration->properties,
"name");
data->paint_frame->paintFrame_removeShape(serviceName);
+ return CELIX_SUCCESS;
}
Modified: incubator/celix/trunk/examples/sender/test_activator.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/sender/test_activator.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/examples/sender/test_activator.c (original)
+++ incubator/celix/trunk/examples/sender/test_activator.c Tue Oct 18 11:24:15
2011
@@ -101,8 +101,8 @@ void service_destroy(void * userData) {
// listener = (SERVICE_LISTENER) malloc(sizeof(*listener));
// listener->serviceChanged = (void *) serviceChanged;
// addServiceListener(context, listener, "(test=test)");
-// tracker = tracker_createServiceTracker(context, (char *)
SERVICE_TEST_NAME, cust);
-// tracker_open(tracker);
+// tracker = serviceTracker_create(context, (char *) SERVICE_TEST_NAME,
cust);
+// serviceTracker_open(tracker);
// refs = tracker_getServices(tracker);
// printf("Size: %i\n", arrayList_size(refs));
// //arrayList_clear(refs);
@@ -121,7 +121,7 @@ void service_destroy(void * userData) {
//void bundleActivator_stop(void * userData, BUNDLE_CONTEXT context) {
// // removeServiceListener(context, listener);
-// tracker_close(tracker);
+// serviceTracker_close(tracker);
// tracker_destroy(tracker);
//
//}
Modified: incubator/celix/trunk/examples/whiteboard/tracker/activator.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/activator.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker/activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker/activator.c Tue Oct 18
11:24:15 2011
@@ -54,31 +54,33 @@ void * trk_send(void * handle) {
return NULL;
}
-void * addingServ(void * handle, SERVICE_REFERENCE ref) {
- void *service_instance = NULL;
+celix_status_t addingServ(void * handle, SERVICE_REFERENCE ref, void
**service) {
struct data * data = (struct data *) handle;
printf("Adding\n");
- bundleContext_getService(data->context, ref, &service_instance);
+ bundleContext_getService(data->context, ref, service);
- return service_instance;
+ return CELIX_SUCCESS;
}
-void addedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t addedServ(void * handle, SERVICE_REFERENCE ref, void * service)
{
struct data * data = (struct data *) handle;
arrayList_add(data->publishers, service);
printf("Added %p\n", service);
+ return CELIX_SUCCESS;
}
-void modifiedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t modifiedServ(void * handle, SERVICE_REFERENCE ref, void *
service) {
struct data * data = (struct data *) handle;
printf("Modified\n");
+ return CELIX_SUCCESS;
}
-void removedServ(void * handle, SERVICE_REFERENCE ref, void * service) {
+celix_status_t removedServ(void * handle, SERVICE_REFERENCE ref, void *
service) {
struct data * data = (struct data *) handle;
arrayList_removeElement(data->publishers, service);
printf("Removed %p\n", service);
+ return CELIX_SUCCESS;
}
celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData)
{
@@ -108,10 +110,10 @@ celix_status_t bundleActivator_start(voi
cust->modifiedService = modifiedServ;
cust->removedService = removedServ;
SERVICE_TRACKER tracker = NULL;
- tracker_create(context, (char *) PUBLISHER_NAME, cust, &tracker);
+ serviceTracker_create(context, (char *) PUBLISHER_NAME, cust,
&tracker);
data->tracker = tracker;
- tracker_open(tracker);
+ serviceTracker_open(tracker);
data->running = true;
pthread_create(&data->sender, NULL, trk_send, data);
@@ -126,7 +128,7 @@ celix_status_t bundleActivator_stop(void
printf("Stop\n");
struct data * data = (struct data *) userData;
- tracker_close(data->tracker);
+ serviceTracker_close(data->tracker);
data->running = false;
pthread_join(data->sender, NULL);
Modified: incubator/celix/trunk/framework/private/include/bundle.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle.h?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle.h Tue Oct 18
11:24:15 2011
@@ -49,9 +49,9 @@ celix_status_t bundle_getContext(BUNDLE
celix_status_t bundle_setContext(BUNDLE bundle, BUNDLE_CONTEXT context);
celix_status_t bundle_getEntry(BUNDLE bundle, char * name, apr_pool_t *pool,
char **entry);
-celix_status_t startBundle(BUNDLE bundle, int options);
+celix_status_t bundle_start(BUNDLE bundle, int options);
celix_status_t bundle_update(BUNDLE bundle, char *inputFile);
-celix_status_t stopBundle(BUNDLE bundle, int options);
+celix_status_t bundle_stop(BUNDLE bundle, int options);
celix_status_t bundle_uninstall(BUNDLE bundle);
celix_status_t bundle_setState(BUNDLE bundle, BUNDLE_STATE state);
@@ -82,4 +82,6 @@ celix_status_t bundle_close(BUNDLE bundl
celix_status_t bundle_refresh(BUNDLE bundle);
celix_status_t bundle_getBundleId(BUNDLE bundle, long *id);
+celix_status_t bundle_getRegisteredServices(BUNDLE bundle, ARRAY_LIST *list);
+
#endif /* BUNDLE_H_ */
Modified: incubator/celix/trunk/framework/private/include/bundle_context.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/bundle_context.h?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/bundle_context.h (original)
+++ incubator/celix/trunk/framework/private/include/bundle_context.h Tue Oct 18
11:24:15 2011
@@ -43,7 +43,7 @@ celix_status_t bundleContext_registerSer
celix_status_t bundleContext_registerServiceFactory(BUNDLE_CONTEXT context,
char * serviceName, service_factory_t factory,
PROPERTIES properties, SERVICE_REGISTRATION *service_registration);
-celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char
* serviceName, char * filter, ARRAY_LIST *service_references);
+celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context,
const char * serviceName, char * filter, ARRAY_LIST *service_references);
celix_status_t bundleContext_getServiceReference(BUNDLE_CONTEXT context, char
* serviceName, SERVICE_REFERENCE *service_reference);
celix_status_t bundleContext_getService(BUNDLE_CONTEXT context,
SERVICE_REFERENCE reference, void **service_instance);
Modified: incubator/celix/trunk/framework/private/include/framework.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework.h?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework.h (original)
+++ incubator/celix/trunk/framework/private/include/framework.h Tue Oct 18
11:24:15 2011
@@ -54,9 +54,10 @@ celix_status_t fw_registerService(FRAMEW
celix_status_t fw_registerServiceFactory(FRAMEWORK framework,
SERVICE_REGISTRATION * registration, BUNDLE bundle, char * serviceName,
service_factory_t factory, PROPERTIES properties);
void fw_unregisterService(SERVICE_REGISTRATION registration);
-celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST
*references, BUNDLE bundle, char * serviceName, char * filter);
+celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST
*references, BUNDLE bundle, const char * serviceName, char * filter);
void * fw_getService(FRAMEWORK framework, BUNDLE bundle, SERVICE_REFERENCE
reference);
bool framework_ungetService(FRAMEWORK framework, BUNDLE bundle,
SERVICE_REFERENCE reference);
+celix_status_t fw_getBundleRegisteredServices(FRAMEWORK framework, BUNDLE
bundle, ARRAY_LIST *services);
void fw_addServiceListener(FRAMEWORK framework, BUNDLE bundle,
SERVICE_LISTENER listener, char * filter);
void fw_removeServiceListener(FRAMEWORK framework, BUNDLE bundle,
SERVICE_LISTENER listener);
Modified: incubator/celix/trunk/framework/private/include/headers.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/headers.h?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/headers.h (original)
+++ incubator/celix/trunk/framework/private/include/headers.h Tue Oct 18
11:24:15 2011
@@ -171,17 +171,17 @@ typedef struct serviceRegistration * SER
struct serviceListener {
void * handle;
- void (*serviceChanged)(void * listener, SERVICE_EVENT event);
+ celix_status_t (*serviceChanged)(void * listener, SERVICE_EVENT event);
};
typedef struct serviceListener * SERVICE_LISTENER;
struct serviceTrackerCustomizer {
void * handle;
- void * (*addingService)(void * handle, SERVICE_REFERENCE reference);
- void (*addedService)(void * handle, SERVICE_REFERENCE reference, void *
service);
- void (*modifiedService)(void * handle, SERVICE_REFERENCE reference,
void * service);
- void (*removedService)(void * handle, SERVICE_REFERENCE reference, void
* service);
+ celix_status_t (*addingService)(void * handle, SERVICE_REFERENCE
reference, void **service);
+ celix_status_t (*addedService)(void * handle, SERVICE_REFERENCE
reference, void * service);
+ celix_status_t (*modifiedService)(void * handle, SERVICE_REFERENCE
reference, void * service);
+ celix_status_t (*removedService)(void * handle, SERVICE_REFERENCE
reference, void * service);
};
typedef struct serviceTrackerCustomizer * SERVICE_TRACKER_CUSTOMIZER;
Modified: incubator/celix/trunk/framework/private/include/service_registration.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registration.h?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registration.h
(original)
+++ incubator/celix/trunk/framework/private/include/service_registration.h Tue
Oct 18 11:24:15 2011
@@ -37,7 +37,7 @@ void serviceRegistration_destroy(SERVICE
bool serviceRegistration_isValid(SERVICE_REGISTRATION registration);
void serviceRegistration_invalidate(SERVICE_REGISTRATION registration);
-void serviceRegistration_unregister(SERVICE_REGISTRATION registration);
+celix_status_t serviceRegistration_unregister(SERVICE_REGISTRATION
registration);
celix_status_t serviceRegistration_getService(SERVICE_REGISTRATION
registration, BUNDLE bundle, void **service);
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registry.h
(original)
+++ incubator/celix/trunk/framework/private/include/service_registry.h Tue Oct
18 11:24:15 2011
@@ -40,7 +40,7 @@ SERVICE_REGISTRATION serviceRegistry_reg
SERVICE_REGISTRATION serviceRegistry_registerServiceFactory(SERVICE_REGISTRY
registry, BUNDLE bundle, char * serviceName, service_factory_t factory,
PROPERTIES dictionary);
void serviceRegistry_unregisterService(SERVICE_REGISTRY registry, BUNDLE
bundle, SERVICE_REGISTRATION registration);
void serviceRegistry_unregisterServices(SERVICE_REGISTRY registry, BUNDLE
bundle);
-ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry,
char * serviceName, FILTER filter);
+ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry,
const char * serviceName, FILTER filter);
void * serviceRegistry_getService(SERVICE_REGISTRY registry, BUNDLE bundle,
SERVICE_REFERENCE reference);
bool serviceRegistry_ungetService(SERVICE_REGISTRY registry, BUNDLE bundle,
SERVICE_REFERENCE reference);
void serviceRegistry_ungetServices(SERVICE_REGISTRY registry, BUNDLE bundle);
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_tracker.h (original)
+++ incubator/celix/trunk/framework/private/include/service_tracker.h Tue Oct
18 11:24:15 2011
@@ -44,11 +44,11 @@ struct tracked {
typedef struct tracked * TRACKED;
-celix_status_t tracker_create(BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker);
+celix_status_t serviceTracker_create(BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker);
celix_status_t tracker_createWithFilter(BUNDLE_CONTEXT context, char * filter,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker);
-void tracker_open(SERVICE_TRACKER tracker);
-void tracker_close(SERVICE_TRACKER tracker);
+celix_status_t serviceTracker_open(SERVICE_TRACKER tracker);
+celix_status_t serviceTracker_close(SERVICE_TRACKER tracker);
void tracker_destroy(SERVICE_TRACKER tracker);
SERVICE_REFERENCE tracker_getServiceReference(SERVICE_TRACKER tracker);
Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Tue Oct 18 11:24:15
2011
@@ -234,7 +234,7 @@ celix_status_t bundle_createModule(BUNDL
return status;
}
-celix_status_t startBundle(BUNDLE bundle, int options) {
+celix_status_t bundle_start(BUNDLE bundle, int options) {
celix_status_t status = CELIX_SUCCESS;
if (bundle != NULL) {
status = fw_startBundle(bundle->framework, bundle, options);
@@ -246,7 +246,7 @@ celix_status_t bundle_update(BUNDLE bund
return framework_updateBundle(bundle->framework, bundle, inputFile);
}
-celix_status_t stopBundle(BUNDLE bundle, int options) {
+celix_status_t bundle_stop(BUNDLE bundle, int options) {
return fw_stopBundle(bundle->framework, bundle, ((options & 1) == 0));
}
@@ -502,4 +502,10 @@ celix_status_t bundle_getBundleId(BUNDLE
return status;
}
+celix_status_t bundle_getRegisteredServices(BUNDLE bundle, ARRAY_LIST *list) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ status = fw_getBundleRegisteredServices(bundle->framework, bundle,
list);
+ return status;
+}
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_context.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_context.c Tue Oct 18
11:24:15 2011
@@ -164,7 +164,7 @@ celix_status_t bundleContext_registerSer
return status;
}
-celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context, char
* serviceName, char * filter, ARRAY_LIST *service_references) {
+celix_status_t bundleContext_getServiceReferences(BUNDLE_CONTEXT context,
const char * serviceName, char * filter, ARRAY_LIST *service_references) {
ARRAY_LIST references = NULL;
celix_status_t status = CELIX_SUCCESS;
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Tue Oct 18 11:24:15
2011
@@ -987,7 +987,7 @@ celix_status_t fw_registerServiceFactory
return CELIX_SUCCESS;
}
-celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST
*references, BUNDLE bundle ATTRIBUTE_UNUSED, char * serviceName, char *
sfilter) {
+celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST
*references, BUNDLE bundle ATTRIBUTE_UNUSED, const char * serviceName, char *
sfilter) {
FILTER filter = NULL;
if (sfilter != NULL) {
filter = filter_create(sfilter);
@@ -1017,6 +1017,12 @@ void * fw_getService(FRAMEWORK framework
return serviceRegistry_getService(framework->registry, bundle,
reference);
}
+celix_status_t fw_getBundleRegisteredServices(FRAMEWORK framework, BUNDLE
bundle, ARRAY_LIST *services) {
+ celix_status_t status = CELIX_SUCCESS;
+ *services = serviceRegistry_getRegisteredServices(framework->registry,
bundle);
+ return status;
+}
+
bool framework_ungetService(FRAMEWORK framework, BUNDLE bundle
ATTRIBUTE_UNUSED, SERVICE_REFERENCE reference) {
return serviceRegistry_ungetService(framework->registry, bundle,
reference);
}
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c
(original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Tue Oct
18 11:24:15 2011
@@ -110,21 +110,20 @@ void serviceRegistration_invalidate(SERV
pthread_mutex_unlock(®istration->mutex);
}
-void serviceRegistration_unregister(SERVICE_REGISTRATION registration) {
+celix_status_t serviceRegistration_unregister(SERVICE_REGISTRATION
registration) {
+ celix_status_t status = CELIX_SUCCESS;
pthread_mutex_lock(®istration->mutex);
if (!serviceRegistration_isValid(registration) ||
registration->isUnregistering) {
printf("Service is already unregistered\n");
- return;
+ status = CELIX_ILLEGAL_STATE;
+ } else {
+ registration->isUnregistering = true;
}
- registration->isUnregistering = true;
pthread_mutex_unlock(®istration->mutex);
serviceRegistry_unregisterService(registration->registry,
registration->reference->bundle, registration);
- // Unregister service cleans up the registration
-// pthread_mutex_lock(®istration->mutex);
-// registration->svcObj = NULL;
-// pthread_mutex_unlock(®istration->mutex);
+ return status;
}
celix_status_t serviceRegistration_getService(SERVICE_REGISTRATION
registration, BUNDLE bundle, void **service) {
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Tue Oct 18
11:24:15 2011
@@ -238,7 +238,7 @@ void serviceRegistry_unregisterServices(
pthread_mutex_unlock(®istry->mutex);
}
-ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry,
char * serviceName, FILTER filter) {
+ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry,
const char * serviceName, FILTER filter) {
ARRAY_LIST references = arrayList_create();
HASH_MAP_VALUES registrations =
hashMapValues_create(registry->serviceRegistrations);
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=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Tue Oct 18
11:24:15 2011
@@ -32,10 +32,10 @@
ARRAY_LIST m_trackers;
void * addingService(FW_SERVICE_TRACKER, SERVICE_REFERENCE);
-void track(FW_SERVICE_TRACKER, SERVICE_REFERENCE, SERVICE_EVENT);
-void untrack(FW_SERVICE_TRACKER, SERVICE_REFERENCE, SERVICE_EVENT);
+celix_status_t serviceTracker_track(FW_SERVICE_TRACKER, SERVICE_REFERENCE,
SERVICE_EVENT);
+celix_status_t serviceTracker_untrack(FW_SERVICE_TRACKER fwTracker,
SERVICE_REFERENCE reference, SERVICE_EVENT event ATTRIBUTE_UNUSED);
-celix_status_t tracker_create(BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
+celix_status_t serviceTracker_create(BUNDLE_CONTEXT context, char * service,
SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
celix_status_t status = CELIX_SUCCESS;
if (service == NULL) {
@@ -82,42 +82,54 @@ celix_status_t tracker_createWithFilter(
return CELIX_SUCCESS;
}
-void tracker_open(SERVICE_TRACKER tracker) {
+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);
ARRAY_LIST initial = NULL;
- bundleContext_getServiceReferences(tracker->context, NULL,
tracker->filter, &initial);
- SERVICE_REFERENCE initial_reference;
- unsigned int i;
+ status = bundleContext_getServiceReferences(tracker->context, NULL,
tracker->filter, &initial);
+ if (status == CELIX_SUCCESS) {
+ SERVICE_REFERENCE initial_reference;
+ unsigned int i;
+
+ listener->serviceChanged = (void *) tracker_serviceChanged;
+ status = bundleContext_addServiceListener(tracker->context,
listener, tracker->filter);
+ if (status == CELIX_SUCCESS) {
+ fwTracker->listener = listener;
- listener->serviceChanged = (void *) tracker_serviceChanged;
- bundleContext_addServiceListener(tracker->context, listener,
tracker->filter);
- 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);
+ }
+ arrayList_clear(initial);
+ arrayList_destroy(initial);
- for (i = 0; i < arrayList_size(initial); i++) {
- initial_reference = (SERVICE_REFERENCE) arrayList_get(initial,
i);
- track(fwTracker, initial_reference, NULL);
+ initial = NULL;
+ }
}
- arrayList_clear(initial);
- arrayList_destroy(initial);
- initial = NULL;
+ return status;
}
-void tracker_close(SERVICE_TRACKER tracker) {
- FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
- bundleContext_removeServiceListener(tracker->context,
fwTracker->listener);
+celix_status_t serviceTracker_close(SERVICE_TRACKER tracker) {
+ celix_status_t status = CELIX_SUCCESS;
- ARRAY_LIST refs = tracker_getServiceReferences(tracker);
- if (refs != NULL) {
- int i;
- for (i = 0; i < arrayList_size(refs); i++) {
- SERVICE_REFERENCE ref = arrayList_get(refs, i);
- untrack(fwTracker, ref, NULL);
+ FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
+ status = bundleContext_removeServiceListener(tracker->context,
fwTracker->listener);
+ if (status == CELIX_SUCCESS) {
+ ARRAY_LIST refs = tracker_getServiceReferences(tracker);
+ if (refs != NULL) {
+ int i;
+ for (i = 0; i < arrayList_size(refs); i++) {
+ SERVICE_REFERENCE ref = arrayList_get(refs, i);
+ status = serviceTracker_untrack(fwTracker, ref,
NULL);
+ }
}
+ arrayList_destroy(refs);
}
- arrayList_destroy(refs);
+
+ return status;
}
void tracker_destroy(SERVICE_TRACKER tracker) {
@@ -199,10 +211,10 @@ void tracker_serviceChanged(SERVICE_LIST
switch (event->type) {
case REGISTERED:
case MODIFIED:
- track(fwTracker, event->reference,
event);
+ serviceTracker_track(fwTracker,
event->reference, event);
break;
case UNREGISTERING:
- untrack(fwTracker, event->reference,
event);
+ serviceTracker_untrack(fwTracker,
event->reference, event);
break;
case MODIFIED_ENDMATCH:
break;
@@ -212,7 +224,9 @@ void tracker_serviceChanged(SERVICE_LIST
}
}
-void track(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event ATTRIBUTE_UNUSED) {
+celix_status_t serviceTracker_track(FW_SERVICE_TRACKER fwTracker,
SERVICE_REFERENCE reference, SERVICE_EVENT event ATTRIBUTE_UNUSED) {
+ celix_status_t status = CELIX_SUCCESS;
+
TRACKED tracked = NULL;
int found = -1;
unsigned int i;
@@ -241,13 +255,15 @@ void track(FW_SERVICE_TRACKER fwTracker,
fwTracker->customizer->modifiedService(fwTracker->customizer->handle,
reference, tracked->service);
}
}
+
+ return status;
}
void * addingService(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE
reference) {
void *svc = NULL;
if (fwTracker->customizer != NULL) {
- svc =
fwTracker->customizer->addingService(fwTracker->customizer->handle, reference);
+
fwTracker->customizer->addingService(fwTracker->customizer->handle, reference,
&svc);
} else {
bundleContext_getService(fwTracker->tracker->context,
reference, &svc);
}
@@ -255,7 +271,8 @@ void * addingService(FW_SERVICE_TRACKER
return svc;
}
-void untrack(FW_SERVICE_TRACKER fwTracker, SERVICE_REFERENCE reference,
SERVICE_EVENT event ATTRIBUTE_UNUSED) {
+celix_status_t serviceTracker_untrack(FW_SERVICE_TRACKER fwTracker,
SERVICE_REFERENCE reference, SERVICE_EVENT event ATTRIBUTE_UNUSED) {
+ celix_status_t status = CELIX_SUCCESS;
TRACKED tracked = NULL;
unsigned int i;
bool result = NULL;
@@ -265,17 +282,21 @@ void untrack(FW_SERVICE_TRACKER fwTracke
if (tracked->reference == reference) {
if (tracked != NULL) {
arrayList_remove(fwTracker->tracked, i);
-
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
+ status =
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
}
- if (fwTracker->customizer != NULL) {
-
fwTracker->customizer->removedService(fwTracker->customizer->handle, reference,
tracked->service);
- } else {
-
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
+ if (status == CELIX_SUCCESS) {
+ if (fwTracker->customizer != NULL) {
+
fwTracker->customizer->removedService(fwTracker->customizer->handle, reference,
tracked->service);
+ } else {
+ status =
bundleContext_ungetService(fwTracker->tracker->context, reference, &result);
+ }
+ free(tracked);
+ break;
}
- free(tracked);
- break;
}
}
+
+ return status;
}
FW_SERVICE_TRACKER findFwServiceTracker(SERVICE_TRACKER tracker) {
Modified: incubator/celix/trunk/launcher/launcher.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/launcher.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/launcher.c (original)
+++ incubator/celix/trunk/launcher/launcher.c Tue Oct 18 11:24:15 2011
@@ -97,7 +97,7 @@ int main(void) {
int i;
for (i = 0; i < arrayList_size(installed); i++) {
BUNDLE bundle = (BUNDLE) arrayList_get(installed, i);
- startBundle(bundle, 0);
+ bundle_start(bundle, 0);
}
arrayList_destroy(installed);
Modified: incubator/celix/trunk/log_service/private/src/log_service_activator.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log_service_activator.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log_service_activator.c
(original)
+++ incubator/celix/trunk/log_service/private/src/log_service_activator.c Tue
Oct 18 11:24:15 2011
@@ -23,6 +23,7 @@
* Author: alexander
*/
#include <apr_general.h>
+#include <stdlib.h>
#include "bundle_activator.h"
#include "log_service_impl.h"
Modified: incubator/celix/trunk/shell/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/CMakeLists.txt?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/shell/CMakeLists.txt (original)
+++ incubator/celix/trunk/shell/CMakeLists.txt Tue Oct 18 11:24:15 2011
@@ -18,7 +18,8 @@
add_library(shell SHARED shell command
ps_command start_command stop_command
install_command update_command
- uninstall_command log_command)
+ uninstall_command log_command
+ inspect_command)
include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
include_directories("${PROJECT_SOURCE_DIR}/log_service/public/include")
target_link_libraries(shell framework curl)
Added: incubator/celix/trunk/shell/inspect_command.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/inspect_command.c?rev=1185583&view=auto
==============================================================================
--- incubator/celix/trunk/shell/inspect_command.c (added)
+++ incubator/celix/trunk/shell/inspect_command.c Tue Oct 18 11:24:15 2011
@@ -0,0 +1,141 @@
+/*
+ * inspect_command.c
+ *
+ * Created on: Oct 13, 2011
+ * Author: alexander
+ */
+
+#include <stdlib.h>
+
+#include <apr_strings.h>
+
+#include "command_private.h"
+#include "array_list.h"
+#include "bundle_context.h"
+#include "bundle.h"
+#include "module.h"
+#include "constants.h"
+#include "service_registration.h"
+
+#define SERVICE_TYPE "service"
+#define CAPABILITY "capability"
+#define REQUIREMENT "requirement"
+
+void inspectCommand_execute(COMMAND command, char * commandline, void
(*out)(char *), void (*err)(char *));
+celix_status_t inspectCommand_printExportedServices(COMMAND command,
ARRAY_LIST ids, void (*out)(char *), void (*err)(char *));
+
+COMMAND inspectCommand_create(BUNDLE_CONTEXT context) {
+ COMMAND command = (COMMAND) malloc(sizeof(*command));
+ command->bundleContext = context;
+ command->name = "inspect";
+ command->shortDescription = "inspect dependencies";
+ command->usage = "inspect (service) (capability|requirement) [<id>
...]";
+ command->executeCommand = inspectCommand_execute;
+ return command;
+}
+
+void inspectCommand_destroy(COMMAND command) {
+ free(command);
+}
+
+void inspectCommand_execute(COMMAND command, char * commandline, void
(*out)(char *), void (*err)(char *)) {
+ celix_status_t status = CELIX_SUCCESS;
+ char *token;
+ char *commandStr = apr_strtok(commandline, " ", &token);
+ char *type = apr_strtok(NULL, " ", &token);
+ if (type != NULL) {
+ char *direction = apr_strtok(NULL, " ", &token);
+ if (direction != NULL) {
+ ARRAY_LIST ids = arrayList_create();
+ char *id = apr_strtok(NULL, " ", &token);
+ while (id != NULL) {
+ arrayList_add(ids, id);
+ id = apr_strtok(NULL, " ", &token);
+ }
+
+ if (strcmp(type, SERVICE_TYPE) == 0) {
+ if (strcmp(direction, CAPABILITY) == 0) {
+ status =
inspectCommand_printExportedServices(command, ids, out, err);
+ if (status != CELIX_SUCCESS) {
+ out("INSPECT: Error\n");
+ }
+ } else {
+ out("INSPECT: Not implemented\n");
+ }
+ } else {
+ out("INSPECT: Invalid argument\n");
+ }
+ } else {
+ out("INSPECT: Too few arguments\n");
+ }
+ } else {
+ out("INSPECT: Too few arguments\n");
+ }
+}
+
+celix_status_t inspectCommand_printExportedServices(COMMAND command,
ARRAY_LIST ids, void (*out)(char *), void (*err)(char *)) {
+ celix_status_t status = CELIX_SUCCESS;
+ ARRAY_LIST bundles = NULL;
+
+ if (arrayList_isEmpty(ids)) {
+ celix_status_t status =
bundleContext_getBundles(command->bundleContext, &bundles);
+ } else {
+ bundles = arrayList_create();
+ int i;
+ for (i = 0; i < arrayList_size(ids); i++) {
+ char *idStr = arrayList_get(ids, i);
+ long id = atol(idStr);
+ BUNDLE b = NULL;
+ celix_status_t st =
bundleContext_getBundleById(command->bundleContext, id, &b);
+ if (st == CELIX_SUCCESS) {
+ arrayList_add(bundles, b);
+ } else {
+ char line[256];
+ sprintf(line, "INSPECT: Invalid bundle ID:
%ld\n", id);
+ out(line);
+ }
+ }
+ }
+
+ if (status == CELIX_SUCCESS) {
+ int i = 0;
+ for (i = 0; i < arrayList_size(bundles); i++) {
+ BUNDLE bundle = arrayList_get(bundles, i);
+
+ if (i > 0) {
+ out("\n");
+ }
+
+ if (bundle != NULL) {
+ ARRAY_LIST refs = NULL;
+ if (bundle_getRegisteredServices(bundle, &refs)
== CELIX_SUCCESS) {
+ char line[256];
+ char * name =
module_getSymbolicName(bundle_getCurrentModule(bundle));
+ sprintf(line, "%s provides
services:\n", name);
+ out(line);
+ out("==============\n");
+
+ if (refs == NULL ||
arrayList_size(refs) == 0) {
+ out("Nothing\n");
+ } else {
+ int j = 0;
+ for (j = 0; j <
arrayList_size(refs); j++) {
+ SERVICE_REFERENCE ref =
arrayList_get(refs, j);
+ char line[256];
+ char *objectClass =
properties_get(ref->registration->properties, (char *) OBJECTCLASS);
+ sprintf(line,
"ObjectClass = %s\n", objectClass);
+ out(line);
+ if ((j + 1) <
arrayList_size(refs)) {
+ out("----\n");
+ }
+ }
+ }
+ }
+
+ }
+ }
+ }
+
+
+ return status;
+}
Added: incubator/celix/trunk/shell/inspect_command.h
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/inspect_command.h?rev=1185583&view=auto
==============================================================================
--- incubator/celix/trunk/shell/inspect_command.h (added)
+++ incubator/celix/trunk/shell/inspect_command.h Tue Oct 18 11:24:15 2011
@@ -0,0 +1,14 @@
+/*
+ * inspect_command.h
+ *
+ * Created on: Oct 13, 2011
+ * Author: alexander
+ */
+
+#ifndef INSPECT_COMMAND_H_
+#define INSPECT_COMMAND_H_
+
+COMMAND inspectCommand_create(BUNDLE_CONTEXT context);
+void inspectCommand_destroy(COMMAND command);
+
+#endif /* INSPECT_COMMAND_H_ */
Modified: incubator/celix/trunk/shell/shell.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/shell.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/shell/shell.c (original)
+++ incubator/celix/trunk/shell/shell.c Tue Oct 18 11:24:15 2011
@@ -39,6 +39,7 @@
#include "uninstall_command.h"
#include "update_command.h"
#include "log_command.h"
+#include "inspect_command.h"
#include "utils.h"
@@ -68,6 +69,9 @@ struct shellServiceActivator {
SERVICE_REGISTRATION logCommand;
COMMAND logCmd;
+
+ SERVICE_REGISTRATION inspectCommand;
+ COMMAND inspectCmd;
};
SHELL shell_create() {
@@ -167,6 +171,7 @@ celix_status_t bundleActivator_create(BU
((struct shellServiceActivator *) (*userData))->uninstallCommand = NULL;
((struct shellServiceActivator *) (*userData))->updateCommand = NULL;
((struct shellServiceActivator *) (*userData))->logCommand = NULL;
+ ((struct shellServiceActivator *) (*userData))->inspectCommand = NULL;
((struct shellServiceActivator *) (*userData))->registration = NULL;
//(*userData) = &(*activator);
@@ -218,6 +223,9 @@ celix_status_t bundleActivator_start(voi
activator->logCmd = logCommand_create(context);
bundleContext_registerService(context, (char *)
COMMAND_SERVICE_NAME, activator->logCmd, NULL, &activator->logCommand);
+
+ activator->inspectCmd = inspectCommand_create(context);
+ bundleContext_registerService(context, (char *)
COMMAND_SERVICE_NAME, activator->inspectCmd, NULL, &activator->inspectCommand);
}
}
@@ -235,6 +243,7 @@ celix_status_t bundleActivator_stop(void
serviceRegistration_unregister(activator->uninstallCommand);
serviceRegistration_unregister(activator->updateCommand);
serviceRegistration_unregister(activator->logCommand);
+ serviceRegistration_unregister(activator->inspectCommand);
status = bundleContext_removeServiceListener(context,
activator->listener);
if (status == CELIX_SUCCESS) {
@@ -245,6 +254,7 @@ celix_status_t bundleActivator_stop(void
uninstallCommand_destroy(activator->uninstallCmd);
updateCommand_destroy(activator->updateCmd);
logCommand_destroy(activator->logCmd);
+ inspectCommand_destroy(activator->inspectCmd);
free(activator->shellService);
activator->shellService = NULL;
Modified: incubator/celix/trunk/shell/start_command.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/start_command.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/shell/start_command.c (original)
+++ incubator/celix/trunk/shell/start_command.c Tue Oct 18 11:24:15 2011
@@ -57,7 +57,7 @@ void startCommand_execute(COMMAND comman
BUNDLE bundle = NULL;
bundleContext_getBundleById(command->bundleContext, id,
&bundle);
if (bundle != NULL) {
- startBundle(bundle, 0);
+ bundle_start(bundle, 0);
} else {
err("Bundle id is invalid.");
}
Modified: incubator/celix/trunk/shell/stop_command.c
URL:
http://svn.apache.org/viewvc/incubator/celix/trunk/shell/stop_command.c?rev=1185583&r1=1185582&r2=1185583&view=diff
==============================================================================
--- incubator/celix/trunk/shell/stop_command.c (original)
+++ incubator/celix/trunk/shell/stop_command.c Tue Oct 18 11:24:15 2011
@@ -56,7 +56,7 @@ void stopCommand_execute(COMMAND command
BUNDLE bundle = NULL;
bundleContext_getBundleById(command->bundleContext, id,
&bundle);
if (bundle != NULL) {
- stopBundle(bundle, 0);
+ bundle_stop(bundle, 0);
} else {
err("Bundle id is invalid.");
}