summaryrefslogtreecommitdiff
path: root/cpp/test/IceSSL/configuration/TestI.cpp
blob: 9e24210437fb69d8df1f6194cef19b12af95bb04 (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
// **********************************************************************
//
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

#include <Ice/Ice.h>
#include <IceUtil/Thread.h>
#include <TestI.h>

using namespace std;
using namespace Ice;

ServerI::ServerI(const CommunicatorPtr& communicator) :
    _communicator(communicator)
{
}

void
ServerI::destroy()
{
    _communicator->destroy();
}

Test::ServerPrx
ServerFactoryI::createServer(const Test::Properties& props, const Current& current)
{
    PropertiesPtr properties = createProperties();
    for(Test::Properties::const_iterator p = props.begin(); p != props.end(); ++p)
    {
	properties->setProperty(p->first, p->second);
    }

    int argc = 0;
    char* argv[] = { "" };
    CommunicatorPtr communicator = initializeWithProperties(argc, argv, properties);
    ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("ServerAdapter", "ssl");
    ServerIPtr server = new ServerI(communicator);
    ObjectPrx obj = adapter->addWithUUID(server);
    _servers[obj->ice_getIdentity()] = server;
    adapter->activate();

    return Test::ServerPrx::uncheckedCast(obj);;
}

void
ServerFactoryI::destroyServer(const Test::ServerPrx& srv, const Ice::Current&)
{
    map<Identity, ServerIPtr>::iterator p = _servers.find(srv->ice_getIdentity());
    if(p != _servers.end())
    {
	p->second->destroy();
	_servers.erase(p);
    }
}

void
ServerFactoryI::shutdown(const Ice::Current& current)
{
    current.adapter->getCommunicator()->shutdown();
}