summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Bug_2074_Regression/ORB_Task.cpp
blob: 41e64a4dd51d92cf868b8d61a3287d1a2dbbfbc1 (plain)
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
/**
 * @file ORB_Task.cpp
 *
 * $Id$
 *
 * @author Carlos O'Ryan <coryan@atdesk.com>
 *
 */
#include "ORB_Task.h"
#include "tao/Messaging/Messaging.h"
#include "orbsvcs/CosNamingC.h"

ACE_RCSID(Bug_2074_Regression, ORB_Task, "$Id$")

ORB_Task::ORB_Task (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
{
}

int
ORB_Task::svc (void)
{
  try
  {
    CORBA::Object_var ncRef =
        orb_->string_to_object(
            "corbaloc:iiop:10.175.12.99:15025/NameService" );

    CORBA::PolicyList policies;

    TimeBase::TimeT timeout = 5000 * 10000;

    CORBA::Any timeoutAny;
    timeoutAny <<= timeout;

    policies.length(1);
    policies[0] = orb_->create_policy(
      Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
      timeoutAny );

    CORBA::Object_var object = ncRef->_set_policy_overrides(
      policies, CORBA::SET_OVERRIDE );

    policies[0]->destroy();

    CosNaming::NamingContext_var namingContext =
      CosNaming::NamingContext::_narrow( object.in() );
    namingContext->_non_existent();
  }
  catch ( const CORBA::TRANSIENT&)
  {
    ACE_DEBUG ((LM_DEBUG, "Caught transient\n"));
  }
  catch ( const CORBA::TIMEOUT&)
  {
    ACE_DEBUG ((LM_DEBUG, "Caught timeout\n"));
  }
  catch ( const CORBA::Exception& e )
  {
      ACE_PRINT_EXCEPTION (e, "Exception caught");
  }

  return 0;
}