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

« back to all changes in this revision

Viewing changes to test/Ice/objects/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
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.
13
13
using namespace std;
14
14
using namespace Test;
15
15
 
 
16
class MyObjectFactory : public Ice::ObjectFactory
 
17
{
 
18
public:
 
19
 
 
20
    virtual Ice::ObjectPtr create(const string& type)
 
21
    {
 
22
        if(type == "::Test::I")
 
23
        {
 
24
            return new II;
 
25
        }
 
26
        else if(type == "::Test::J")
 
27
        {
 
28
            return new JI;
 
29
        }
 
30
        else if(type == "::Test::H")
 
31
        {
 
32
            return new HI;
 
33
        }
 
34
 
 
35
        assert(false); // Should never be reached
 
36
        return 0;
 
37
    }
 
38
 
 
39
    virtual void destroy()
 
40
    {
 
41
        // Nothing to do
 
42
    }
 
43
};
 
44
 
16
45
int
17
46
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
18
47
{
 
48
    Ice::ObjectFactoryPtr factory = new MyObjectFactory;
 
49
    communicator->addObjectFactory(factory, "::Test::I");
 
50
    communicator->addObjectFactory(factory, "::Test::J");
 
51
    communicator->addObjectFactory(factory, "::Test::H");
 
52
 
19
53
    communicator->getProperties()->setProperty("TestAdapter.Endpoints", "default -p 12010 -t 10000");
20
54
    Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("TestAdapter");
21
55
    InitialPtr initial = new InitialI(adapter);
22
56
    adapter->add(initial, communicator->stringToIdentity("initial"));
 
57
    UnexpectedObjectExceptionTestIPtr uoet = new UnexpectedObjectExceptionTestI;
 
58
    adapter->add(uoet, communicator->stringToIdentity("uoet"));
23
59
    adapter->activate();
24
60
    communicator->waitForShutdown();
25
61
    return EXIT_SUCCESS;
33
69
 
34
70
    try
35
71
    {
36
 
        communicator = Ice::initialize(argc, argv);
37
 
        status = run(argc, argv, communicator);
 
72
        communicator = Ice::initialize(argc, argv);
 
73
        status = run(argc, argv, communicator);
38
74
    }
39
75
    catch(const Ice::Exception& ex)
40
76
    {
41
 
        cerr << ex << endl;
42
 
        status = EXIT_FAILURE;
 
77
        cerr << ex << endl;
 
78
        status = EXIT_FAILURE;
43
79
    }
44
80
 
45
81
    if(communicator)
46
82
    {
47
 
        try
48
 
        {
49
 
            communicator->destroy();
50
 
        }
51
 
        catch(const Ice::Exception& ex)
52
 
        {
53
 
            cerr << ex << endl;
54
 
            status = EXIT_FAILURE;
55
 
        }
 
83
        try
 
84
        {
 
85
            communicator->destroy();
 
86
        }
 
87
        catch(const Ice::Exception& ex)
 
88
        {
 
89
            cerr << ex << endl;
 
90
            status = EXIT_FAILURE;
 
91
        }
56
92
    }
57
93
 
58
94
    return status;