summaryrefslogtreecommitdiff
path: root/java/demo/book/freeze_filesystem/Server.java
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2007-03-30 18:19:01 +0000
committerMark Spruiell <mes@zeroc.com>2007-03-30 18:19:01 +0000
commit77a7949e19e7bfaa75488bb535a2a1450192425e (patch)
tree2fe1208403dc3a0758c2b73fe7420c61fb4d007f /java/demo/book/freeze_filesystem/Server.java
parenttracing fixes (diff)
downloadice-77a7949e19e7bfaa75488bb535a2a1450192425e.tar.bz2
ice-77a7949e19e7bfaa75488bb535a2a1450192425e.tar.xz
ice-77a7949e19e7bfaa75488bb535a2a1450192425e.zip
adding Freeze filesystem demo
Diffstat (limited to 'java/demo/book/freeze_filesystem/Server.java')
-rw-r--r--java/demo/book/freeze_filesystem/Server.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/java/demo/book/freeze_filesystem/Server.java b/java/demo/book/freeze_filesystem/Server.java
new file mode 100644
index 00000000000..d0a21c6caa4
--- /dev/null
+++ b/java/demo/book/freeze_filesystem/Server.java
@@ -0,0 +1,84 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2007 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.
+//
+// **********************************************************************
+
+import Filesystem.*;
+
+public class Server extends Ice.Application
+{
+ public
+ Server(String envName)
+ {
+ _envName = envName;
+ }
+
+ public int
+ run(String[] args)
+ {
+ //
+ // Install object factories.
+ //
+ Ice.ObjectFactory factory = new NodeFactory();
+ communicator().addObjectFactory(factory, PersistentFile.ice_staticId());
+ communicator().addObjectFactory(factory, PersistentDirectory.ice_staticId());
+
+ //
+ // Create an object adapter (stored in the _adapter
+ // static member).
+ //
+ Ice.ObjectAdapter adapter =
+ communicator().createObjectAdapterWithEndpoints("FreezeFilesystem", "default -p 10000");
+ DirectoryI._adapter = adapter;
+ FileI._adapter = adapter;
+
+ //
+ // Create the Freeze evictor (stored in the _evictor
+ // static member).
+ //
+ Freeze.ServantInitializer init = new NodeInitializer();
+ Freeze.Evictor evictor = Freeze.Util.createEvictor(adapter, _envName, "evictorfs", init, null, true);
+ DirectoryI._evictor = evictor;
+ FileI._evictor = evictor;
+
+ adapter.addServantLocator(evictor, "");
+
+ //
+ // Create the root node if it doesn't exist.
+ //
+ Ice.Identity rootId = Ice.Util.stringToIdentity("RootDir");
+ if(!evictor.hasObject(rootId))
+ {
+ PersistentDirectory root = new DirectoryI(rootId);
+ root.nodeName = "/";
+ root.nodes = new java.util.HashMap();
+ evictor.add(root, rootId);
+ }
+
+ //
+ // Ready to accept requests now.
+ //
+ adapter.activate();
+
+ //
+ // Wait until we are done.
+ //
+ communicator().waitForShutdown();
+
+ return 0;
+ }
+
+ public static void
+ main(String[] args)
+ {
+ Server app = new Server("db");
+ int status = app.main("Server", args, "config.server");
+ System.exit(status);
+ }
+
+ private String _envName;
+}