summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciao/Servant_Activator.h
blob: 9a3cfc58644e92819294d6e44b1aa30b4f96093a (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
102
103
104
105
106
107
108
109
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Servant_Activator.h
 *
 *  $Id$
 *
 *  @authors Balachandran Natarajan <bala@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef CIAO_SERVANT_ACTIVATOR_H
#define CIAO_SERVANT_ACTIVATOR_H
#include /**/ "ace/pre.h"

#include "ace/Array_Base.h"
#include "ciao/CIAO_Server_Export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "tao/PortableServer/PortableServer.h"
#include "tao/PortableServer/ServantActivatorC.h"
#include "tao/PortableServer/ForwardRequestC.h"
#include "tao/LocalObject.h"

#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4250)
#endif /* _MSC_VER */

namespace CIAO
{
  class Port_Activator;

  /**
   * @class Servant_Activator
   *
   * @brief Activator that is registered with the POA for facet and
   * consumer servants.
   *
   * This class acts like a factory in some sense. This factory is
   * registered with the POA with RETAIN policy. When the factory gets
   * a call back as part of the upcall, this factory looks at the
   * list of port activators registered, uses the OID to pick the
   * right one (yes a linear algorithm is used), calls activate () on
   * it which returns the servant for *that* port.
   */
  class CIAO_SERVER_Export Servant_Activator
    : public virtual PortableServer::ServantActivator
    , public virtual TAO_Local_RefCounted_Object
  {
  public:
    Servant_Activator (CORBA::ORB_ptr o);

    virtual ~Servant_Activator (void);

    bool update_port_activator (const PortableServer::ObjectId &oid)
      ACE_THROW_SPEC ((CORBA::SystemException));

    /// Template methods overridden to get callbacks.
    /**
     * If you would like to know the details of the following two
     * methods, please PortableServer documentation. This is probably
     * not the place to document what these mean.
     */
    PortableServer::Servant incarnate (
      const PortableServer::ObjectId &oid,
      PortableServer::POA_ptr poa)
      ACE_THROW_SPEC ((CORBA::SystemException,
                       PortableServer::ForwardRequest));

    void etherealize (const PortableServer::ObjectId &oid,
                      PortableServer::POA_ptr adapter,
                      PortableServer::Servant servant,
                      CORBA::Boolean cleanup_in_progress,
                      CORBA::Boolean remaining_activations)
      ACE_THROW_SPEC ((CORBA::SystemException));

    /// Local helper methods
    bool register_port_activator (Port_Activator *pa);

  private:
    /// Pointer to our ORB
    CORBA::ORB_var orb_;

    /// @@ This should be changed at some point of time so that we
    /// don't  land up with a linear algorithm
    typedef ACE_Array_Base<Port_Activator *> Port_Activators;

    /// Array of port activators
    Port_Activators pa_;

    /// Running index of the slot that has been just filled in.
    size_t slot_index_;

    /// Mutex that synchronizes access to the array.
    ACE_SYNCH_MUTEX  mutex_;
  };
}

#if defined(_MSC_VER)
#pragma warning(pop)
#endif /* _MSC_VER */

#include /**/ "ace/post.h"
#endif /*CIAO_SERVANT_ACTIVATOR_H*/