summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/demo/book/evictor_filesystem/Client.cpp13
-rw-r--r--cpp/demo/book/evictor_filesystem/Parser.h2
-rw-r--r--cpp/demo/book/evictor_filesystem/PersistentFilesystemI.cpp10
-rw-r--r--cpp/demo/book/lifecycle/Client.cpp10
-rw-r--r--cpp/demo/book/lifecycle/FilesystemI.cpp1
-rw-r--r--cpp/demo/book/lifecycle/FilesystemI.h2
-rw-r--r--cpp/demo/book/lifecycle/Parser.h2
-rw-r--r--cpp/demo/book/lifecycle/Server.cpp15
-rw-r--r--cpp/demo/book/map_filesystem/Client.cpp13
-rw-r--r--cpp/demo/book/map_filesystem/FilesystemI.cpp8
-rw-r--r--cpp/demo/book/map_filesystem/FilesystemI.h4
-rw-r--r--cpp/demo/book/map_filesystem/Server.cpp7
-rw-r--r--cpp/demo/book/printer/Client.cpp28
-rw-r--r--cpp/demo/book/printer/Server.cpp38
-rw-r--r--cpp/demo/book/simple_filesystem/Client.cpp50
-rw-r--r--cpp/demo/book/simple_filesystem/FilesystemI.h26
-rw-r--r--cpp/demo/book/simple_filesystem/Server.cpp26
-rw-r--r--cs/demo/book/lifecycle/Client.cs7
-rw-r--r--cs/demo/book/lifecycle/Server.cs7
-rw-r--r--cs/demo/book/printer/Client.cs26
-rw-r--r--cs/demo/book/printer/Server.cs27
-rw-r--r--cs/demo/book/simple_filesystem/Client.cs41
-rw-r--r--cs/demo/book/simple_filesystem/DirectoryI.cs1
-rw-r--r--cs/demo/book/simple_filesystem/FileI.cs1
-rw-r--r--cs/demo/book/simple_filesystem/Server.cs30
-rw-r--r--java/demo/book/evictor_filesystem/Client.java2
-rw-r--r--java/demo/book/evictor_filesystem/DirectoryI.java2
-rw-r--r--java/demo/book/evictor_filesystem/FileI.java14
-rw-r--r--java/demo/book/evictor_filesystem/Server.java3
-rw-r--r--java/demo/book/lifecycle/Client.java8
-rw-r--r--java/demo/book/lifecycle/Server.java8
-rw-r--r--java/demo/book/map_filesystem/Client.java2
-rw-r--r--java/demo/book/map_filesystem/DirectoryI.java4
-rw-r--r--java/demo/book/map_filesystem/FileI.java1
-rw-r--r--java/demo/book/map_filesystem/Server.java18
-rw-r--r--java/demo/book/printer/Client.java33
-rw-r--r--java/demo/book/printer/PrinterI.java3
-rw-r--r--java/demo/book/printer/Server.java30
-rw-r--r--java/demo/book/simple_filesystem/Client.java49
-rw-r--r--java/demo/book/simple_filesystem/Filesystem/DirectoryI.java1
-rw-r--r--java/demo/book/simple_filesystem/Filesystem/FileI.java1
-rw-r--r--java/demo/book/simple_filesystem/Server.java33
42 files changed, 392 insertions, 215 deletions
diff --git a/cpp/demo/book/evictor_filesystem/Client.cpp b/cpp/demo/book/evictor_filesystem/Client.cpp
index ee09e42dcbd..e50a92a50bb 100644
--- a/cpp/demo/book/evictor_filesystem/Client.cpp
+++ b/cpp/demo/book/evictor_filesystem/Client.cpp
@@ -26,19 +26,12 @@ public:
{
}
- virtual int run(int, char * []) {
-
- // Create a proxy for the root directory
+ virtual int run(int, char*[])
+ {
//
- Ice::ObjectPrx base = communicator()->stringToProxy("RootDir:default -p 10000");
- if(!base)
- {
- throw "Could not create proxy";
- }
-
// Down-cast the proxy to a Directory proxy.
//
- DirectoryPrx rootDir = DirectoryPrx::checkedCast(base);
+ DirectoryPrx rootDir = DirectoryPrx::checkedCast(communicator()->propertyToProxy("RootDir.Proxy"));
if(!rootDir)
{
throw "Invalid proxy";
diff --git a/cpp/demo/book/evictor_filesystem/Parser.h b/cpp/demo/book/evictor_filesystem/Parser.h
index 648812abfaa..091de235481 100644
--- a/cpp/demo/book/evictor_filesystem/Parser.h
+++ b/cpp/demo/book/evictor_filesystem/Parser.h
@@ -46,6 +46,7 @@ typedef IceUtil::Handle<Parser> ParserPtr;
class Parser : public IceUtil::SimpleShared
{
public:
+
Parser(const Filesystem::DirectoryPrx&);
void usage();
@@ -72,6 +73,7 @@ public:
int parse(bool = false);
private:
+
::std::list<Filesystem::DirectoryPrx> _dirs;
bool _continue;
diff --git a/cpp/demo/book/evictor_filesystem/PersistentFilesystemI.cpp b/cpp/demo/book/evictor_filesystem/PersistentFilesystemI.cpp
index 4813ca17573..95e62606da5 100644
--- a/cpp/demo/book/evictor_filesystem/PersistentFilesystemI.cpp
+++ b/cpp/demo/book/evictor_filesystem/PersistentFilesystemI.cpp
@@ -40,11 +40,11 @@ Filesystem::FileI::destroy(const Ice::Current& c)
{
IceUtil::Mutex::Lock lock(_mutex);
- if(_destroyed)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
- }
- _destroyed = true;
+ if(_destroyed)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
+ }
+ _destroyed = true;
}
//
diff --git a/cpp/demo/book/lifecycle/Client.cpp b/cpp/demo/book/lifecycle/Client.cpp
index 7bc228ee012..1576da83e91 100644
--- a/cpp/demo/book/lifecycle/Client.cpp
+++ b/cpp/demo/book/lifecycle/Client.cpp
@@ -26,16 +26,14 @@ public:
{
}
- virtual int run(int, char * []) {
-
+ virtual int run(int, char*[])
+ {
+ //
// Create a proxy for the root directory
//
Ice::ObjectPrx base = communicator()->stringToProxy("RootDir:default -p 10000");
- if(!base)
- {
- throw "Could not create proxy";
- }
+ //
// Down-cast the proxy to a Directory proxy.
//
DirectoryPrx rootDir = DirectoryPrx::checkedCast(base);
diff --git a/cpp/demo/book/lifecycle/FilesystemI.cpp b/cpp/demo/book/lifecycle/FilesystemI.cpp
index c48ba2f227d..89aaf6a2808 100644
--- a/cpp/demo/book/lifecycle/FilesystemI.cpp
+++ b/cpp/demo/book/lifecycle/FilesystemI.cpp
@@ -43,6 +43,7 @@ FilesystemI::NodeI::id() const
FilesystemI::NodeI::NodeI(const string& name, const DirectoryIPtr& parent)
: _name(name), _parent(parent), _destroyed(false)
{
+ //
// Create an identity. The root directory has the fixed identity "RootDir".
//
if(parent != 0)
diff --git a/cpp/demo/book/lifecycle/FilesystemI.h b/cpp/demo/book/lifecycle/FilesystemI.h
index e8abc5b9978..ce55c799c0e 100644
--- a/cpp/demo/book/lifecycle/FilesystemI.h
+++ b/cpp/demo/book/lifecycle/FilesystemI.h
@@ -37,7 +37,6 @@ namespace FilesystemI
Ice::Identity _id;
IceUtil::Mutex _m;
};
-
typedef IceUtil::Handle<NodeI> NodeIPtr;
class FileI : virtual public Filesystem::File, virtual public NodeI
@@ -54,7 +53,6 @@ namespace FilesystemI
Filesystem::Lines _lines;
};
-
typedef IceUtil::Handle<FileI> FileIPtr;
class DirectoryI : virtual public NodeI, virtual public Filesystem::Directory
diff --git a/cpp/demo/book/lifecycle/Parser.h b/cpp/demo/book/lifecycle/Parser.h
index 648812abfaa..091de235481 100644
--- a/cpp/demo/book/lifecycle/Parser.h
+++ b/cpp/demo/book/lifecycle/Parser.h
@@ -46,6 +46,7 @@ typedef IceUtil::Handle<Parser> ParserPtr;
class Parser : public IceUtil::SimpleShared
{
public:
+
Parser(const Filesystem::DirectoryPrx&);
void usage();
@@ -72,6 +73,7 @@ public:
int parse(bool = false);
private:
+
::std::list<Filesystem::DirectoryPrx> _dirs;
bool _continue;
diff --git a/cpp/demo/book/lifecycle/Server.cpp b/cpp/demo/book/lifecycle/Server.cpp
index 88445a1bb4e..317b4388fe1 100644
--- a/cpp/demo/book/lifecycle/Server.cpp
+++ b/cpp/demo/book/lifecycle/Server.cpp
@@ -14,19 +14,24 @@ using namespace std;
using namespace Filesystem;
using namespace FilesystemI;
-class FilesystemApp : virtual public Ice::Application {
+class FilesystemApp : virtual public Ice::Application
+{
public:
- virtual int run(int, char* []) {
+
+ virtual int run(int, char*[])
+ {
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter.
//
Ice::ObjectAdapterPtr adapter =
- communicator()->createObjectAdapterWithEndpoints(
- "SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ communicator()->createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory.
//
DirectoryIPtr root = new DirectoryI;
@@ -34,10 +39,12 @@ public:
id.name = "RootDir";
adapter->add(root, id);
+ //
// All objects are created, allow client requests now.
//
adapter->activate();
+ //
// Wait until we are done.
//
communicator()->waitForShutdown();
diff --git a/cpp/demo/book/map_filesystem/Client.cpp b/cpp/demo/book/map_filesystem/Client.cpp
index 3dd084104a4..5f0a29bc17b 100644
--- a/cpp/demo/book/map_filesystem/Client.cpp
+++ b/cpp/demo/book/map_filesystem/Client.cpp
@@ -27,19 +27,12 @@ public:
{
}
- virtual int run(int, char * []) {
-
- // Create a proxy for the root directory
+ virtual int run(int, char*[])
+ {
//
- Ice::ObjectPrx base = communicator()->stringToProxy("RootDir:default -p 10000");
- if(!base)
- {
- throw "Could not create proxy";
- }
-
// Down-cast the proxy to a Directory proxy.
//
- DirectoryPrx rootDir = DirectoryPrx::checkedCast(base);
+ DirectoryPrx rootDir = DirectoryPrx::checkedCast(communicator()->propertyToProxy("RootDir.Proxy"));
if(!rootDir)
{
throw "Invalid proxy";
diff --git a/cpp/demo/book/map_filesystem/FilesystemI.cpp b/cpp/demo/book/map_filesystem/FilesystemI.cpp
index f37dcf8fdd7..d9ee20a6b55 100644
--- a/cpp/demo/book/map_filesystem/FilesystemI.cpp
+++ b/cpp/demo/book/map_filesystem/FilesystemI.cpp
@@ -120,6 +120,7 @@ FileI::destroy(const Ice::Current& c)
{
try
{
+ //
// The transaction is necessary since we are altering two
// records in one atomic action.
//
@@ -178,6 +179,7 @@ DirectoryI::DirectoryI(const Ice::CommunicatorPtr& communicator, const string& e
const Freeze::ConnectionPtr connection = Freeze::createConnection(_communicator, _envName);
IdentityDirectoryEntryMap dirDB(connection, directoriesDB());
+ //
// Create the record for the root directory if necessary.
//
for(;;)
@@ -250,8 +252,7 @@ DirectoryI::list(const Ice::Current& c)
throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
NodeDescSeq result;
- for(StringNodeDescDict::const_iterator q = p->second.nodes.begin();
- q != p->second.nodes.end(); ++q)
+ for(StringNodeDescDict::const_iterator q = p->second.nodes.begin(); q != p->second.nodes.end(); ++q)
{
result.push_back(q->second);
}
@@ -311,6 +312,7 @@ DirectoryI::createDirectory(const string& name, const Ice::Current& c)
{
try
{
+ //
// The transaction is necessary since we are altering two
// records in one atomic action.
//
@@ -371,6 +373,7 @@ DirectoryI::createFile(const string& name, const Ice::Current& c)
{
try
{
+ //
// The transaction is necessary since we are altering two
// records in one atomic action.
//
@@ -431,6 +434,7 @@ DirectoryI::destroy(const Ice::Current& c)
{
try
{
+ //
// The transaction is necessary since we are altering two
// records in one atomic action.
//
diff --git a/cpp/demo/book/map_filesystem/FilesystemI.h b/cpp/demo/book/map_filesystem/FilesystemI.h
index 6eab56d3eeb..769cf4ad422 100644
--- a/cpp/demo/book/map_filesystem/FilesystemI.h
+++ b/cpp/demo/book/map_filesystem/FilesystemI.h
@@ -7,8 +7,8 @@
//
// **********************************************************************
-#ifndef PERSISTENT_FILESYSTEM_I_H
-#define PERSISTENT_FILESYSTEM_I_H
+#ifndef FILESYSTEM_I_H
+#define FILESYSTEM_I_H
#include <Filesystem.h>
#include <Freeze/Freeze.h>
diff --git a/cpp/demo/book/map_filesystem/Server.cpp b/cpp/demo/book/map_filesystem/Server.cpp
index 2897afc6458..76d2cd30168 100644
--- a/cpp/demo/book/map_filesystem/Server.cpp
+++ b/cpp/demo/book/map_filesystem/Server.cpp
@@ -28,14 +28,17 @@ public:
virtual int run(int, char*[])
{
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter
//
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("MapFilesystem");
+ //
// Open a connection to the files and directories database. This should remain open
// for the duration of the application for performance reasons.
//
@@ -43,19 +46,23 @@ public:
const IdentityFileEntryMap fileDB(connection, FileI::filesDB());
const IdentityDirectoryEntryMap dirDB(connection, DirectoryI::directoriesDB());
+ //
// Add default servants for the file and directory.
//
adapter->addDefaultServant(new FileI(communicator(), _envName), "file");
adapter->addDefaultServant(new DirectoryI(communicator(), _envName), "");
+ //
// Ready to accept requests now
//
adapter->activate();
+ //
// Wait until we are done
//
communicator()->waitForShutdown();
+ //
// Clean up
//
if(interrupted())
diff --git a/cpp/demo/book/printer/Client.cpp b/cpp/demo/book/printer/Client.cpp
index e7190622a6b..7a2d07297e0 100644
--- a/cpp/demo/book/printer/Client.cpp
+++ b/cpp/demo/book/printer/Client.cpp
@@ -18,26 +18,36 @@ main(int argc, char * argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
- try {
+ try
+ {
ic = Ice::initialize(argc, argv);
- Ice::ObjectPrx base = ic->stringToProxy(
- "SimplePrinter:default -p 10000");
+ Ice::ObjectPrx base = ic->stringToProxy("SimplePrinter:default -p 10000");
PrinterPrx printer = PrinterPrx::checkedCast(base);
- if (!printer)
+ if(!printer)
+ {
throw "Invalid proxy";
+ }
printer->printString("Hello World!");
- } catch (const Ice::Exception & ex) {
+ }
+ catch(const Ice::Exception& ex)
+ {
cerr << ex << endl;
status = 1;
- } catch (const char * msg) {
+ }
+ catch(const char* msg)
+ {
cerr << msg << endl;
status = 1;
}
- if (ic) {
- try {
+ if(ic)
+ {
+ try
+ {
ic->destroy();
- } catch (const Ice::Exception & ex) {
+ }
+ catch (const Ice::Exception& ex)
+ {
cerr << ex << endl;
status = 1;
}
diff --git a/cpp/demo/book/printer/Server.cpp b/cpp/demo/book/printer/Server.cpp
index c4330b12499..e5018cc82ab 100644
--- a/cpp/demo/book/printer/Server.cpp
+++ b/cpp/demo/book/printer/Server.cpp
@@ -13,15 +13,16 @@
using namespace std;
using namespace Demo;
-class PrinterI : public Printer {
+class PrinterI : public Printer
+{
public:
- virtual void printString(const string & s,
- const Ice::Current &);
+
+ virtual void printString(const string &, const Ice::Current&);
};
void
PrinterI::
-printString(const string & s, const Ice::Current &)
+printString(const string &s, const Ice::Current&)
{
cout << s << endl;
}
@@ -31,27 +32,34 @@ main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
- try {
+ try
+ {
ic = Ice::initialize(argc, argv);
- Ice::ObjectAdapterPtr adapter
- = ic->createObjectAdapterWithEndpoints(
- "SimplePrinterAdapter", "default -p 10000");
+ Ice::ObjectAdapterPtr adapter =
+ ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
Ice::ObjectPtr object = new PrinterI;
- adapter->add(object,
- ic->stringToIdentity("SimplePrinter"));
+ adapter->add(object, ic->stringToIdentity("SimplePrinter"));
adapter->activate();
ic->waitForShutdown();
- } catch (const Ice::Exception & e) {
+ }
+ catch(const Ice::Exception& e)
+ {
cerr << e << endl;
status = 1;
- } catch (const char * msg) {
+ }
+ catch(const char* msg)
+ {
cerr << msg << endl;
status = 1;
}
- if (ic) {
- try {
+ if(ic)
+ {
+ try
+ {
ic->destroy();
- } catch (const Ice::Exception & e) {
+ }
+ catch(const Ice::Exception& e)
+ {
cerr << e << endl;
status = 1;
}
diff --git a/cpp/demo/book/simple_filesystem/Client.cpp b/cpp/demo/book/simple_filesystem/Client.cpp
index 24865abb023..007e4b11cfa 100644
--- a/cpp/demo/book/simple_filesystem/Client.cpp
+++ b/cpp/demo/book/simple_filesystem/Client.cpp
@@ -26,16 +26,22 @@ listRecursive(const DirectoryPrx& dir, int depth = 0)
NodeSeq contents = dir->list();
- for (NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) {
+ for(NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i)
+ {
DirectoryPrx dir = DirectoryPrx::checkedCast(*i);
FilePrx file = FilePrx::uncheckedCast(*i);
cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl;
- if (dir) {
+ if(dir)
+ {
listRecursive(dir, depth);
- } else {
+ }
+ else
+ {
Lines text = file->read();
- for (Lines::const_iterator j = text.begin(); j != text.end(); ++j)
+ for(Lines::const_iterator j = text.begin(); j != text.end(); ++j)
+ {
cout << indent << "\t" << *j << endl;
+ }
}
}
}
@@ -45,39 +51,59 @@ main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
- try {
+ try
+ {
+ //
// Create a communicator
//
ic = Ice::initialize(argc, argv);
+ //
// Create a proxy for the root directory
//
Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000");
- if (!base)
- throw "Could not create proxy";
+ //
// Down-cast the proxy to a Directory proxy
//
DirectoryPrx rootDir = DirectoryPrx::checkedCast(base);
- if (!rootDir)
+ if(!rootDir)
+ {
throw "Invalid proxy";
+ }
+ //
// Recursively list the contents of the root directory
//
cout << "Contents of root directory:" << endl;
listRecursive(rootDir);
- } catch (const Ice::Exception & ex) {
+ }
+ catch(const Ice::Exception& ex)
+ {
cerr << ex << endl;
status = 1;
- } catch (const char * msg) {
+ }
+ catch(const char* msg)
+ {
cerr << msg << endl;
status = 1;
}
+ //
// Clean up
//
- if (ic)
- ic->destroy();
+ if(ic)
+ {
+ try
+ {
+ ic->destroy();
+ }
+ catch(const Ice::Exception& e)
+ {
+ cerr << e << endl;
+ status = 1;
+ }
+ }
return status;
}
diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.h b/cpp/demo/book/simple_filesystem/FilesystemI.h
index e848eb55062..5bf02a3c1dd 100644
--- a/cpp/demo/book/simple_filesystem/FilesystemI.h
+++ b/cpp/demo/book/simple_filesystem/FilesystemI.h
@@ -13,46 +13,54 @@
#include <Ice/Ice.h>
#include <Filesystem.h>
-namespace Filesystem {
-
+namespace Filesystem
+{
class DirectoryI;
typedef IceUtil::Handle<DirectoryI> DirectoryIPtr;
- class NodeI : virtual public Node {
+ class NodeI : virtual public Node
+ {
public:
+
virtual std::string name(const Ice::Current&);
NodeI(const Ice::CommunicatorPtr&, const std::string&, const DirectoryIPtr&);
void activate(const Ice::ObjectAdapterPtr&);
+
private:
+
std::string _name;
Ice::Identity _id;
DirectoryIPtr _parent;
NodeI(const NodeI&); // Copy forbidden
void operator=(const NodeI&); // Assignment forbidden
};
-
typedef IceUtil::Handle<NodeI> NodeIPtr;
- class FileI : virtual public File,
- virtual public NodeI {
+ class FileI : virtual public File, virtual public NodeI
+ {
public:
+
virtual Lines read(const Ice::Current&);
virtual void write(const Lines&,
const Ice::Current& = Ice::Current());
FileI(const Ice::CommunicatorPtr&, const std::string&, const DirectoryIPtr&);
+
private:
+
Lines _lines;
};
-
typedef IceUtil::Handle<FileI> FileIPtr;
- class DirectoryI : virtual public Directory,
- virtual public NodeI {
+ class DirectoryI : virtual public Directory, virtual public NodeI
+ {
public:
+
virtual NodeSeq list(const Ice::Current&);
DirectoryI(const Ice::CommunicatorPtr&, const std::string&, const DirectoryIPtr&);
void addChild(const Filesystem::NodePrx&);
+
private:
+
Filesystem::NodeSeq _contents;
};
}
diff --git a/cpp/demo/book/simple_filesystem/Server.cpp b/cpp/demo/book/simple_filesystem/Server.cpp
index 5bc72089edb..bde7861d29a 100644
--- a/cpp/demo/book/simple_filesystem/Server.cpp
+++ b/cpp/demo/book/simple_filesystem/Server.cpp
@@ -13,24 +13,30 @@
using namespace std;
using namespace Filesystem;
-class FilesystemApp : virtual public Ice::Application {
+class FilesystemApp : virtual public Ice::Application
+{
public:
- virtual int run(int, char*[]) {
+
+ virtual int run(int, char*[])
+ {
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter.
//
Ice::ObjectAdapterPtr adapter =
- communicator()->createObjectAdapterWithEndpoints(
- "SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ communicator()->createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory (with name "/" and no parent)
//
DirectoryIPtr root = new DirectoryI(communicator(), "/", 0);
root->activate(adapter);
+ //
// Create a file called "README" in the root directory
//
FileIPtr file = new FileI(communicator(), "README", root);
@@ -39,11 +45,13 @@ public:
file->write(text);
file->activate(adapter);
+ //
// Create a directory called "Coleridge" in the root directory
//
DirectoryIPtr coleridge = new DirectoryI(communicator(), "Coleridge", root);
coleridge->activate(adapter);
+ //
// Create a file called "Kubla_Khan" in the Coleridge directory
//
file = new FileI(communicator(), "Kubla_Khan", coleridge);
@@ -56,20 +64,22 @@ public:
file->write(text);
file->activate(adapter);
+ //
// All objects are created, allow client requests now
//
adapter->activate();
+ //
// Wait until we are done
//
communicator()->waitForShutdown();
- if (interrupted()) {
- cerr << appName()
- << ": received signal, shutting down" << endl;
+ if(interrupted())
+ {
+ cerr << appName() << ": received signal, shutting down" << endl;
}
return 0;
- };
+ }
};
int
diff --git a/cs/demo/book/lifecycle/Client.cs b/cs/demo/book/lifecycle/Client.cs
index 2921a4c347a..8310f8c8d3d 100644
--- a/cs/demo/book/lifecycle/Client.cs
+++ b/cs/demo/book/lifecycle/Client.cs
@@ -23,18 +23,17 @@ public class Client
{
public override int run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx @base = communicator().stringToProxy("RootDir:default -p 10000");
- if(@base == null)
- {
- throw new Error("Could not create proxy");
- }
+ //
// Down-cast the proxy to a Directory proxy.
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(@base);
diff --git a/cs/demo/book/lifecycle/Server.cs b/cs/demo/book/lifecycle/Server.cs
index b9f2c5b157d..2a5627b95c4 100644
--- a/cs/demo/book/lifecycle/Server.cs
+++ b/cs/demo/book/lifecycle/Server.cs
@@ -23,15 +23,18 @@ public class Server
{
public override int run(string[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create an object adapter
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory.
//
DirectoryI root = new DirectoryI();
@@ -39,12 +42,14 @@ public class Server
id.name = "RootDir";
adapter.add(root, id);
+ //
// All objects are created, allow client requests now.
//
adapter.activate();
//
// Wait until we are done.
+ //
communicator().waitForShutdown();
if(interrupted())
{
diff --git a/cs/demo/book/printer/Client.cs b/cs/demo/book/printer/Client.cs
index af3cf8e820d..faf7d16b1c9 100644
--- a/cs/demo/book/printer/Client.cs
+++ b/cs/demo/book/printer/Client.cs
@@ -23,25 +23,31 @@ public class Client
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(ref args);
- Ice.ObjectPrx obj = ic.stringToProxy(
- "SimplePrinter:default -p 10000");
+ Ice.ObjectPrx obj = ic.stringToProxy("SimplePrinter:default -p 10000");
PrinterPrx printer = PrinterPrxHelper.checkedCast(obj);
- if (printer == null)
+ if(printer == null)
+ {
throw new ApplicationException("Invalid proxy");
+ }
printer.printString("Hello World!");
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/printer/Server.cs b/cs/demo/book/printer/Server.cs
index 42e3c16e591..21561874570 100644
--- a/cs/demo/book/printer/Server.cs
+++ b/cs/demo/book/printer/Server.cs
@@ -30,28 +30,29 @@ public class Server
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(ref args);
- Ice.ObjectAdapter adapter
- = ic.createObjectAdapterWithEndpoints(
- "SimplePrinterAdapter", "default -p 10000");
+ Ice.ObjectAdapter adapter =
+ ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
Ice.Object obj = new PrinterI();
- adapter.add(
- obj,
- ic.stringToIdentity("SimplePrinter"));
+ adapter.add(obj, ic.stringToIdentity("SimplePrinter"));
adapter.activate();
ic.waitForShutdown();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null)
+ if(ic != null)
{
- // Clean up
- //
- try {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/simple_filesystem/Client.cs b/cs/demo/book/simple_filesystem/Client.cs
index c3e7777665a..fe6e0a8fa28 100644
--- a/cs/demo/book/simple_filesystem/Client.cs
+++ b/cs/demo/book/simple_filesystem/Client.cs
@@ -29,16 +29,22 @@ public class Client
NodePrx[] contents = dir.list();
- foreach (NodePrx node in contents) {
+ foreach(NodePrx node in contents)
+ {
DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(node);
FilePrx file = FilePrxHelper.uncheckedCast(node);
Console.WriteLine(indent + node.name() + (subdir != null ? " (directory):" : " (file):"));
- if (subdir != null) {
+ if(subdir != null)
+ {
listRecursive(subdir, depth);
- } else {
+ }
+ else
+ {
string[] text = file.read();
- for (int j = 0; j < text.Length; ++j)
+ for(int j = 0; j < text.Length; ++j)
+ {
Console.WriteLine(indent + "\t" + text[j]);
+ }
}
}
}
@@ -47,35 +53,46 @@ public class Client
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
+ //
// Create a communicator
//
ic = Ice.Util.initialize(ref args);
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx obj = ic.stringToProxy("RootDir:default -p 10000");
+ //
// Down-cast the proxy to a Directory proxy
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(obj);
- if (rootDir == null)
+ if(rootDir == null)
+ {
throw new ApplicationException("Invalid proxy");
+ }
+ //
// Recursively list the contents of the root directory
//
Console.WriteLine("Contents of root directory:");
listRecursive(rootDir, 0);
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
Console.Error.WriteLine(e);
status = 1;
}
diff --git a/cs/demo/book/simple_filesystem/DirectoryI.cs b/cs/demo/book/simple_filesystem/DirectoryI.cs
index 236fe62db2b..d7e47e4023d 100644
--- a/cs/demo/book/simple_filesystem/DirectoryI.cs
+++ b/cs/demo/book/simple_filesystem/DirectoryI.cs
@@ -19,6 +19,7 @@ public class DirectoryI : DirectoryDisp_
_name = name;
_parent = parent;
+ //
// Create an identity. The root directory has the fixed identity "RootDir"
//
_id = new Ice.Identity();
diff --git a/cs/demo/book/simple_filesystem/FileI.cs b/cs/demo/book/simple_filesystem/FileI.cs
index 717f47b182f..25a84eab096 100644
--- a/cs/demo/book/simple_filesystem/FileI.cs
+++ b/cs/demo/book/simple_filesystem/FileI.cs
@@ -21,6 +21,7 @@ public class FileI : FileDisp_
Debug.Assert(_parent != null);
+ //
// Create an identity
//
_id = new Ice.Identity();
diff --git a/cs/demo/book/simple_filesystem/Server.cs b/cs/demo/book/simple_filesystem/Server.cs
index 9a324b2e97a..55e972732cc 100644
--- a/cs/demo/book/simple_filesystem/Server.cs
+++ b/cs/demo/book/simple_filesystem/Server.cs
@@ -23,37 +23,46 @@ public class Server
{
public override int run(string[] args)
{
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter.
//
- Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ Ice.ObjectAdapter adapter =
+ communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory (with name "/" and no parent)
//
DirectoryI root = new DirectoryI(communicator(), "/", null);
root.activate(adapter);
+ //
// Create a file called "README" in the root directory
//
FileI file = new FileI(communicator(), "README", root);
string[] text;
text = new string[]{ "This file system contains a collection of poetry." };
- try {
+ try
+ {
file.write(text);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
Console.Error.WriteLine(e.reason);
}
file.activate(adapter);
+ //
// Create a directory called "Coleridge" in the root directory
//
DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
coleridge.activate(adapter);
+ //
// Create a file called "Kubla_Khan" in the Coleridge directory
//
file = new FileI(communicator(), "Kubla_Khan", coleridge);
@@ -62,23 +71,30 @@ public class Server
"Where Alph, the sacred river, ran",
"Through caverns measureless to man",
"Down to a sunless sea." };
- try {
+ try
+ {
file.write(text);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
Console.Error.WriteLine(e.reason);
}
file.activate(adapter);
+ //
// All objects are created, allow client requests now
//
adapter.activate();
+ //
// Wait until we are done
//
communicator().waitForShutdown();
- if (interrupted())
+ if(interrupted())
+ {
Console.Error.WriteLine(appName() + ": terminating");
+ }
return 0;
}
diff --git a/java/demo/book/evictor_filesystem/Client.java b/java/demo/book/evictor_filesystem/Client.java
index c24556388ce..fd428020a13 100644
--- a/java/demo/book/evictor_filesystem/Client.java
+++ b/java/demo/book/evictor_filesystem/Client.java
@@ -14,10 +14,12 @@ public class Client extends Ice.Application
public int
run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create a proxy for the root directory
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(communicator().propertyToProxy("RootDir.Proxy"));
diff --git a/java/demo/book/evictor_filesystem/DirectoryI.java b/java/demo/book/evictor_filesystem/DirectoryI.java
index 98cd14d7dbd..f91add94a34 100644
--- a/java/demo/book/evictor_filesystem/DirectoryI.java
+++ b/java/demo/book/evictor_filesystem/DirectoryI.java
@@ -48,7 +48,7 @@ public final class DirectoryI extends PersistentDirectory
{
throw new PermissionDenied("Cannot destroy non-empty directory");
}
- _destroyed = true;
+ _destroyed = true;
}
//
diff --git a/java/demo/book/evictor_filesystem/FileI.java b/java/demo/book/evictor_filesystem/FileI.java
index 5455b0880c6..08e86aa6eb5 100644
--- a/java/demo/book/evictor_filesystem/FileI.java
+++ b/java/demo/book/evictor_filesystem/FileI.java
@@ -33,13 +33,13 @@ public final class FileI extends PersistentFile
throws PermissionDenied
{
synchronized(this)
- {
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
- _destroyed = true;
- }
+ {
+ if(_destroyed)
+ {
+ throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
+ }
+ _destroyed = true;
+ }
//
// Because we use a transactional evictor, these updates are guaranteed to be atomic.
diff --git a/java/demo/book/evictor_filesystem/Server.java b/java/demo/book/evictor_filesystem/Server.java
index 55bd40fccc5..857695e8036 100644
--- a/java/demo/book/evictor_filesystem/Server.java
+++ b/java/demo/book/evictor_filesystem/Server.java
@@ -30,8 +30,7 @@ public class Server extends Ice.Application
//
// Create an object adapter.
//
- Ice.ObjectAdapter adapter =
- communicator().createObjectAdapter("EvictorFilesystem");
+ Ice.ObjectAdapter adapter = communicator().createObjectAdapter("EvictorFilesystem");
//
// Create the Freeze evictor (stored in the _evictor
diff --git a/java/demo/book/lifecycle/Client.java b/java/demo/book/lifecycle/Client.java
index 710a52649e3..c1e0525b7e6 100644
--- a/java/demo/book/lifecycle/Client.java
+++ b/java/demo/book/lifecycle/Client.java
@@ -14,18 +14,17 @@ public class Client extends Ice.Application
public int
run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx base = communicator().stringToProxy("RootDir:default -p 10000");
- if(base == null)
- {
- throw new Error("Could not create proxy");
- }
+ //
// Down-cast the proxy to a Directory proxy.
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(base);
@@ -52,5 +51,4 @@ public class Client extends Ice.Application
super(msg);
}
}
-
}
diff --git a/java/demo/book/lifecycle/Server.java b/java/demo/book/lifecycle/Server.java
index 54bc2d2526f..933c777a36e 100644
--- a/java/demo/book/lifecycle/Server.java
+++ b/java/demo/book/lifecycle/Server.java
@@ -14,16 +14,19 @@ class Server extends Ice.Application
public int
run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
Ice.Properties properties = communicator().getProperties();
+ //
// Create an object adapter
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ "LifecycleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory.
//
DirectoryI root = new DirectoryI();
@@ -31,11 +34,12 @@ class Server extends Ice.Application
id.name = "RootDir";
adapter.add(root, id);
-
+ //
// All objects are created, allow client requests now.
//
adapter.activate();
+ //
// Wait until we are done.
//
communicator().waitForShutdown();
diff --git a/java/demo/book/map_filesystem/Client.java b/java/demo/book/map_filesystem/Client.java
index 33542ecf941..163296ffc48 100644
--- a/java/demo/book/map_filesystem/Client.java
+++ b/java/demo/book/map_filesystem/Client.java
@@ -14,10 +14,12 @@ public class Client extends Ice.Application
public int
run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal.
//
shutdownOnInterrupt();
+ //
// Create a proxy for the root directory
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(communicator().propertyToProxy("RootDir.Proxy"));
diff --git a/java/demo/book/map_filesystem/DirectoryI.java b/java/demo/book/map_filesystem/DirectoryI.java
index 2d8c701f2c0..3c4894add90 100644
--- a/java/demo/book/map_filesystem/DirectoryI.java
+++ b/java/demo/book/map_filesystem/DirectoryI.java
@@ -23,6 +23,7 @@ public class DirectoryI extends _DirectoryDisp
{
IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(connection, directoriesDB());
+ //
// Create the record for the root directory if necessary.
//
for(;;)
@@ -182,6 +183,7 @@ public class DirectoryI extends _DirectoryDisp
for(;;)
{
+ //
// The transaction is necessary since we are altering
// two records in one atomic action.
//
@@ -247,6 +249,7 @@ public class DirectoryI extends _DirectoryDisp
for(;;)
{
+ //
// The transaction is necessary since we are altering
// two records in one atomic action.
//
@@ -312,6 +315,7 @@ public class DirectoryI extends _DirectoryDisp
for(;;)
{
+ //
// The transaction is necessary since we are altering
// two records in one atomic action.
//
diff --git a/java/demo/book/map_filesystem/FileI.java b/java/demo/book/map_filesystem/FileI.java
index bd7fabe10ba..b52fa00c1f4 100644
--- a/java/demo/book/map_filesystem/FileI.java
+++ b/java/demo/book/map_filesystem/FileI.java
@@ -142,6 +142,7 @@ public class FileI extends _FileDisp
Freeze.Transaction txn = null;
try
{
+ //
// The transaction is necessary since we are
// altering two records in one atomic action.
//
diff --git a/java/demo/book/map_filesystem/Server.java b/java/demo/book/map_filesystem/Server.java
index da9ce6e8617..e7851806949 100644
--- a/java/demo/book/map_filesystem/Server.java
+++ b/java/demo/book/map_filesystem/Server.java
@@ -21,6 +21,7 @@ public class Server extends Ice.Application
public int
run(String[] args)
{
+ //
// Create an object adapter
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapter("MapFilesystem");
@@ -28,35 +29,40 @@ public class Server extends Ice.Application
Freeze.Connection connection = null;
try
{
+ //
// Open a connection to the files and directories
// database. This should remain open for the duration of the
// application for performance reasons.
//
connection = Freeze.Util.createConnection(communicator(), _envName);
- IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, FileI.filesDB(), true);
+ IdentityFileEntryMap fileDB = new IdentityFileEntryMap(connection, FileI.filesDB(), true);
IdentityDirectoryEntryMap dirDB = new IdentityDirectoryEntryMap(
- connection, DirectoryI.directoriesDB(), true);
-
+ connection, DirectoryI.directoriesDB(), true);
+
+ //
// Add default servants for the file and directory.
//
adapter.addDefaultServant(new FileI(communicator(), _envName), "file");
adapter.addDefaultServant(new DirectoryI(communicator(), _envName), "");
-
+
+ //
// Ready to accept requests now
//
adapter.activate();
-
+
+ //
// Wait until we are done
//
communicator().waitForShutdown();
}
finally
{
+ //
// Close the connection gracefully.
//
connection.close();
}
-
+
return 0;
}
diff --git a/java/demo/book/printer/Client.java b/java/demo/book/printer/Client.java
index bb18ab4bc71..8f2fe114658 100644
--- a/java/demo/book/printer/Client.java
+++ b/java/demo/book/printer/Client.java
@@ -7,34 +7,43 @@
//
// **********************************************************************
-public class Client {
+public class Client
+{
public static void
main(String[] args)
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(args);
- Ice.ObjectPrx base = ic.stringToProxy(
- "SimplePrinter:default -p 10000");
+ Ice.ObjectPrx base = ic.stringToProxy("SimplePrinter:default -p 10000");
Demo.PrinterPrx printer = Demo.PrinterPrxHelper.checkedCast(base);
- if (printer == null)
+ if(printer == null)
+ {
throw new Error("Invalid proxy");
+ }
printer.printString("Hello World!");
- } catch (Ice.LocalException e) {
+ }
+ catch(Ice.LocalException e)
+ {
e.printStackTrace();
status = 1;
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
System.err.println(e.getMessage());
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
System.err.println(e.getMessage());
status = 1;
}
diff --git a/java/demo/book/printer/PrinterI.java b/java/demo/book/printer/PrinterI.java
index a00699af269..bf48aad2c8f 100644
--- a/java/demo/book/printer/PrinterI.java
+++ b/java/demo/book/printer/PrinterI.java
@@ -7,7 +7,8 @@
//
// **********************************************************************
-public class PrinterI extends Demo._PrinterDisp {
+public class PrinterI extends Demo._PrinterDisp
+{
public void
printString(String s, Ice.Current current)
{
diff --git a/java/demo/book/printer/Server.java b/java/demo/book/printer/Server.java
index 5d278107c7b..89f8fddae30 100644
--- a/java/demo/book/printer/Server.java
+++ b/java/demo/book/printer/Server.java
@@ -7,33 +7,35 @@
//
// **********************************************************************
-public class Server {
+public class Server
+{
public static void
main(String[] args)
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
ic = Ice.Util.initialize(args);
- Ice.ObjectAdapter adapter
- = ic.createObjectAdapterWithEndpoints(
- "SimplePrinterAdapter", "default -p 10000");
+ Ice.ObjectAdapter adapter = ic.createObjectAdapterWithEndpoints("SimplePrinterAdapter", "default -p 10000");
Ice.Object object = new PrinterI();
- adapter.add(
- object,
- ic.stringToIdentity("SimplePrinter"));
+ adapter.add(object, ic.stringToIdentity("SimplePrinter"));
adapter.activate();
ic.waitForShutdown();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
e.printStackTrace();
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
System.err.println(e.getMessage());
status = 1;
}
diff --git a/java/demo/book/simple_filesystem/Client.java b/java/demo/book/simple_filesystem/Client.java
index fa90748d197..bc3569af867 100644
--- a/java/demo/book/simple_filesystem/Client.java
+++ b/java/demo/book/simple_filesystem/Client.java
@@ -9,8 +9,8 @@
import Filesystem.*;
-public class Client {
-
+public class Client
+{
// Recursively print the contents of directory "dir" in tree fashion.
// For files, show the contents of each file. The "depth"
// parameter is the current nesting level (for indentation).
@@ -24,16 +24,22 @@ public class Client {
NodePrx[] contents = dir.list();
- for (int i = 0; i < contents.length; ++i) {
+ for(int i = 0; i < contents.length; ++i)
+ {
DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(contents[i]);
FilePrx file = FilePrxHelper.uncheckedCast(contents[i]);
System.out.println(indent + contents[i].name() + (subdir != null ? " (directory):" : " (file):"));
- if (subdir != null) {
+ if(subdir != null)
+ {
listRecursive(subdir, depth);
- } else {
+ }
+ else
+ {
String[] text = file.read();
- for (int j = 0; j < text.length; ++j)
+ for(int j = 0; j < text.length; ++j)
+ {
System.out.println(indent + "\t" + text[j]);
+ }
}
}
}
@@ -43,38 +49,51 @@ public class Client {
{
int status = 0;
Ice.Communicator ic = null;
- try {
+ try
+ {
+ //
// Create a communicator
//
ic = Ice.Util.initialize(args);
+ //
// Create a proxy for the root directory
//
Ice.ObjectPrx base = ic.stringToProxy("RootDir:default -p 10000");
+ //
// Down-cast the proxy to a Directory proxy
//
DirectoryPrx rootDir = DirectoryPrxHelper.checkedCast(base);
- if (rootDir == null)
+ if(rootDir == null)
+ {
throw new RuntimeException("Invalid proxy");
+ }
+ //
// Recursively list the contents of the root directory
//
System.out.println("Contents of root directory:");
listRecursive(rootDir, 0);
- } catch (Ice.LocalException e) {
+ }
+ catch(Ice.LocalException e)
+ {
e.printStackTrace();
status = 1;
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
System.err.println(e.getMessage());
status = 1;
}
- if (ic != null) {
- // Clean up
- //
- try {
+ if(ic != null)
+ {
+ try
+ {
ic.destroy();
- } catch (Exception e) {
+ }
+ catch(Exception e)
+ {
System.err.println(e.getMessage());
status = 1;
}
diff --git a/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java b/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
index f52f8f28a38..7acb88c4112 100644
--- a/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
+++ b/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
@@ -23,7 +23,6 @@ public final class DirectoryI extends _DirectoryDisp
//
_id = new Ice.Identity();
_id.name = _parent != null ? java.util.UUID.randomUUID().toString() : "RootDir";
-
}
// Slice Node::name() operation
diff --git a/java/demo/book/simple_filesystem/Filesystem/FileI.java b/java/demo/book/simple_filesystem/Filesystem/FileI.java
index 69bb0684363..79ecfd1f130 100644
--- a/java/demo/book/simple_filesystem/Filesystem/FileI.java
+++ b/java/demo/book/simple_filesystem/Filesystem/FileI.java
@@ -21,6 +21,7 @@ public class FileI extends _FileDisp
assert(_parent != null);
+ //
// Create an identity
//
_id = new Ice.Identity();
diff --git a/java/demo/book/simple_filesystem/Server.java b/java/demo/book/simple_filesystem/Server.java
index aefca791431..4889a6e47ab 100644
--- a/java/demo/book/simple_filesystem/Server.java
+++ b/java/demo/book/simple_filesystem/Server.java
@@ -9,41 +9,51 @@
import Filesystem.*;
-public class Server extends Ice.Application {
+public class Server extends Ice.Application
+{
public int
run(String[] args)
{
+ //
// Terminate cleanly on receipt of a signal
//
shutdownOnInterrupt();
+ //
// Create an object adapter.
//
- Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
- "SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ Ice.ObjectAdapter adapter =
+ communicator().createObjectAdapterWithEndpoints("SimpleFilesystem", "default -h 127.0.0.1 -p 10000");
+ //
// Create the root directory (with name "/" and no parent)
//
DirectoryI root = new DirectoryI(communicator(), "/", null);
root.activate(adapter);
+ //
// Create a file called "README" in the root directory
//
FileI file = new FileI(communicator(), "README", root);
String[] text;
text = new String[]{ "This file system contains a collection of poetry." };
- try {
+ try
+ {
file.write(text, null);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
System.err.println(e.reason);
}
file.activate(adapter);
+ //
// Create a directory called "Coleridge" in the root directory
//
DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
coleridge.activate(adapter);
+ //
// Create a file called "Kubla_Khan" in the Coleridge directory
//
file = new FileI(communicator(), "Kubla_Khan", coleridge);
@@ -52,23 +62,30 @@ public class Server extends Ice.Application {
"Where Alph, the sacred river, ran",
"Through caverns measureless to man",
"Down to a sunless sea." };
- try {
+ try
+ {
file.write(text, null);
- } catch (GenericError e) {
+ }
+ catch(GenericError e)
+ {
System.err.println(e.reason);
}
file.activate(adapter);
+ //
// All objects are created, allow client requests now
//
adapter.activate();
+ //
// Wait until we are done
//
communicator().waitForShutdown();
- if (interrupted())
+ if(interrupted())
+ {
System.err.println(appName() + ": terminating");
+ }
return 0;
}