Ejemplo n.º 1
0
void on_initialize(const string_t& address)
{

  // session factory used to create sessions.
  std::shared_ptr<granada::http::session::SessionFactory> session_factory(new granada::http::session::RedisSessionFactory());

  ////
  // Browser Controller
  // Permits to browse server resources.
  // get property "browser_module" from the server configuration file
  // If this property equals "on" we will use browser controller.
  std::string browser_module = granada::util::application::GetProperty("browser_controller");
  if(!browser_module.empty() && browser_module=="on"){
    uri_builder uri(address);
    auto addr = uri.to_uri().to_string();
    std::unique_ptr<granada::http::controller::Controller> browser_controller(new granada::http::controller::BrowserController(addr,session_factory));
    browser_controller->open().wait();
    g_controllers.push_back(std::move(browser_controller));
    ucout << "Browser Controller: Initialized... Listening for requests at: " << addr << std::endl;
  }

  // factory used to create Plug-in Handlers, Plug-ins, Plug-in Factories.
  std::shared_ptr<granada::plugin::RedisSpidermonkeyPluginFactory> plugin_factory(new granada::plugin::RedisSpidermonkeyPluginFactory());

  ////
  // Plugin Controller
  //
  uri_builder plugin_uri(address);
  plugin_uri.append_path(U("plugin"));
  auto addr = plugin_uri.to_uri().to_string();
  std::unique_ptr<granada::http::controller::PluginController> plugin_controller(new granada::http::controller::PluginController(addr,session_factory,plugin_factory));
  plugin_controller->open().wait();
  g_controllers.push_back(std::move(plugin_controller));
  ucout << "Plugin Controller: Initialized... Listening for requests at: " << addr << std::endl;

  return;
}
Ejemplo n.º 2
0
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
    /// Move the test to the real-time class if it is possible.
    RT_Class rt_class;

    try
    {
        ORB_Holder orb (argc, argv, "");

        if (parse_args (argc, argv) != 0)
            return 1;

        RTServer_Setup rtserver_setup (use_rt_corba,
                                       orb,
                                       rt_class,
                                       nthreads);

        PortableServer::POA_var root_poa =
            RIR_Narrow<PortableServer::POA>::resolve (orb,
                    "RootPOA");

        PortableServer::POAManager_var poa_manager =
            root_poa->the_POAManager ();

        poa_manager->activate ();

        PortableServer::POA_var the_poa (rtserver_setup.poa ());

        ORB_Task orb_task (orb);
        ORB_Task_Activator orb_task_activator (rt_class.priority_high (),
                                               rt_class.thr_sched_class (),
                                               nthreads,
                                               &orb_task);

        ACE_DEBUG ((LM_DEBUG, "Finished ORB and POA configuration\n"));

        Servant_var<Session_Factory> session_factory (
            new Session_Factory (orb,
                                 the_poa.in ())
        );

        CORBA::Object_var object =
            session_factory->_this ();

        CORBA::String_var ior =
            orb->object_to_string (object.in ());

        // Output the ior to the <ior_output_file>
        FILE *output_file = ACE_OS::fopen (ior_output_file, "w");
        if (output_file == 0)
            ACE_ERROR_RETURN ((LM_ERROR,
                               "Cannot open output file for writing IOR: %s",
                               ior_output_file),
                              1);
        ACE_OS::fprintf (output_file, "%s", ior.in ());
        ACE_OS::fclose (output_file);

        orb->run ();

        ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
    }
    catch (const CORBA::Exception& ex)
    {
        ex._tao_print_exception ("Exception caught:");
        return 1;
    }

    return 0;
}