blob: 02ea1c89c43863539bfd036e5345ed306aba7db6 (
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) 2003-2004 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 <Ice/Locator.h>
#include <TestI.h>
ServerManagerI::ServerManagerI(const Ice::ObjectAdapterPtr& adapter) :
_adapter(adapter)
{
}
void
ServerManagerI::startServer(const Ice::Current&)
{
int argc = 0;
char** argv = 0;
//
// Simulate a server: create a new communicator and object
// adapter. The object adapter is started on a system allocated
// port. The configuration used here contains the Ice.Locator
// configuration variable. The new object adapter will register
// its endpoints with the locator and create references containing
// the adapter id instead of the endpoints.
//
_serverCommunicator = Ice::initialize(argc, argv);
_serverCommunicator->getProperties()->setProperty("TestAdapter.Endpoints", "default");
_serverCommunicator->getProperties()->setProperty("TestAdapter.AdapterId", "TestAdapter");
Ice::ObjectAdapterPtr adapter = _serverCommunicator->createObjectAdapter("TestAdapter");
Ice::ObjectPrx locator = _serverCommunicator->stringToProxy("locator:default -p 12345");
adapter->setLocator(Ice::LocatorPrx::uncheckedCast(locator));
Ice::ObjectPtr object = new TestI(adapter);
Ice::ObjectPrx proxy = adapter->add(object, Ice::stringToIdentity("test"));
adapter->activate();
}
void
ServerManagerI::shutdown(const Ice::Current&)
{
_serverCommunicator->shutdown();
_adapter->getCommunicator()->shutdown();
}
TestI::TestI(const Ice::ObjectAdapterPtr& adapter) :
_adapter(adapter)
{
Ice::ObjectPtr servant = new HelloI();
_adapter->add(servant, Ice::stringToIdentity("hello"));
}
void
TestI::shutdown(const Ice::Current&)
{
_adapter->getCommunicator()->shutdown();
}
HelloPrx
TestI::getHello(const Ice::Current&)
{
return HelloPrx::uncheckedCast(_adapter->createProxy(Ice::stringToIdentity("hello")));
}
void
HelloI::sayHello(const Ice::Current&)
{
}
|