Diff of /src/MHiveConsole.cpp [000000] .. [379103]  Maximize  Restore

Switch to unified view

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

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

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks