summaryrefslogtreecommitdiff
path: root/CIAO/ciao/Contexts/Session/Session_Context_T.cpp
blob: 37fff51c5541fefa19c8965860401f5bb078e3a6 (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
#ifndef CIAO_SESSION_CONTEXT_IMPL_T_C
#define CIAO_SESSION_CONTEXT_IMPL_T_C

namespace CIAO
{
  template <typename BASE_CTX,
            typename COMP>
  Session_Context_Impl_T<BASE_CTX, COMP>::Session_Context_Impl_T (
      Components::CCMHome_ptr the_home,
      ::CIAO::Session_Container_ptr c,
      PortableServer::Servant sv,
      const char* id)
    : Context_Impl_Base_T < ::CIAO::Session_Container> (the_home, c, id),
      servant_ (sv)
  {
  }

  template <typename BASE_CTX,
            typename COMP>
  Session_Context_Impl_T<BASE_CTX, COMP>::~Session_Context_Impl_T (void)
  {
  }

  template <typename BASE_CTX,
            typename COMP>
  ::CORBA::Object_ptr
  Session_Context_Impl_T<BASE_CTX, COMP>::get_CCM_object (void)
  {
    ::CORBA::Object_var obj;

    try
      {
        ::CIAO::Session_Container_var cnt_safe =
          ::CIAO::Session_Container::_duplicate (this->container_.in ());
        if (::CORBA::is_nil (cnt_safe.in ()))
          {
            CIAO_ERROR (1,
                        (LM_ERROR,
                        CLINFO
                        "Session_Context_Impl_T::get_CCM_object - "
                        "Error: Container is nil\n"));
            throw ::CORBA::INV_OBJREF ();
          }
        obj = cnt_safe->get_objref (this->servant_);
      }
    catch (const CORBA::Exception& ex)
      {
        ex._tao_print_exception ("Caught Exception\n");
      }

    typename COMP::_var_type component = COMP::_narrow (obj.in ());

    if (::CORBA::is_nil (component.in ()))
      {
        throw ::CORBA::INTERNAL ();
      }

    return component._retn ();
  }
}

#endif /* CIAO_SESSION_CONTEXT_IMPL_T_C */