[379103]: src / MHiveConsole.cpp  Maximize  Restore  History

Download this file

103 lines (90 with data), 3.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
/*
* File: MhiveClient.cpp
* Author: HoelscJ
*
* Created on 6. September 2010, 12:50
*/
#include <cstdlib>
#include "org/esb/util/StringUtil.h"
using namespace std;
char *getmyline()
{
char *buf, *str = 0;
buf = (char*)malloc(1);
int strlength = 0;
fread(buf, 1, 1, stdin);
while(!feof(stdin) && (*buf != '\n')) {
strlength++;
str = (char*)realloc(str, strlength);
*(str + strlength-1) = *buf;
fread(buf, 1, 1, stdin);
}
if(feof(stdin))return NULL;
free(buf);
strlength++;
str = (char*)realloc(str, strlength);
*(str + strlength-1) = '\0';
return str;
}
bool startserver(){
org::esb::hive::DatabaseService::start(org::esb::config::Config::getProperty("hive.base_path"));
int port=atoi(org::esb::config::Config::getProperty("web.port"));
new org::esb::api::JsonServer(port);
org::esb::hive::ExportScanner expscan;
org::esb::signal::Messenger::getInstance().addMessageListener(*new org::esb::hive::ExportScanner());
org::esb::hive::HiveListener hive;
org::esb::signal::Messenger::getInstance().addMessageListener(*new org::esb::hive::HiveListener());
org::esb::hive::job::ProcessUnitController puw;
org::esb::signal::Messenger::getInstance().addMessageListener(*new org::esb::hive::job::ProcessUnitController());
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("webserver", org::esb::hive::START));
string base_path = org::esb::config::Config::getProperty("hive.base_path");
org::esb::signal::Messenger::getInstance().sendMessage(org::esb::signal::Message().setProperty("processunitcontroller", org::esb::hive::START));
org::esb::signal::Messenger::getInstance().sendMessage(org::esb::signal::Message().setProperty("hivelistener", org::esb::hive::START));
org::esb::signal::Messenger::getInstance().sendRequest(org::esb::signal::Message().setProperty("exportscanner", org::esb::hive::START));
}
bool stopserver(){
}
bool startclient(){
}
bool stopclient(){
}
/*
*
*/
int console() {
char * line=NULL;
std::cout<<"Welcome to the mhive console."<<std::endl;
std::cout<<"type help to get a list of available commands."<<std::endl;
do{
std::cout <<"mhive>";
if((line=getmyline())==NULL)break;
std::string l=org::esb::util::StringUtil::trim(line,"\n");
if(l=="help"){
std::cout<<"help -> print this help"<<std::endl;
std::cout<<"start server -> starts the mhive server"<<std::endl;
std::cout<<"start client -> starts the mhive client which will connect to first server found by auto discovery"<<std::endl;
std::cout<<"start client [IP|HOSTNAME][:PORT] -> starts the mhive client which will connect to the given server connection"<<std::endl;
std::cout<<"stop server -> stops the mhive server"<<std::endl;
std::cout<<"stop client -> stops the mhive client"<<std::endl;
}else
//if(l=="start"){
// std::cout<<"hee? start server, start client?"<<std::endl;
//}else
if(l=="start server"){
startserver();
std::cout<<"start server"<<std::endl;
}else
if(l.find("start client")!=string::npos){
std::cout<<"start client"<<std::endl;
}else
if(l=="exit"){
std::cout<<"exiting the mhive console, bye"<<std::endl;
break;
}else
if(l.length()>0){
std::cout<<"hee? unknown command "<<l<<std::endl;
std::cout<<"type help to get a list of available commands"<<std::endl;
}
}while(line);
return 0;
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks