summaryrefslogtreecommitdiff
path: root/cpp/src/IcePack/LocatorI.cpp
blob: ab2822d7fbf02b662001445e449f57bf592af653 (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
// **********************************************************************
//
// Copyright (c) 2002
// 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::findAdapterById(const string& id, 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 client
    // will always throw a NoEndpointException because we return a
    // null proxy here...
    //

    try
    {
	return _adapterRegistry->findById(id)->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 proxies are not direct
	// proxies)
	//
    }
    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;
}