~ubuntu-branches/ubuntu/quantal/zeroc-ice/quantal

« back to all changes in this revision

Viewing changes to test/Glacier2/addressFilter/Server.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Francisco Moya
  • Date: 2008-02-12 16:28:20 UTC
  • mfrom: (4.1.5 hardy)
  • Revision ID: james.westby@ubuntu.com-20080212162820-x3e046s7nmabeswv
Tags: 3.2.1-8
Added -g to global compilation flags (Closes: #465074).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// **********************************************************************
2
 
//
3
 
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
4
 
//
5
 
// This copy of Ice is licensed to you under the terms described in the
6
 
// ICE_LICENSE file included in this distribution.
7
 
//
8
 
// **********************************************************************
9
 
 
10
 
#include <Ice/Application.h>
11
 
#include <Ice/Locator.h>
12
 
#include <BackendI.h>
13
 
 
14
 
using namespace std;
15
 
using namespace Ice;
16
 
using namespace Test;
17
 
 
18
 
//
19
 
// Dummy ServerLocatorRegistry, ServerLocator and ServantLocator. For
20
 
// simplicity, we essentially 'alias' all possible requests to a single
21
 
// object adapter and a single servant.
22
 
//
23
 
class ServerLocatorRegistry : virtual public LocatorRegistry
24
 
{
25
 
public:
26
 
 
27
 
    virtual void 
28
 
    setAdapterDirectProxy_async(const AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb, const string&, 
29
 
                                const ObjectPrx&, const Current&)
30
 
    {
31
 
        cb->ice_response();
32
 
    }
33
 
 
34
 
    virtual void
35
 
    setReplicatedAdapterDirectProxy_async(const AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr& cb,
36
 
                                          const string&, const string&, const ObjectPrx&, const Current&)
37
 
    {
38
 
        cb->ice_response();
39
 
    }
40
 
 
41
 
    virtual void
42
 
    setServerProcessProxy_async(const AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
43
 
                                const string&, const ProcessPrx&, const Current&)
44
 
    {
45
 
        cb->ice_response();
46
 
    }
47
 
};
48
 
 
49
 
class ServerLocatorI : virtual public Locator
50
 
{
51
 
public:
52
 
    ServerLocatorI(const BackendPtr& backend, const ObjectAdapterPtr& adapter) :
53
 
        _backend(backend),
54
 
        _adapter(adapter),
55
 
        _registryPrx(
56
 
            LocatorRegistryPrx::uncheckedCast(
57
 
                adapter->add(new ServerLocatorRegistry, _adapter->getCommunicator()->stringToIdentity("registry"))))
58
 
    {
59
 
    }
60
 
 
61
 
    virtual void
62
 
    findObjectById_async(const AMD_Locator_findObjectByIdPtr& cb, const Identity& id, const Current&) const 
63
 
    { 
64
 
        cb->ice_response(_adapter->createProxy(id));
65
 
    }    
66
 
 
67
 
    virtual void
68
 
    findAdapterById_async(const AMD_Locator_findAdapterByIdPtr& cb, const string& id, const Current& current) const 
69
 
    {
70
 
       cb->ice_response(_adapter->createDirectProxy(_adapter->getCommunicator()->stringToIdentity("dummy")));   
71
 
    }
72
 
 
73
 
    virtual LocatorRegistryPrx 
74
 
    getRegistry(const Current&) const 
75
 
    { 
76
 
        return _registryPrx;
77
 
    }
78
 
 
79
 
private:
80
 
    const BackendPtr _backend;
81
 
    const ObjectAdapterPtr _adapter;
82
 
    const LocatorRegistryPrx _registryPrx;
83
 
};
84
 
 
85
 
class ServantLocatorI : virtual public ServantLocator
86
 
{
87
 
public:
88
 
 
89
 
    ServantLocatorI(const BackendPtr& backend) :
90
 
        _backend(backend)
91
 
    {
92
 
    }
93
 
        
94
 
    virtual ObjectPtr locate(const Current&, LocalObjectPtr&)
95
 
    {
96
 
        return _backend;
97
 
    }
98
 
 
99
 
    virtual void finished(const Current&, const ObjectPtr&, const LocalObjectPtr&)
100
 
    {
101
 
    }
102
 
 
103
 
    virtual void deactivate(const string&)
104
 
    {
105
 
    }
106
 
 
107
 
private:
108
 
 
109
 
    const BackendPtr _backend;
110
 
};
111
 
 
112
 
class BackendServer : public Application
113
 
{
114
 
public:
115
 
 
116
 
    virtual int run(int, char*[]);
117
 
};
118
 
 
119
 
int
120
 
main(int argc, char* argv[])
121
 
{
122
 
    BackendServer app;
123
 
    return app.main(argc, argv);
124
 
}
125
 
 
126
 
int
127
 
BackendServer::run(int argc, char* argv[])
128
 
{
129
 
    string endpoints = 
130
 
        communicator()->getProperties()->getPropertyWithDefault("BackendAdapter.Endpoints", 
131
 
                                                                "tcp -p 12010 -t 20000:ssl -p 12011 -t 20000");
132
 
 
133
 
    communicator()->getProperties()->setProperty("BackendAdapter.Endpoints", endpoints);
134
 
    ObjectAdapterPtr adapter = communicator()->createObjectAdapter("BackendAdapter");
135
 
    BackendPtr backend = new BackendI;
136
 
    Ice::LocatorPtr locator = new ServerLocatorI(backend, adapter);
137
 
    adapter->add(locator, communicator()->stringToIdentity("locator"));
138
 
    adapter->addServantLocator(new ServantLocatorI(backend), "");
139
 
    adapter->activate();
140
 
    communicator()->waitForShutdown();
141
 
    return EXIT_SUCCESS;
142
 
}