Beispiel #1
0
Datei: main.cpp Projekt: CCJY/ACE
int
ACE_TMAIN (int, ACE_TCHAR *argv[])
{
  ACE_Service_Config daemon;
  ACE_ARGV new_args;

  // Load the existing <argv> into our new one.
  new_args.add (argv);
  // Enable loading of static services.
  new_args.add (ACE_TEXT ("-y"));
  // Enable debugging within dynamically linked services.
  new_args.add (ACE_TEXT ("-d"));

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("argc = %d\n"),
              new_args.argc ()));

  // Print the contents of the combined <ACE_ARGV>.
  for (int i = 0; i < new_args.argc (); i++)
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%d) %s\n"),
                i,
                new_args.argv ()[i]));

  if (daemon.open (new_args.argc (),
                   new_args.argv ()) == -1)
    {
      if (errno != ENOENT)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")),
                          1);
      else // Use static binding.
        {
          ACE_ARGV args;

          args.add (argv[0]);
          args.add (ACE_TEXT ("-p10011")); // Port number.
          ACE_Service_Object *so =
            ACE_SVC_INVOKE (ACE_Naming_Context);

          if (so->init (args.argc (),
                        args.argv ()) == -1)
            ACE_ERROR_RETURN ((LM_ERROR,
                               ACE_TEXT ("%p\n"),
                               ACE_TEXT ("ACE_Naming_Context")),
                              1);
        }
    }

  Client_Test test_body;
  if (test_body.open () == -1)
    return 1;

  // Run forever, performing the configured services until we are shut
  // down by a SIGINT/SIGQUIT signal.

  ACE_Reactor::instance ()->run_reactor_event_loop ();
  test_body.close ();

  return 0;
}
int
ACE_Service_Object_Type::init (int argc, ACE_TCHAR *argv[]) const
{
    ACE_TRACE ("ACE_Service_Object_Type::init");

    void *obj = this->object ();
    ACE_Service_Object *so = (ACE_Service_Object *) obj;

    if (so == 0)
        return -1;
    else
        return so->init (argc, argv);
}
int
ACE_Service_Object_Type::fini (void) const
{
    ACE_TRACE ("ACE_Service_Object_Type::fini");

    void *obj = this->object ();

    ACE_Service_Object *so = (ACE_Service_Object *) obj;

    if (so)
    {
        so->fini ();

#if 0
        if (ACE_BIT_ENABLED (this->flags_,
                             ACE_Service_Type::DELETE_OBJ))
            delete so;
#endif /* 1 */
    }

    return ACE_Service_Type_Impl::fini ();
}
Beispiel #4
0
int
ACE_TMAIN (int, ACE_TCHAR* argv[])
{
#if defined (ACE_HAS_MONITOR_FRAMEWORK) && (ACE_HAS_MONITOR_FRAMEWORK == 1)

  try
    {
      if (ACE_Service_Config::open (argv[0]) != 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR, "Unable to load the TAO_MonitorAndControl\n"), 1);
        }

      // Run the service.
      const ACE_Service_Type* st = 0;
      ACE_Service_Repository::instance ()->find (ACE_TEXT("TAO_MonitorAndControl"),
                                                 &st);
      if (st == 0)
        {
          ACE_ERROR_RETURN ((LM_ERROR, "Failed to find the TAO_MonitorAndControl instance\n"), 1);
        }

      ACE_Service_Object* obj =
        (ACE_Service_Object*) st->type ()->object ();
      obj->resume ();

      // Wait for an external entity to stop it.
      ACE_Thread_Manager::instance ()->wait ();
    }
  catch (...)
    {
      ACE_ERROR_RETURN ((LM_ERROR, "Caught an unexpected exception type\n"), 1);
    }
#else /* ACE_HAS_MONITOR_FRAMEWORK==1 */
  ACE_UNUSED_ARG (argv);
#endif /* ACE_HAS_MONITOR_FRAMEWORK==1 */

  return 0;
}