1
// **********************************************************************
3
// Copyright (c) 2003-2010 ZeroC, Inc. All rights reserved.
5
// This copy of Ice is licensed to you under the terms described in the
6
// ICE_LICENSE file included in this distribution.
8
// **********************************************************************
10
#include <FilesystemI.h>
11
#include <IdentityFileEntryMap.h>
12
#include <IdentityDirectoryEntryMap.h>
13
#include <Ice/Application.h>
14
#include <Freeze/Freeze.h>
17
using namespace Filesystem;
18
using namespace FilesystemDB;
20
class FilesystemApp : public virtual Ice::Application
24
FilesystemApp(const string& envName)
29
virtual int run(int, char*[])
32
// Terminate cleanly on receipt of a signal
34
shutdownOnInterrupt();
37
// Create an object adapter
39
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MapFilesystem");
42
// Open a connection to the files and directories database. This should remain open
43
// for the duration of the application for performance reasons.
45
const Freeze::ConnectionPtr connection(Freeze::createConnection(communicator(), _envName));
46
const IdentityFileEntryMap fileDB(connection, FileI::filesDB());
47
const IdentityDirectoryEntryMap dirDB(connection, DirectoryI::directoriesDB());
50
// Add default servants for the file and directory.
52
adapter->addDefaultServant(new FileI(communicator(), _envName), "file");
53
adapter->addDefaultServant(new DirectoryI(communicator(), _envName), "");
56
// Ready to accept requests now
61
// Wait until we are done
63
communicator()->waitForShutdown();
70
cerr << appName() << ": received signal, shutting down" << endl;
82
main(int argc, char* argv[])
84
FilesystemApp app("db");
85
return app.main(argc, argv, "config.server");