celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1524662 - in /incubator/celix/trunk: remote_services/calc_shell/ remote_services/calc_shell/private/include/ remote_services/calc_shell/private/src/ shell/ shell/private/include/ shell/private/src/ shell/public/include/ shell/public/src/
Date Thu, 19 Sep 2013 09:10:11 GMT
Author: abroekhuis
Date: Thu Sep 19 09:10:10 2013
New Revision: 1524662

URL: http://svn.apache.org/r1524662
Log:
CELIX-66: Refactored Shell and Commands to use services instead of direct references.

Added:
    incubator/celix/trunk/shell/public/include/command_impl.h
      - copied, changed from r1524045, incubator/celix/trunk/shell/public/include/command_private.h
    incubator/celix/trunk/shell/public/src/
    incubator/celix/trunk/shell/public/src/command.c
      - copied, changed from r1524045, incubator/celix/trunk/shell/private/src/command.c
Removed:
    incubator/celix/trunk/shell/private/src/command.c
    incubator/celix/trunk/shell/public/include/command_private.h
Modified:
    incubator/celix/trunk/remote_services/calc_shell/CMakeLists.txt
    incubator/celix/trunk/remote_services/calc_shell/private/include/add_command.h
    incubator/celix/trunk/remote_services/calc_shell/private/include/sqrt_command.h
    incubator/celix/trunk/remote_services/calc_shell/private/include/sub_command.h
    incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/calc_shell_activator.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c
    incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c
    incubator/celix/trunk/shell/CMakeLists.txt
    incubator/celix/trunk/shell/private/include/shell_private.h
    incubator/celix/trunk/shell/private/src/install_command.c
    incubator/celix/trunk/shell/private/src/log_command.c
    incubator/celix/trunk/shell/private/src/ps_command.c
    incubator/celix/trunk/shell/private/src/shell.c
    incubator/celix/trunk/shell/private/src/start_command.c
    incubator/celix/trunk/shell/private/src/stop_command.c
    incubator/celix/trunk/shell/private/src/uninstall_command.c
    incubator/celix/trunk/shell/private/src/update_command.c
    incubator/celix/trunk/shell/public/include/command.h

Modified: incubator/celix/trunk/remote_services/calc_shell/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/CMakeLists.txt?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/CMakeLists.txt (original)
+++ incubator/celix/trunk/remote_services/calc_shell/CMakeLists.txt Thu Sep 19 09:10:10 2013
@@ -24,6 +24,7 @@ bundle(calc_shell SOURCES
     private/include/add_command.h
     private/include/sqrt_command.h
     private/include/sub_command.h
+    ${PROJECT_SOURCE_DIR}/shell/public/src/command.c
 )
 
 include_directories("${PROJECT_SOURCE_DIR}/remote_services/calc_shell/private/include")

Modified: incubator/celix/trunk/remote_services/calc_shell/private/include/add_command.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/include/add_command.h?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/include/add_command.h (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/include/add_command.h Thu Sep
19 09:10:10 2013
@@ -27,6 +27,8 @@
 #ifndef ADD_COMMAND_H_
 #define ADD_COMMAND_H_
 
+#include "command_impl.h"
+
 command_pt addCommand_create(bundle_context_pt context);
 void addCommand_destroy(command_pt command);
 

Modified: incubator/celix/trunk/remote_services/calc_shell/private/include/sqrt_command.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/include/sqrt_command.h?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/include/sqrt_command.h (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/include/sqrt_command.h Thu Sep
19 09:10:10 2013
@@ -27,6 +27,8 @@
 #ifndef SQRT_COMMAND_H_
 #define SQRT_COMMAND_H_
 
+#include "command_impl.h"
+
 command_pt sqrtCommand_create(bundle_context_pt context);
 void sqrtCommand_destroy(command_pt command);
 

Modified: incubator/celix/trunk/remote_services/calc_shell/private/include/sub_command.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/include/sub_command.h?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/include/sub_command.h (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/include/sub_command.h Thu Sep
19 09:10:10 2013
@@ -27,6 +27,8 @@
 #ifndef SUB_COMMAND_H_
 #define SUB_COMMAND_H_
 
+#include "command_impl.h"
+
 command_pt subCommand_create(bundle_context_pt context);
 void subCommand_destroy(command_pt command);
 

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/add_command.c Thu Sep 19
09:10:10 2013
@@ -29,7 +29,6 @@
 
 #include <apr_strings.h>
 
-#include "command_private.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "add_command.h"

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/calc_shell_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/calc_shell_activator.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/calc_shell_activator.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/calc_shell_activator.c Thu
Sep 19 09:10:10 2013
@@ -29,7 +29,7 @@
 #include "bundle_context.h"
 #include "service_registration.h"
 
-#include "command_private.h"
+#include "command_impl.h"
 
 #include "add_command.h"
 #include "sub_command.h"
@@ -38,14 +38,19 @@
 struct activator {
 	service_registration_pt addCommand;
 	command_pt addCmd;
+	command_service_pt addCmdSrv;
 
 	service_registration_pt subCommand;
 	command_pt subCmd;
+	command_service_pt subCmdSrv;
 
 	service_registration_pt sqrtCommand;
 	command_pt sqrtCmd;
+	command_service_pt sqrtCmdSrv;
 };
 
+static celix_status_t calcShell_createCommandService(apr_pool_t *pool, command_pt command,
command_service_pt *commandService);
+
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_pool_t *pool = NULL;
@@ -62,6 +67,10 @@ celix_status_t bundleActivator_create(bu
 			((struct activator *) (*userData))->addCmd = NULL;
 			((struct activator *) (*userData))->subCmd = NULL;
 			((struct activator *) (*userData))->sqrtCmd = NULL;
+
+			((struct activator *) (*userData))->addCmdSrv = NULL;
+			((struct activator *) (*userData))->subCmdSrv = NULL;
+			((struct activator *) (*userData))->sqrtCmdSrv = NULL;
 		}
 	}
 
@@ -71,20 +80,37 @@ celix_status_t bundleActivator_create(bu
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
 
+	apr_pool_t *pool;
 	struct activator * activator = (struct activator *) userData;
 
+	bundleContext_getMemoryPool(context, &pool);
+
 	activator->addCmd = addCommand_create(context);
-	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->addCmd,
NULL, &activator->addCommand);
+	calcShell_createCommandService(pool, activator->addCmd, &activator->addCmdSrv);
+	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->addCmdSrv,
NULL, &activator->addCommand);
 
 	activator->subCmd = subCommand_create(context);
-	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->subCmd,
NULL, &activator->subCommand);
+	calcShell_createCommandService(pool, activator->subCmd, &activator->subCmdSrv);
+	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->subCmdSrv,
NULL, &activator->subCommand);
 
 	activator->sqrtCmd = sqrtCommand_create(context);
-	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->sqrtCmd,
NULL, &activator->sqrtCommand);
+	calcShell_createCommandService(pool, activator->sqrtCmd, &activator->sqrtCmdSrv);
+	bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->sqrtCmdSrv,
NULL, &activator->sqrtCommand);
 
 	return status;
 }
 
+static celix_status_t calcShell_createCommandService(apr_pool_t *pool, command_pt command,
command_service_pt *commandService) {
+	*commandService = apr_palloc(pool, sizeof(**commandService));
+	(*commandService)->command = command;
+	(*commandService)->executeCommand = command->executeCommand;
+	(*commandService)->getName = command_getName;
+	(*commandService)->getShortDescription = command_getShortDescription;
+	(*commandService)->getUsage = command_getUsage;
+
+	return CELIX_SUCCESS;
+}
+
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
 	struct activator * activator = (struct activator *) userData;

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/sqrt_command.c Thu Sep 19
09:10:10 2013
@@ -29,7 +29,6 @@
 
 #include <apr_strings.h>
 
-#include "command_private.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "sqrt_command.h"

Modified: incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c (original)
+++ incubator/celix/trunk/remote_services/calc_shell/private/src/sub_command.c Thu Sep 19
09:10:10 2013
@@ -29,7 +29,6 @@
 
 #include <apr_strings.h>
 
-#include "command_private.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "sub_command.h"

Modified: incubator/celix/trunk/shell/CMakeLists.txt
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/CMakeLists.txt?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/CMakeLists.txt (original)
+++ incubator/celix/trunk/shell/CMakeLists.txt Thu Sep 19 09:10:10 2013
@@ -21,9 +21,10 @@ if (SHELL)
 	SET_HEADER(BUNDLE_SYMBOLICNAME "apache_celix_shell")
 	SET_HEADERS("Bundle-Name: Apache Celix Shell") 
 
-    bundle(shell SOURCES 
+    bundle(shell SOURCES
+    	public/src/command
+     
     	private/src/shell 
-    	private/src/command
     	private/src/ps_command 
     	private/src/start_command 
     	private/src/stop_command
@@ -51,9 +52,9 @@ if (SHELL)
 	include_directories(${CURL_INCLUDE_DIRS})
     target_link_libraries(shell celix_framework ${CURL_LIBRARIES})
     
-    package(shell FILES public/include/shell.h public/include/command.h public/include/command_private.h)
+    package(shell FILES public/include/shell.h public/include/command.h public/include/command_impl.h
public/src/command.c)
     
-    FILE(GLOB files public/include/shell.h public/include/command.h public/include/command_private.h)
+    FILE(GLOB files public/include/shell.h public/include/command.h public/include/command_impl.h
public/src/command.c)
     INSTALL(FILES ${files} DESTINATION include/celix/shell COMPONENT framework)
     INSTALL(FILES ${PROJECT_BINARY_DIR}/shell/shell.zip DESTINATION share/celix/bundles COMPONENT
framework)
 endif (SHELL)
\ No newline at end of file

Modified: incubator/celix/trunk/shell/private/include/shell_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/include/shell_private.h?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/include/shell_private.h (original)
+++ incubator/celix/trunk/shell/private/include/shell_private.h Thu Sep 19 09:10:10 2013
@@ -44,7 +44,7 @@ char * shell_getCommandDescription(shell
 service_reference_pt shell_getCommandReference(shell_pt shell, char * command);
 void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char
*));
 
-command_pt shell_getCommand(shell_pt shell, char * commandName);
+command_service_pt shell_getCommand(shell_pt shell, char * commandName);
 
 
 #endif /* SHELL_PRIVATE_H_ */

Modified: incubator/celix/trunk/shell/private/src/install_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/install_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/install_command.c (original)
+++ incubator/celix/trunk/shell/private/src/install_command.c Thu Sep 19 09:10:10 2013
@@ -25,7 +25,7 @@
  */
 #include <stdlib.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle_archive.h"

Modified: incubator/celix/trunk/shell/private/src/log_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/log_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/log_command.c (original)
+++ incubator/celix/trunk/shell/private/src/log_command.c Thu Sep 19 09:10:10 2013
@@ -26,7 +26,7 @@
 
 #include <stdlib.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "log_command.h"
 #include "bundle_context.h"
 #include "log_reader_service.h"

Modified: incubator/celix/trunk/shell/private/src/ps_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/ps_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/ps_command.c (original)
+++ incubator/celix/trunk/shell/private/src/ps_command.c Thu Sep 19 09:10:10 2013
@@ -25,7 +25,7 @@
  */
 #include <stdlib.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle_archive.h"

Modified: incubator/celix/trunk/shell/private/src/shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/shell.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/shell.c (original)
+++ incubator/celix/trunk/shell/private/src/shell.c Thu Sep 19 09:10:10 2013
@@ -28,7 +28,7 @@
 
 #include "shell_private.h"
 #include "bundle_activator.h"
-#include "command_private.h"
+#include "command_impl.h"
 #include "bundle_context.h"
 #include "service_registration.h"
 #include "service_listener.h"
@@ -52,29 +52,39 @@ struct shellServiceActivator {
 
 	service_registration_pt psCommand;
 	command_pt psCmd;
+	command_service_pt psCmdSrv;
 
 	service_registration_pt startCommand;
 	command_pt startCmd;
+	command_service_pt startCmdSrv;
 
 	service_registration_pt stopCommand;
 	command_pt stopCmd;
+	command_service_pt stopCmdSrv;
 
 	service_registration_pt installCommand;
 	command_pt installCmd;
+	command_service_pt installCmdSrv;
 
 	service_registration_pt uninstallCommand;
     command_pt uninstallCmd;
+    command_service_pt uninstallCmdSrv;
 
 	service_registration_pt updateCommand;
 	command_pt updateCmd;
+	command_service_pt updateCmdSrv;
 
 	service_registration_pt logCommand;
     command_pt logCmd;
+    command_service_pt logCmdSrv;
 
     service_registration_pt inspectCommand;
 	command_pt inspectCmd;
+	command_service_pt inspectCmdSrv;
 };
 
+static celix_status_t shell_createCommandService(apr_pool_t *pool, command_pt command, command_service_pt
*commandService);
+
 shell_pt shell_create(apr_pool_t *pool) {
 	shell_pt shell = (shell_pt) malloc(sizeof(*shell));
 	shell->pool = pool;
@@ -102,21 +112,21 @@ array_list_pt shell_getCommands(shell_pt
 }
 
 char * shell_getCommandUsage(shell_pt shell, char * commandName) {
-	command_pt command = hashMap_get(shell->commandNameMap, commandName);
-	return (command == NULL) ? NULL : command->usage;
+	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
+	return (command == NULL) ? NULL : command->getUsage(command->command);
 }
 
 char * shell_getCommandDescription(shell_pt shell, char * commandName) {
-	command_pt command = hashMap_get(shell->commandNameMap, commandName);
-	return (command == NULL) ? NULL : command->shortDescription;
+	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
+	return (command == NULL) ? NULL : command->getShortDescription(command->command);
 }
 
 service_reference_pt shell_getCommandReference(shell_pt shell, char * command) {
 	hash_map_iterator_pt iter = hashMapIterator_create(shell->commandReferenceMap);
 	while (hashMapIterator_hasNext(iter)) {
 		hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-		command_pt cmd = (command_pt) hashMapEntry_getValue(entry);
-		if (strcmp(cmd->name, command) == 0) {
+		command_service_pt cmd = (command_service_pt) hashMapEntry_getValue(entry);
+		if (strcmp(cmd->getName(cmd->command), command) == 0) {
 			return (service_reference_pt) hashMapEntry_getValue(entry);
 		}
 	}
@@ -126,33 +136,33 @@ service_reference_pt shell_getCommandRef
 void shell_executeCommand(shell_pt shell, char * commandLine, void (*out)(char *), void (*error)(char
*)) {
 	unsigned int pos = strcspn(commandLine, " ");
 	char * commandName = (pos != strlen(commandLine)) ? string_ndup((char *)commandLine, pos)
: strdup(commandLine);
-	command_pt command = shell_getCommand(shell, commandName);
+	command_service_pt command = shell_getCommand(shell, commandName);
 	if (command != NULL) {
-		command->executeCommand(command, commandLine, out, error);
+		command->executeCommand(command->command, commandLine, out, error);
 	} else {
 	    error("No such command\n");
 	}
 	free(commandName);
 }
 
-command_pt shell_getCommand(shell_pt shell, char * commandName) {
-	command_pt command = hashMap_get(shell->commandNameMap, commandName);
+command_service_pt shell_getCommand(shell_pt shell, char * commandName) {
+	command_service_pt command = hashMap_get(shell->commandNameMap, commandName);
 	return (command == NULL) ? NULL : command;
 }
 
 void shell_addCommand(shell_pt shell, service_reference_pt reference) {
-    command_pt command = NULL;
+    command_service_pt command = NULL;
 	void *cmd = NULL;
 	bundleContext_getService(shell->bundleContext, reference, &cmd);
-	command = (command_pt) cmd;
-	hashMap_put(shell->commandNameMap, command->name, command);
+	command = (command_service_pt) cmd;
+	hashMap_put(shell->commandNameMap, command->getName(command->command), command);
 	hashMap_put(shell->commandReferenceMap, reference, command);
 }
 
 void shell_removeCommand(shell_pt shell, service_reference_pt reference) {
-	command_pt command = (command_pt) hashMap_remove(shell->commandReferenceMap, reference);
+	command_service_pt command = (command_service_pt) hashMap_remove(shell->commandReferenceMap,
reference);
 	if (command != NULL) {
-		hashMap_remove(shell->commandNameMap, command->name);
+		hashMap_remove(shell->commandNameMap, command->getName(command->command));
 	}
 }
 
@@ -215,34 +225,53 @@ celix_status_t bundleActivator_start(voi
 
 	    if (status == CELIX_SUCCESS) {
 	        activator->psCmd = psCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->psCmd,
NULL, &activator->psCommand);
+	        shell_createCommandService(pool, activator->psCmd, &activator->psCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->psCmdSrv,
NULL, &activator->psCommand);
 
 	        activator->startCmd = startCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->startCmd,
NULL, &activator->startCommand);
+	        shell_createCommandService(pool, activator->startCmd, &activator->startCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->startCmdSrv,
NULL, &activator->startCommand);
 
 	        activator->stopCmd = stopCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->stopCmd,
NULL, &activator->stopCommand);
+	        shell_createCommandService(pool, activator->stopCmd, &activator->stopCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->stopCmdSrv,
NULL, &activator->stopCommand);
 
 	        activator->installCmd = installCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->installCmd,
NULL, &activator->installCommand);
+	        shell_createCommandService(pool, activator->installCmd, &activator->installCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->installCmdSrv,
NULL, &activator->installCommand);
 
 	        activator->uninstallCmd = uninstallCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->uninstallCmd,
NULL, &activator->uninstallCommand);
+	        shell_createCommandService(pool, activator->uninstallCmd, &activator->uninstallCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->uninstallCmdSrv,
NULL, &activator->uninstallCommand);
 
 	        activator->updateCmd = updateCommand_create(context);
-	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->updateCmd,
NULL, &activator->updateCommand);
+	        shell_createCommandService(pool, activator->updateCmd, &activator->updateCmdSrv);
+	        bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->updateCmdSrv,
NULL, &activator->updateCommand);
 
 	        activator->logCmd = logCommand_create(context);
-            bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->logCmd,
NULL, &activator->logCommand);
+	        shell_createCommandService(pool, activator->logCmd, &activator->logCmdSrv);
+            bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->logCmdSrv,
NULL, &activator->logCommand);
 
             activator->inspectCmd = inspectCommand_create(context);
-			bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->inspectCmd,
NULL, &activator->inspectCommand);
+            shell_createCommandService(pool, activator->inspectCmd, &activator->inspectCmdSrv);
+			bundleContext_registerService(context, (char *) COMMAND_SERVICE_NAME, activator->inspectCmdSrv,
NULL, &activator->inspectCommand);
 	    }
 	}
 
 	return status;
 }
 
+static celix_status_t shell_createCommandService(apr_pool_t *pool, command_pt command, command_service_pt
*commandService) {
+	*commandService = apr_palloc(pool, sizeof(**commandService));
+	(*commandService)->command = command;
+	(*commandService)->executeCommand = command->executeCommand;
+	(*commandService)->getName = command_getName;
+	(*commandService)->getShortDescription = command_getShortDescription;
+	(*commandService)->getUsage = command_getUsage;
+
+	return CELIX_SUCCESS;
+}
+
 celix_status_t bundleActivator_stop(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
 	struct shellServiceActivator * activator = (struct shellServiceActivator *) userData;

Modified: incubator/celix/trunk/shell/private/src/start_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/start_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/start_command.c (original)
+++ incubator/celix/trunk/shell/private/src/start_command.c Thu Sep 19 09:10:10 2013
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"

Modified: incubator/celix/trunk/shell/private/src/stop_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/stop_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/stop_command.c (original)
+++ incubator/celix/trunk/shell/private/src/stop_command.c Thu Sep 19 09:10:10 2013
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"

Modified: incubator/celix/trunk/shell/private/src/uninstall_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/uninstall_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/uninstall_command.c (original)
+++ incubator/celix/trunk/shell/private/src/uninstall_command.c Thu Sep 19 09:10:10 2013
@@ -26,7 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"

Modified: incubator/celix/trunk/shell/private/src/update_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/private/src/update_command.c?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/update_command.c (original)
+++ incubator/celix/trunk/shell/private/src/update_command.c Thu Sep 19 09:10:10 2013
@@ -29,7 +29,7 @@
 #include <curl/curl.h>
 #include <curl/easy.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 #include "array_list.h"
 #include "bundle_context.h"
 #include "bundle.h"

Modified: incubator/celix/trunk/shell/public/include/command.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/public/include/command.h?rev=1524662&r1=1524661&r2=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/public/include/command.h (original)
+++ incubator/celix/trunk/shell/public/include/command.h Thu Sep 19 09:10:10 2013
@@ -31,6 +31,8 @@ static const char * const COMMAND_SERVIC
 
 typedef struct command * command_pt;
 
+typedef struct commandService * command_service_pt;
+
 struct commandService {
 	command_pt command;
 	char * (*getName)(command_pt command);

Copied: incubator/celix/trunk/shell/public/include/command_impl.h (from r1524045, incubator/celix/trunk/shell/public/include/command_private.h)
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/public/include/command_impl.h?p2=incubator/celix/trunk/shell/public/include/command_impl.h&p1=incubator/celix/trunk/shell/public/include/command_private.h&r1=1524045&r2=1524662&rev=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/public/include/command_private.h (original)
+++ incubator/celix/trunk/shell/public/include/command_impl.h Thu Sep 19 09:10:10 2013
@@ -17,7 +17,7 @@
  *under the License.
  */
 /*
- * command_private.h
+ * command_impl.h
  *
  *  \date       Aug 13, 2010
  *  \author    	<a href="mailto:celix-dev@incubator.apache.org">Apache Celix Project
Team</a>
@@ -40,5 +40,8 @@ struct command {
 	void (*executeCommand)(command_pt command, char * commandLine, void (*out)(char *), void
(*error)(char *));
 };
 
+char *command_getName(command_pt command);
+char *command_getUsage(command_pt command);
+char *command_getShortDescription(command_pt command);
 
 #endif /* COMMAND_PRIVATE_H_ */

Copied: incubator/celix/trunk/shell/public/src/command.c (from r1524045, incubator/celix/trunk/shell/private/src/command.c)
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/public/src/command.c?p2=incubator/celix/trunk/shell/public/src/command.c&p1=incubator/celix/trunk/shell/private/src/command.c&r1=1524045&r2=1524662&rev=1524662&view=diff
==============================================================================
--- incubator/celix/trunk/shell/private/src/command.c (original)
+++ incubator/celix/trunk/shell/public/src/command.c Thu Sep 19 09:10:10 2013
@@ -26,7 +26,7 @@
 
 #include <stdio.h>
 
-#include "command_private.h"
+#include "command_impl.h"
 
 char * command_getName(command_pt command) {
 	return command->name;



Mime
View raw message