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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
// **********************************************************************
//
// 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 <IceUtil/UUID.h>
#include <Ice/Ice.h>
#include <IcePack/NodeI.h>
#include <IcePack/Activator.h>
#include <IcePack/ServerFactory.h>
//
// Just to get the hostname
//
#include <Ice/ProtocolPluginFacade.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
# include <direct.h>
#endif
using namespace std;
using namespace IcePack;
NodeI::NodeI(const ActivatorPtr& activator,
const string& name,
const ServerFactoryPtr& factory,
const Ice::CommunicatorPtr& communicator,
const Ice::PropertiesPtr& properties) :
_activator(activator),
_name(name),
_hostname(IceInternal::getProtocolPluginFacade(communicator)->getDefaultHost()),
_factory(factory)
{
_tmpDir = properties->getProperty("IcePack.Node.Data");
_tmpDir = _tmpDir + (_tmpDir[_tmpDir.length() - 1] == '/' ? "" : "/") + "tmp/";
}
ServerPrx
NodeI::createServer(const string& name, const ServerDescriptorPtr& desc, const ::Ice::Current&) const
{
return _factory->createServer(name, desc);
}
ServerAdapterPrx
NodeI::createServerAdapter(const ServerPrx& server, const string& id, const ::Ice::Current&) const
{
return _factory->createServerAdapter(id, server);
}
string
NodeI::createTmpDir(const Ice::Current&) const
{
string dir = _tmpDir + IceUtil::generateUUID();
#ifdef _WIN32
_mkdir(dir.c_str());
#else
mkdir(dir.c_str(), 0755);
#endif
return dir;
}
void
NodeI::destroyTmpDir(const string& path, const Ice::Current&) const
{
rmdir(path.c_str());
}
std::string
NodeI::getName(const Ice::Current&) const
{
return _name;
}
std::string
NodeI::getHostname(const Ice::Current&) const
{
return _hostname;
}
void
NodeI::shutdown(const Ice::Current&) const
{
_activator->shutdown();
}
|