summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/ESF/ESF_Proxy_Admin.cpp
blob: f0b9b6f9fb1e105678065bbec8f07e50b562915f (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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// $Id$

#ifndef TAO_ESF_PROXY_ADMIN_CPP
#define TAO_ESF_PROXY_ADMIN_CPP

#include "ESF_Proxy_Admin.h"

#if ! defined (__ACE_INLINE__)
#include "ESF_Proxy_Admin.i"
#endif /* __ACE_INLINE__ */

#include "ESF_Shutdown_Proxy.h"

ACE_RCSID(ESF, ESF_Proxy_Admin, "$Id$")

template<class EC, class P>
TAO_ESF_Proxy_Admin<EC,P>::TAO_ESF_Proxy_Admin (EC *ec)
  :  event_channel_ (ec)
{
  this->event_channel_->create_proxy_collection (this->collection_);
}

template<class EC, class P>
TAO_ESF_Proxy_Admin<EC,P>::~TAO_ESF_Proxy_Admin (void)
{
  this->event_channel_->destroy_proxy_collection (this->collection_);
}

template<class EC, class PROXY> ACE_TYPENAME PROXY::_ptr_type
TAO_ESF_Proxy_Admin<EC,PROXY>::obtain (CORBA::Environment &)
  ACE_THROW_SPEC (())
{
  PROXY* proxy;
  this->event_channel_->create_proxy (proxy);

  PortableServer::ServantBase_var holder = proxy;

  ACE_TYPENAME PROXY::_var_type result =
    proxy->activate (ACE_TRY_ENV);
  ACE_CHECK_RETURN (PROXY::Interface::_nil ());

  this->collection_->connected (proxy, ACE_TRY_ENV);
  ACE_CHECK_RETURN (PROXY::Interface::_nil ());

  return result._retn ();
}

template<class EC, class P> void
TAO_ESF_Proxy_Admin<EC,P>::shutdown (CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC (())
{
  TAO_ESF_Shutdown_Proxy<P> worker;

  this->collection_->for_each (&worker, ACE_TRY_ENV);
  ACE_CHECK; // Cannot happen, just following the discipline.

  this->collection_->shutdown (ACE_TRY_ENV);
}

template<class EC, class P> void
TAO_ESF_Proxy_Admin<EC,P>::connected (P *,
                                      CORBA::Environment &)
  ACE_THROW_SPEC (())
{
}

template<class EC, class P> void
TAO_ESF_Proxy_Admin<EC,P>::reconnected (P *proxy,
                                        CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC (())
{
  this->collection_->reconnected (proxy, ACE_TRY_ENV);
}

template<class EC, class P> void
TAO_ESF_Proxy_Admin<EC,P>::disconnected (P *proxy,
                                         CORBA::Environment &ACE_TRY_ENV)
  ACE_THROW_SPEC (())
{
  ACE_TRY
    {
      this->collection_->disconnected (proxy, ACE_TRY_ENV);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      // @@ In the future the collections may raise exceptions to
      // report errors (such as out of memory or things like that).
      // We must decide how is that info going to be used, and how
      // would we propagate the exception to the application.
      // For example: the CosEC has no exceptions for "out of
      // resources" or something similar, and i've never seen a spec
      // that has an exception for "could not acquire a mutex".
    }
  ACE_ENDTRY;

  proxy->deactivate (ACE_TRY_ENV);
  ACE_CHECK; // Cannot happen, just following the discipline.
}

#endif /* TAO_ESF_PROXY_ADMIN_CPP */