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

« back to all changes in this revision

Viewing changes to demo/Freeze/phonebook/Collocated.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
1
// **********************************************************************
2
2
//
3
 
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
 
3
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
4
4
//
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
19
19
public:
20
20
    
21
21
    PhoneBookCollocated(const string& envName) :
22
 
        _envName(envName)
 
22
        _envName(envName)
23
23
    {
24
24
    }
25
25
 
26
26
    virtual int run(int argc, char* argv[]);
 
27
    virtual void interruptCallback(int);
27
28
 
28
29
private:
29
30
 
40
41
int
41
42
PhoneBookCollocated::run(int argc, char* argv[])
42
43
{
 
44
    //
 
45
    // Since this is an interactive demo we want the custom interrupt
 
46
    // callback to be called when the process is interrupted.
 
47
    //
 
48
    callbackOnInterrupt();
 
49
 
43
50
    Ice::PropertiesPtr properties = communicator()->getProperties();
44
51
 
45
52
    //
72
79
    Freeze::EvictorPtr evictor = Freeze::createEvictor(adapter, _envName, "contacts", 0, indices);
73
80
    adapter->addServantLocator(evictor, "contact");
74
81
 
75
 
    Ice::Int evictorSize = properties->getPropertyAsInt("PhoneBook.EvictorSize");
 
82
    Ice::Int evictorSize = properties->getPropertyAsInt("EvictorSize");
76
83
    if(evictorSize > 0)
77
84
    {
78
 
        evictor->setSize(evictorSize);
 
85
        evictor->setSize(evictorSize);
79
86
    }
80
87
 
81
88
    //
96
103
    //
97
104
    int runParser(int, char*[], const Ice::CommunicatorPtr&);
98
105
    int status = runParser(argc, argv, communicator());
99
 
    adapter->deactivate();
100
 
    adapter->waitForDeactivate();
 
106
    adapter->destroy();
101
107
 
102
108
    return status;
103
109
}
 
110
 
 
111
void
 
112
PhoneBookCollocated::interruptCallback(int)
 
113
{
 
114
    try
 
115
    {
 
116
        communicator()->destroy();
 
117
    }
 
118
    catch(const IceUtil::Exception& ex)
 
119
    {
 
120
        cerr << appName() << ": " << ex << endl;
 
121
    }
 
122
    catch(...)
 
123
    {
 
124
        cerr << appName() << ": unknown exception" << endl;
 
125
    }
 
126
    exit(EXIT_SUCCESS);
 
127
}