summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/IFR_Service/Servant_Locator.cpp
blob: 4065aead98c150419bf75b82aa604b9d363d19fe (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
// $Id$

#include "Servant_Locator.h"
#include "Servant_Factory.h"
#include "Repository_i.h"

ACE_RCSID(IFR_Service, Servant_Locator, "$Id$")

IFR_ServantLocator::IFR_ServantLocator (TAO_Repository_i *repo)
  : repo_ (repo)
{
}

PortableServer::Servant
IFR_ServantLocator::preinvoke (
    const PortableServer::ObjectId &oid,
    PortableServer::POA_ptr poa,
    const char * /* operation */,
    PortableServer::ServantLocator::Cookie &cookie
    ACE_ENV_ARG_DECL
  )
  ACE_THROW_SPEC ((CORBA::SystemException,
                   PortableServer::ForwardRequest))
{
  CORBA::String_var s =
    PortableServer::ObjectId_to_string (oid);

  ACE_Configuration_Section_Key servant_key;
  int status =
    this->repo_->config ()->expand_path (this->repo_->root_key (),
                                         s.in (),
                                         servant_key,
                                         0);

  if (status != 0)
    {
      // If we're here, destroy() has been called.
      ACE_THROW_RETURN (CORBA::OBJECT_NOT_EXIST (), 0);
    }

  PortableServer::Servant servant =
    this->repo_->servant_factory ()->create_tie (servant_key,
                                                 poa
                                                 ACE_ENV_ARG_PARAMETER);
  ACE_CHECK_RETURN (0);

  cookie = servant;

  return servant;
}

void
IFR_ServantLocator::postinvoke (
    const PortableServer::ObjectId & /* oid */,
    PortableServer::POA_ptr /* poa */,
    const char * /* operation */,
    PortableServer::ServantLocator::Cookie /* cookie */,
    PortableServer::Servant servant
    ACE_ENV_ARG_DECL_NOT_USED
  )
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  delete servant;
}