summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/LocatorI.cpp
blob: 2eb90bf134ace0d5f60568c219803a77ba55f309 (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
// **********************************************************************
//
// Copyright (c) 2001
// ZeroC, Inc.
// Billerica, MA, USA
//
// All Rights Reserved.
//
// Ice is free software; you can redistribute it and/or modify it under
// the terms of the GNU General Public License version 2 as published by
// the Free Software Foundation.
//
// **********************************************************************

#include <Ice/Ice.h>
#include <IcePack/LocatorI.h>

using namespace std;
using namespace IcePack;

IcePack::LocatorI::LocatorI(const AdapterRegistryPtr& adapterRegistry, 
			    const Ice::LocatorRegistryPrx& locatorRegistry) :
    _adapterRegistry(adapterRegistry),
    _locatorRegistry(locatorRegistry)
{
}

Ice::ObjectPrx 
IcePack::LocatorI::findAdapterByName(const string& name, const Ice::Current&) const
{
    //
    // TODO: I think will need to do something more sensible in cases
    // where the adapter is found but the adapter proxy is null
    // (possibly because the server activation failed or timed out) or
    // if the adapter object isn't reachable (possibly because the
    // IcePack node is down or unreachable). Right now the Ice cleint
    // will always throw a NoEndpointException because we return a
    // null proxy here...
    //

    try
    {
	return _adapterRegistry->findByName(name)->getDirectProxy(true);
    }
    catch(const AdapterNotExistException&)
    {
    }
    catch(const Ice::ObjectNotExistException&)
    {
	//
	// Expected if the adapter is destroyed.
	//
    }
    catch(const Ice::NoEndpointException&)
    {
	//
	// This could be because we can't locate the IcePack node
	// adapter. IcePack server adapter proxy are not direct proxy.
	//
    }
    catch(const Ice::LocalException&)
    {
	//
	// Expected if we couldn't contact the adapter object
	// (possibly because the IcePack node is down).
	//
    }

    return 0;
}

Ice::LocatorRegistryPrx
IcePack::LocatorI::getRegistry(const Ice::Current&) const
{
    return _locatorRegistry;
}