summaryrefslogtreecommitdiff
path: root/cpp/src/Glacier/ClientBlobject.cpp
blob: bff9072f25acce97943f3092aceb633fd08ad2ca (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
// MutableRealms, Inc.
// Huntsville, AL, USA
//
// All Rights Reserved
//
// **********************************************************************

#include <Ice/RoutingTable.h>
#include <Glacier/ClientBlobject.h>

using namespace std;
using namespace Ice;
using namespace Glacier;

Glacier::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator,
					const IceInternal::RoutingTablePtr& routingTable) :
    _communicator(communicator),
    _logger(_communicator->getLogger()),
    _routingTable(routingTable)
{
    PropertiesPtr properties = _communicator->getProperties();
    _traceLevel = atoi(properties->getProperty("Glacier.Trace.Client").c_str());
}

void
Glacier::ClientBlobject::destroy()
{
    // No mutex protection necessary, destroy is only called after all
    // object adapters have shut down.
    _communicator = 0;
    _logger = 0;
    _routingTable = 0;
}

void
Glacier::ClientBlobject::ice_invoke(const std::vector<Byte>& inParams, std::vector<Byte>& outParams,
				    const Current& current)
{
    assert(_communicator); // Destroyed?

    try
    {
	ObjectPrx proxy = _routingTable->get(current.identity);
	
	if (!proxy)
	{
	    throw ObjectNotExistException(__FILE__, __LINE__);
	}
	
	if (!current.facet.empty())
	{
	    proxy = proxy->ice_newFacet(current.facet);
	}
	
	if (!current.response)
	{
	    proxy = proxy->ice_oneway();
	}
	
	proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams, current.context);
    }
    catch (const Exception& ex)
    {
	if (_traceLevel)
	{
	    ostringstream s;
	    s << "routing exception:\n" << ex;
	    _logger->trace("Glacier", s.str());
	}

	ex.ice_throw();
    }
}