00001 #include "TestApi.h"
00002 #include "Configuration.h"
00003 #include "Sct/Exception.h"
00004
00005 #include "Sct_SctApi/SctApiServer.h"
00006 #include "Sct_SctApi/SctApiCrateServer.h"
00007 #include "sctConfIPC/configipc.h"
00008 #include "SctApi/Idiosyncrasy.h"
00009
00010 #include <ipc/core.h>
00011 #include <ipc/object.h>
00012 #include <ipc/server.h>
00013 #include <pmg/pmg_initSync.h>
00014 #include <Sct/Addressing.h>
00015
00016 #include <iostream>
00017 #include <boost/shared_ptr.hpp>
00018
00019 using namespace std;
00020 using namespace boost;
00021 using namespace SctConfiguration;
00022 using namespace SctTest;
00023
00024 IPCServer ipcServer;
00025 shared_ptr<SctConfiguration::Configuration> configServer;
00026
00027
00028
00029
00030
00031
00032
00033
00034 int main(int argc, char** argv) {
00035 Sct::setExceptionHandlers(argv[0]);
00036
00037 IPCCore::init(argc,argv);
00038 IPCPartition p("SCT");
00039
00040
00041 try {
00042
00043
00044
00045 const Sct::UCID arbitraryUcid(0,0);
00046 SctApi::Idiosyncrasy id(arbitraryUcid);
00047
00048 auto_ptr<TestApi> api(new TestApi(id));
00049
00050 if (!SctTest::Configuration::instance().publish()) {
00051 cout << "Failed to publish Configuration" << endl;
00052 return 2;
00053 }
00054
00055
00056
00057
00058
00059
00060 auto_ptr<SctApiCrateServer> h2(new SctApiCrateServer(*api));
00061
00062 SctApiServer::CrateDescriptors d; d.push_back(arbitraryUcid);
00063 auto_ptr<SctApiServer> h(new SctApiServer(d, Sct_SctApi::SctApiIPC::instanceName));
00064
00065
00066 if (!h->publish()) {
00067 cout << "Failed to publish SctTestApi" << std::endl;
00068 return 2;
00069 }
00070
00071 cout << "Serving...\n";
00072
00073
00074 pmg_initSync();
00075 ipcServer.run();
00076
00077 cout << "Run over" << std::endl;
00078 h->withdraw();
00079 SctTest::Configuration::instance().withdraw();
00080
00081
00082 } catch(SctConfiguration::ConfigurationException &c) {
00083 std::cout << "ConfigurationException: " << c.what() << std::endl;
00084
00085 MRSStream mrsStream(p);
00086 mrsStream << "SctTestApi" << MRS_FATAL << MRS_QUALIF("SctTestApi") << MRS_TEXT("Configuration server not running!") << ENDM;
00087
00088 exit(1);
00089 }
00090 }