Initial feature commit
[anna.git] / example / diameter / launcher / Launcher.cpp
index 116c325..aebebec 100644 (file)
@@ -25,6 +25,7 @@
 #include <anna/time/functions.hpp>
 #include <anna/diameter.comm/ApplicationMessageOamModule.hpp>
 #include <anna/xml/xml.hpp>
+#include <Procedure.hpp>
 
 // Process
 #include <Launcher.hpp>
@@ -1418,6 +1419,27 @@ std::string Launcher::help() const throw() {
   result += "\n   test|report-hex[|[yes]|no]    Reports could include the diameter messages in hexadecimal format. Disabled by default.";
   result += "\n";
   result += "\n";
+  result += "\n------------------------------------------------------------------------------------- Dynamic procedure";
+  result += "\n";
+  result += "\ndynamic[|args]                   This launch an internal operation implemented in 'Procedure' class.";
+  result += "\n                                 Its default implementation does nothing, but you could create a dynamic";
+  result += "\n                                 library 'libanna_launcherDynamic.so' and replace the one in this project.";
+  result += "\n                                 One interesting application consists in the use of the diameter API and";
+  result += "\n                                 event operation to create a set of libraries as the testing framework.";
+  result += "\n                                 To execute each test case, the ADML process would be executed with a";
+  result += "\n                                 specific library path. But the main use would be the stress programming";
+  result += "\n                                 to achieve a great amount of cloned (even mixed) tests without using";
+  result += "\n                                 the management operation interface by mean http or signals: a single";
+  result += "\n                                 call to 'dynamic' would be enough to start a cascade of internally";
+  result += "\n                                 implemented operations.";
+  result += "\n                                 This operation accepts a generic string argument (piped or not, as you";
+  result += "\n                                 desire and depending on your procedure implementation).";
+  result += "\n";
+  result += "\n                                 This operation requires advanced programming and knowlegde of ANNA Diameter";
+  result += "\n                                 stack and testing framework, to take advantage of all the possibilities.";
+  result += "\n";
+  result += "\n";
+  result += "\n";
   result += "\nUSING OPERATIONS INTERFACE";
   result += "\n--------------------------";
   result += "\n";
@@ -1510,6 +1532,17 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
   ///////////////////////////////////////////////////////////////////
   // Simple operations without arguments:
 
+  // Dynamic operation:
+  if(operation.find("dynamic") == 0) {
+    Procedure p(this);
+    int op_size = operation.size();
+    std::string args = ((operation.find("dynamic|") == 0) && (op_size > 8)) ? operation.substr(8) : "";
+    if (args == "" && op_size != 7)
+      throw anna::RuntimeException("Wrong body content format on HTTP Request. Use 'help' management command to see more information.", ANNA_FILE_LOCATION);
+    p.execute(args, response_content);
+    return;
+  }
+
   // Help:
   if(operation == "help") {
     response_content = help();