summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2008-04-10 15:15:12 +1000
committerMichi Henning <michi@zeroc.com>2008-04-10 15:15:12 +1000
commitff019fee471682420ef738c4fa2f30fd874993ac (patch)
treea58ab62c457972c77a41478ca968c78b7d874fdd
parentminor edits to Silverlight docs (diff)
downloadice-ff019fee471682420ef738c4fa2f30fd874993ac.tar.bz2
ice-ff019fee471682420ef738c4fa2f30fd874993ac.tar.xz
ice-ff019fee471682420ef738c4fa2f30fd874993ac.zip
Bug 2803.
-rw-r--r--cpp/demo/book/freeze_filesystem/Client.cpp52
-rw-r--r--cpp/demo/book/freeze_filesystem/Filesystem.ice22
-rw-r--r--cpp/demo/book/freeze_filesystem/PersistentFilesystem.ice2
-rw-r--r--cpp/demo/book/freeze_filesystem/PersistentFilesystemI.cpp141
-rw-r--r--cpp/demo/book/freeze_filesystem/PersistentFilesystemI.h9
-rw-r--r--cpp/demo/book/freeze_filesystem/Server.cpp11
-rw-r--r--cpp/demo/book/lifecycle/FilesystemI.cpp78
-rw-r--r--cpp/demo/book/lifecycle/FilesystemI.h11
-rw-r--r--cpp/demo/book/lifecycle/Server.cpp3
-rwxr-xr-xcpp/demo/book/simple_filesystem/Client.cpp4
-rwxr-xr-xcpp/demo/book/simple_filesystem/FilesystemI.cpp61
-rwxr-xr-xcpp/demo/book/simple_filesystem/FilesystemI.h28
-rwxr-xr-xcpp/demo/book/simple_filesystem/Server.cpp18
-rw-r--r--cs/demo/book/lifecycle/DirectoryI.cs29
-rw-r--r--cs/demo/book/lifecycle/FileI.cs10
-rw-r--r--cs/demo/book/lifecycle/Server.cs3
-rw-r--r--cs/demo/book/simple_filesystem/DirectoryI.cs30
-rw-r--r--cs/demo/book/simple_filesystem/FileI.cs23
-rw-r--r--cs/demo/book/simple_filesystem/Server.cs17
-rwxr-xr-xdemoscript/book/freeze_filesystem.py3
-rw-r--r--java/demo/book/freeze_filesystem/Client.java56
-rw-r--r--java/demo/book/freeze_filesystem/DirectoryI.java117
-rw-r--r--java/demo/book/freeze_filesystem/Filesystem.ice22
-rw-r--r--java/demo/book/freeze_filesystem/PersistentFilesystem.ice2
-rw-r--r--java/demo/book/lifecycle/FilesystemI/DirectoryI.java30
-rw-r--r--java/demo/book/lifecycle/FilesystemI/FileI.java12
-rw-r--r--java/demo/book/lifecycle/Server.java4
-rwxr-xr-xjava/demo/book/simple_filesystem/Filesystem/DirectoryI.java31
-rwxr-xr-xjava/demo/book/simple_filesystem/Filesystem/FileI.java22
-rwxr-xr-xjava/demo/book/simple_filesystem/Server.java17
-rwxr-xr-xpy/demo/book/simple_filesystem/Server.py63
-rwxr-xr-xvb/demo/book/simple_filesystem/DirectoryI.vb2
32 files changed, 434 insertions, 499 deletions
diff --git a/cpp/demo/book/freeze_filesystem/Client.cpp b/cpp/demo/book/freeze_filesystem/Client.cpp
index 53f360f38b3..f9ff7944e43 100644
--- a/cpp/demo/book/freeze_filesystem/Client.cpp
+++ b/cpp/demo/book/freeze_filesystem/Client.cpp
@@ -13,6 +13,31 @@
using namespace std;
using namespace Filesystem;
+// 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).
+
+static void
+listRecursive(const DirectoryPrx & dir, int depth = 0)
+{
+ string indent(++depth, '\t');
+
+ NodeDescSeq contents = dir->list();
+
+ for (NodeDescSeq::const_iterator i = contents.begin(); i != contents.end(); ++i) {
+ DirectoryPrx dir = DirectoryPrx::checkedCast(i->proxy);
+ FilePrx file = FilePrx::uncheckedCast(i->proxy);
+ cout << indent << i->name << (dir ? " (directory):" : " (file):") << endl;
+ if (dir) {
+ listRecursive(dir, depth);
+ } else {
+ Lines text = file->read();
+ for (Lines::const_iterator j = text.begin(); j != text.end(); ++j)
+ cout << indent << "\t" << *j << endl;
+ }
+ }
+}
+
class FilesystemClient : public Ice::Application
{
public:
@@ -79,7 +104,7 @@ FilesystemClient::run(int argc, char* argv[])
}
catch(const NameInUse&)
{
- NodeDesc desc = rootDir->resolve("Coleridge");
+ NodeDesc desc = rootDir->find("Coleridge");
coleridge = DirectoryPrx::checkedCast(desc.proxy);
assert(coleridge);
}
@@ -107,31 +132,16 @@ FilesystemClient::run(int argc, char* argv[])
}
cout << "Contents of filesystem:" << endl;
- NodeDict contents = rootDir->list(RecursiveList);
- NodeDict::iterator p;
- for(p = contents.begin(); p != contents.end(); ++p)
- {
- cout << " " << p->first << endl;
- }
-
- NodeDesc desc = rootDir->resolve("Coleridge/Kubla_Khan");
- FilePrx file = FilePrx::checkedCast(desc.proxy);
- assert(file);
- Lines text = file->read();
- cout << "Contents of file Coleridge/Kubla_Khan:" << endl;
- for(Lines::iterator i = text.begin(); i != text.end(); ++i)
- {
- cout << " " << *i << endl;
- }
+ listRecursive(rootDir);
//
// Destroy the filesystem.
//
- contents = rootDir->list(NormalList);
- for(p = contents.begin(); p != contents.end(); ++p)
+ NodeDescSeq contents = rootDir->list();
+ for(NodeDescSeq::iterator i = contents.begin(); i != contents.end(); ++i)
{
- cout << "Destroying " << p->first << "..." << endl;
- p->second.proxy->destroy();
+ cout << "Destroying " << i->name << endl;
+ i->proxy->destroy();
}
return EXIT_SUCCESS;
diff --git a/cpp/demo/book/freeze_filesystem/Filesystem.ice b/cpp/demo/book/freeze_filesystem/Filesystem.ice
index b8427f36525..b8b5b38d351 100644
--- a/cpp/demo/book/freeze_filesystem/Filesystem.ice
+++ b/cpp/demo/book/freeze_filesystem/Filesystem.ice
@@ -15,7 +15,6 @@ module Filesystem
};
exception PermissionDenied extends GenericError {};
exception NameInUse extends GenericError {};
- exception IllegalName extends GenericError {};
exception NoSuchName extends GenericError {};
interface Node
@@ -23,8 +22,7 @@ module Filesystem
idempotent string name();
["freeze:write"]
- void destroy()
- throws PermissionDenied;
+ void destroy() throws PermissionDenied;
};
sequence<string> Lines;
@@ -34,8 +32,7 @@ module Filesystem
idempotent Lines read();
["freeze:write"]
- idempotent void write(Lines text)
- throws GenericError;
+ idempotent void write(Lines text) throws GenericError;
};
enum NodeType { DirType, FileType };
@@ -47,23 +44,18 @@ module Filesystem
Node* proxy;
};
- dictionary<string, NodeDesc> NodeDict;
-
- enum ListMode { NormalList, RecursiveList };
+ sequence<NodeDesc> NodeDescSeq;
interface Directory extends Node
{
- idempotent NodeDict list(ListMode mode);
+ idempotent NodeDescSeq list();
- idempotent NodeDesc resolve(string path)
- throws NoSuchName;
+ idempotent NodeDesc find(string name) throws NoSuchName;
["freeze:write"]
- File* createFile(string name)
- throws NameInUse, IllegalName;
+ File* createFile(string name) throws NameInUse;
["freeze:write"]
- Directory* createDirectory(string name)
- throws NameInUse, IllegalName;
+ Directory* createDirectory(string name) throws NameInUse;
};
};
diff --git a/cpp/demo/book/freeze_filesystem/PersistentFilesystem.ice b/cpp/demo/book/freeze_filesystem/PersistentFilesystem.ice
index 774d2603eab..2895d2f5d14 100644
--- a/cpp/demo/book/freeze_filesystem/PersistentFilesystem.ice
+++ b/cpp/demo/book/freeze_filesystem/PersistentFilesystem.ice
@@ -24,6 +24,8 @@ module Filesystem
Lines text;
};
+ dictionary<string, NodeDesc> NodeDict;
+
class PersistentDirectory extends PersistentNode implements Directory
{
["freeze:write"]
diff --git a/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.cpp b/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.cpp
index 7bfe9e9f3e5..984a4c282e1 100644
--- a/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.cpp
+++ b/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.cpp
@@ -14,18 +14,17 @@ using namespace std;
//
// Filesystem::NodeI
//
-Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter;
Freeze::EvictorPtr Filesystem::NodeI::_evictor;
Filesystem::NodeI::NodeI()
#ifdef __SUNPRO_CC
- : _ID(Ice::Identity())
+ : _id(Ice::Identity())
#endif
{
}
Filesystem::NodeI::NodeI(const Ice::Identity& id)
- : _ID(id)
+ : _id(id)
{
}
@@ -42,7 +41,7 @@ void
Filesystem::FileI::destroy(const Ice::Current&)
{
parent->removeNode(nodeName);
- _evictor->remove(_ID);
+ _evictor->remove(_id);
}
Filesystem::Lines
@@ -72,24 +71,24 @@ Filesystem::FileI::FileI(const Ice::Identity& id)
// Filesystem::DirectoryI
//
string
-Filesystem::DirectoryI::name(const Ice::Current& current)
+Filesystem::DirectoryI::name(const Ice::Current& c)
{
IceUtil::Mutex::Lock lock(*this);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
return nodeName;
}
void
-Filesystem::DirectoryI::destroy(const Ice::Current& current)
+Filesystem::DirectoryI::destroy(const Ice::Current& c)
{
if(!parent)
{
- throw Filesystem::PermissionDenied("cannot remove root directory");
+ throw Filesystem::PermissionDenied("cannot destroy root directory");
}
NodeDict children;
@@ -99,7 +98,7 @@ Filesystem::DirectoryI::destroy(const Ice::Current& current)
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
children = nodes;
@@ -107,7 +106,7 @@ Filesystem::DirectoryI::destroy(const Ice::Current& current)
}
//
- // We must iterate over the children outside of synchronization.
+ // We must iterate over the children outside the synchronization.
//
for(NodeDict::iterator p = children.begin(); p != children.end(); ++p)
{
@@ -117,107 +116,65 @@ Filesystem::DirectoryI::destroy(const Ice::Current& current)
assert(nodes.empty());
parent->removeNode(nodeName);
- _evictor->remove(_ID);
+ _evictor->remove(_id);
}
-Filesystem::NodeDict
-Filesystem::DirectoryI::list(Filesystem::ListMode mode, const Ice::Current& current)
+Filesystem::NodeDescSeq
+Filesystem::DirectoryI::list(const Ice::Current& c)
{
- NodeDict result;
- {
- IceUtil::Mutex::Lock lock(*this);
-
- if(_destroyed)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
- }
+ IceUtil::Mutex::Lock lock(*this);
- result = nodes;
+ if(_destroyed)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
- if(mode == RecursiveList)
+ NodeDict::const_iterator p;
+ NodeDescSeq result;
+ for(p = nodes.begin(); p != nodes.end(); ++p)
{
- for(NodeDict::iterator p = result.begin(); p != result.end(); ++p)
- {
- if(p->second.type == DirType)
- {
- DirectoryPrx dir = DirectoryPrx::uncheckedCast(p->second.proxy);
- NodeDict d = dir->list(mode);
- for(NodeDict::iterator q = d.begin(); q != d.end(); ++q)
- {
- result[p->second.name + "/" + q->second.name] = q->second;
- }
- }
- }
+ result.push_back(p->second);
}
-
return result;
}
Filesystem::NodeDesc
-Filesystem::DirectoryI::resolve(const string& path, const Ice::Current& current)
+Filesystem::DirectoryI::find(const string& name, const Ice::Current& c)
{
- string::size_type pos = path.find('/');
- string child, remainder;
- if(pos == string::npos)
- {
- child = path;
- }
- else
- {
- child = path.substr(0, pos);
- pos = path.find_first_not_of("/", pos);
- if(pos != string::npos)
- {
- remainder = path.substr(pos);
- }
- }
-
IceUtil::Mutex::Lock lock(*this);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
- NodeDict::iterator p = nodes.find(child);
+ NodeDict::iterator p = nodes.find(name);
if(p == nodes.end())
{
- throw NoSuchName("no node exists with name `" + child + "'");
- }
-
- if(remainder.empty())
- {
- return p->second;
- }
- else
- {
- if(p->second.type != DirType)
- {
- throw NoSuchName("node `" + child + "' is not a directory");
- }
- DirectoryPrx dir = DirectoryPrx::checkedCast(p->second.proxy);
- assert(dir);
- return dir->resolve(remainder);
+ throw NoSuchName(name);
}
+ return p->second;
}
Filesystem::DirectoryPrx
-Filesystem::DirectoryI::createDirectory(const string& name, const Ice::Current& current)
+Filesystem::DirectoryI::createDirectory(const string& name, const Ice::Current& c)
{
IceUtil::Mutex::Lock lock(*this);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
- checkName(name);
+ if(name.empty() || nodes.find(name) != nodes.end())
+ {
+ throw NameInUse(name);
+ }
- Ice::Identity id = current.adapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID());
+ Ice::Identity id = c.adapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID());
PersistentDirectoryPtr dir = new DirectoryI(id);
dir->nodeName = name;
- dir->parent = PersistentDirectoryPrx::uncheckedCast(current.adapter->createProxy(current.id));
+ dir->parent = PersistentDirectoryPrx::uncheckedCast(c.adapter->createProxy(c.id));
DirectoryPrx proxy = DirectoryPrx::uncheckedCast(_evictor->add(dir, id));
NodeDesc nd;
@@ -230,21 +187,24 @@ Filesystem::DirectoryI::createDirectory(const string& name, const Ice::Current&
}
Filesystem::FilePrx
-Filesystem::DirectoryI::createFile(const string& name, const Ice::Current& current)
+Filesystem::DirectoryI::createFile(const string& name, const Ice::Current& c)
{
IceUtil::Mutex::Lock lock(*this);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
- checkName(name);
+ if(name.empty() || nodes.find(name) != nodes.end())
+ {
+ throw NameInUse(name);
+ }
- Ice::Identity id = current.adapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID());
+ Ice::Identity id = c.adapter->getCommunicator()->stringToIdentity(IceUtil::generateUUID());
PersistentFilePtr file = new FileI(id);
file->nodeName = name;
- file->parent = PersistentDirectoryPrx::uncheckedCast(current.adapter->createProxy(current.id));
+ file->parent = PersistentDirectoryPrx::uncheckedCast(c.adapter->createProxy(c.id));
FilePrx proxy = FilePrx::uncheckedCast(_evictor->add(file, id));
NodeDesc nd;
@@ -276,23 +236,6 @@ Filesystem::DirectoryI::DirectoryI(const Ice::Identity& id) :
{
}
-void
-Filesystem::DirectoryI::checkName(const string& name) const
-{
- if(name.empty() || name.find('/') != string::npos)
- {
- IllegalName e;
- e.reason = "illegal name `" + name + "'";
- throw e;
- }
-
- NodeDict::const_iterator p = nodes.find(name);
- if(p != nodes.end())
- {
- throw NameInUse("name `" + name + "' is already in use");
- }
-}
-
//
// Filesystem::NodeFactory
//
@@ -330,5 +273,5 @@ Filesystem::NodeInitializer::initialize(const Ice::ObjectAdapterPtr&,
{
NodeIPtr node = NodeIPtr::dynamicCast(obj);
assert(node);
- const_cast<Ice::Identity&>(node->_ID) = id;
+ const_cast<Ice::Identity&>(node->_id) = id;
}
diff --git a/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.h b/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.h
index 4533f63ac48..bdbbea08374 100644
--- a/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.h
+++ b/cpp/demo/book/freeze_filesystem/PersistentFilesystemI.h
@@ -22,7 +22,6 @@ class NodeI : virtual public PersistentNode,
{
public:
- static Ice::ObjectAdapterPtr _adapter;
static Freeze::EvictorPtr _evictor;
protected:
@@ -32,7 +31,7 @@ protected:
public:
- const Ice::Identity _ID;
+ const Ice::Identity _id;
};
typedef IceUtil::Handle<NodeI> NodeIPtr;
@@ -59,8 +58,8 @@ public:
virtual std::string name(const Ice::Current&);
virtual void destroy(const Ice::Current&);
- virtual NodeDict list(ListMode, const Ice::Current&);
- virtual NodeDesc resolve(const std::string&, const Ice::Current&);
+ virtual NodeDescSeq list(const Ice::Current&);
+ virtual NodeDesc find(const std::string&, const Ice::Current&);
virtual DirectoryPrx createDirectory(const std::string&, const Ice::Current&);
virtual FilePrx createFile(const std::string&, const Ice::Current&);
virtual void removeNode(const std::string&, const Ice::Current&);
@@ -70,8 +69,6 @@ public:
private:
- void checkName(const std::string&) const;
-
bool _destroyed;
};
diff --git a/cpp/demo/book/freeze_filesystem/Server.cpp b/cpp/demo/book/freeze_filesystem/Server.cpp
index a67bb146c3e..86d7e349e3a 100644
--- a/cpp/demo/book/freeze_filesystem/Server.cpp
+++ b/cpp/demo/book/freeze_filesystem/Server.cpp
@@ -31,17 +31,18 @@ public:
communicator()->addObjectFactory(factory, PersistentDirectory::ice_staticId());
//
- // Create an object adapter (stored in the NodeI::_adapter static member).
+ // Create an object adapter.
//
- NodeI::_adapter = communicator()->createObjectAdapterWithEndpoints("FreezeFilesystem", "default -p 10000");
+ Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints(
+ "FreezeFilesystem", "default -p 10000");
//
// Create the Freeze evictor (stored in the NodeI::_evictor static member).
//
Freeze::ServantInitializerPtr init = new NodeInitializer;
- NodeI::_evictor = Freeze::createBackgroundSaveEvictor(NodeI::_adapter, _envName, "evictorfs", init);
+ NodeI::_evictor = Freeze::createBackgroundSaveEvictor(adapter, _envName, "evictorfs", init);
- NodeI::_adapter->addServantLocator(NodeI::_evictor, "");
+ adapter->addServantLocator(NodeI::_evictor, "");
//
// Create the root node if it doesn't exist.
@@ -57,7 +58,7 @@ public:
//
// Ready to accept requests now.
//
- NodeI::_adapter->activate();
+ adapter->activate();
//
// Wait until we are done.
diff --git a/cpp/demo/book/lifecycle/FilesystemI.cpp b/cpp/demo/book/lifecycle/FilesystemI.cpp
index fa3ad899597..9d564dd9675 100644
--- a/cpp/demo/book/lifecycle/FilesystemI.cpp
+++ b/cpp/demo/book/lifecycle/FilesystemI.cpp
@@ -21,13 +21,13 @@ FilesystemI::DirectoryI::ReapMap FilesystemI::DirectoryI::_reapMap;
// Slice Node::name() operation.
std::string
-FilesystemI::NodeI::name(const Current&)
+FilesystemI::NodeI::name(const Current& c)
{
IceUtil::Mutex::Lock lock(_m);
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
return _name;
@@ -41,21 +41,46 @@ FilesystemI::NodeI::id() const
return _id;
}
+// Activate the servant and add it to the parent's contents map.
+
+ObjectPrx
+FilesystemI::NodeI::activate(const ObjectAdapterPtr& a)
+{
+ ObjectPrx node = a->add(this, _id);
+ if(_parent)
+ {
+ _parent->addChild(_name, this);
+ }
+ return node;
+}
+
+// NodeI constructor.
+
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)
+ {
+ _id.name = "RootDir";
+ }
+ else
+ {
+ _id.name = IceUtil::generateUUID();
+ }
}
// Slice File::read() operation.
Lines
-FilesystemI::FileI::read(const Current&)
+FilesystemI::FileI::read(const Current& c)
{
IceUtil::Mutex::Lock lock(_m);
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
return _lines;
@@ -64,13 +89,13 @@ FilesystemI::FileI::read(const Current&)
// Slice File::write() operation.
void
-FilesystemI::FileI::write(const Lines& text, const Current&)
+FilesystemI::FileI::write(const Lines& text, const Current& c)
{
IceUtil::Mutex::Lock lock(_m);
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
_lines = text;
@@ -86,7 +111,7 @@ FilesystemI::FileI::destroy(const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
_destroyed = true;
}
@@ -99,12 +124,9 @@ FilesystemI::FileI::destroy(const Current& c)
// FileI constructor.
-FilesystemI::FileI::FileI(const ObjectAdapterPtr& a, const string& name, const DirectoryIPtr& parent)
+FilesystemI::FileI::FileI(const string& name, const DirectoryIPtr& parent)
: NodeI(name, parent)
{
- _id.name = IceUtil::generateUUID();
- parent->addChild(name, this);
- a->add(this, _id);
}
// Slice Directory::list() operation.
@@ -117,7 +139,7 @@ FilesystemI::DirectoryI::list(const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
}
@@ -147,7 +169,7 @@ FilesystemI::DirectoryI::find(const string& name, const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
}
@@ -179,7 +201,7 @@ FilesystemI::DirectoryI::createFile(const string& name, const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
}
@@ -187,13 +209,13 @@ FilesystemI::DirectoryI::createFile(const string& name, const Current& c)
reap();
- if(_contents.find(name) != _contents.end())
+ if(name.empty() || _contents.find(name) != _contents.end())
{
throw NameInUse(name);
}
- FileIPtr f = new FileI(c.adapter, name, this);
- return FilePrx::uncheckedCast(c.adapter->createProxy(f->id()));
+ FileIPtr f = new FileI(name, this);
+ return FilePrx::uncheckedCast(f->activate(c.adapter));
}
// Slice Directory::createDirectory() operation.
@@ -206,7 +228,7 @@ FilesystemI::DirectoryI::createDirectory(const string& name, const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
}
@@ -214,13 +236,13 @@ FilesystemI::DirectoryI::createDirectory(const string& name, const Current& c)
reap();
- if(_contents.find(name) != _contents.end())
+ if(name.empty() || _contents.find(name) != _contents.end())
{
throw NameInUse(name);
}
- DirectoryIPtr d = new DirectoryI(c.adapter, name, this);
- return DirectoryPrx::uncheckedCast(c.adapter->createProxy(d->id()));
+ DirectoryIPtr d = new DirectoryI(name, this);
+ return DirectoryPrx::uncheckedCast(d->activate(c.adapter));
}
// Slice Directory::destroy() operation.
@@ -238,7 +260,7 @@ FilesystemI::DirectoryI::destroy(const Current& c)
if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
}
IceUtil::StaticMutex::Lock lcLock(_lcMutex);
@@ -257,19 +279,9 @@ FilesystemI::DirectoryI::destroy(const Current& c)
// DirectoryI constructor.
-FilesystemI::DirectoryI::DirectoryI(const ObjectAdapterPtr& a, const string& name, const DirectoryIPtr& parent)
+FilesystemI::DirectoryI::DirectoryI(const string& name, const DirectoryIPtr& parent)
: NodeI(name, parent)
{
- if(!parent)
- {
- _id.name = "RootDir";
- }
- else
- {
- _id.name = IceUtil::generateUUID();
- _parent->addChild(name, this);
- }
- a->add(this, _id);
}
// Add the passed name-node pair to the _contents map.
diff --git a/cpp/demo/book/lifecycle/FilesystemI.h b/cpp/demo/book/lifecycle/FilesystemI.h
index 01e24b00ace..bf86be54f8f 100644
--- a/cpp/demo/book/lifecycle/FilesystemI.h
+++ b/cpp/demo/book/lifecycle/FilesystemI.h
@@ -23,10 +23,13 @@ namespace FilesystemI
class NodeI : virtual public Filesystem::Node
{
public:
+
virtual std::string name(const Ice::Current&);
Ice::Identity id() const;
+ Ice::ObjectPrx activate(const Ice::ObjectAdapterPtr&);
protected:
+
NodeI(const ::std::string&, const DirectoryIPtr&);
const ::std::string _name;
@@ -41,13 +44,15 @@ namespace FilesystemI
class FileI : virtual public Filesystem::File, virtual public NodeI
{
public:
+
virtual Filesystem::Lines read(const Ice::Current&);
virtual void write(const Filesystem::Lines&, const Ice::Current&);
virtual void destroy(const Ice::Current&);
- FileI(const Ice::ObjectAdapterPtr&, const std::string&, const DirectoryIPtr&);
+ FileI(const std::string&, const DirectoryIPtr&);
private:
+
Filesystem::Lines _lines;
};
@@ -56,13 +61,14 @@ namespace FilesystemI
class DirectoryI : virtual public NodeI, virtual public Filesystem::Directory
{
public:
+
virtual Filesystem::NodeDescSeq list(const Ice::Current&);
virtual Filesystem::NodeDesc find(const std::string& name, const Ice::Current&);
Filesystem::FilePrx createFile(const ::std::string&, const Ice::Current&);
Filesystem::DirectoryPrx createDirectory(const ::std::string&, const Ice::Current&);
virtual void destroy(const Ice::Current&);
- DirectoryI(const Ice::ObjectAdapterPtr&, const std::string& = "/", const DirectoryIPtr& = 0);
+ DirectoryI(const std::string& = "/", const DirectoryIPtr& = 0);
void addChild(const ::std::string&, const NodeIPtr&);
void addReapEntry(const ::std::string&);
@@ -70,6 +76,7 @@ namespace FilesystemI
static IceUtil::StaticMutex _lcMutex;
private:
+
typedef ::std::map< ::std::string, NodeIPtr> Contents;
Contents _contents;
diff --git a/cpp/demo/book/lifecycle/Server.cpp b/cpp/demo/book/lifecycle/Server.cpp
index a30462fb127..ff99757a233 100644
--- a/cpp/demo/book/lifecycle/Server.cpp
+++ b/cpp/demo/book/lifecycle/Server.cpp
@@ -29,7 +29,8 @@ public:
// Create the root directory.
//
- new DirectoryI(adapter);
+ DirectoryIPtr root = new DirectoryI();
+ root->activate(adapter);
// All objects are created, allow client requests now.
//
diff --git a/cpp/demo/book/simple_filesystem/Client.cpp b/cpp/demo/book/simple_filesystem/Client.cpp
index c2a30428ba3..51c24e6951b 100755
--- a/cpp/demo/book/simple_filesystem/Client.cpp
+++ b/cpp/demo/book/simple_filesystem/Client.cpp
@@ -20,7 +20,7 @@ using namespace Filesystem;
// parameter is the current nesting level (for indentation).
static void
-listRecursive(const DirectoryPrx & dir, int depth = 0)
+listRecursive(const DirectoryPrx& dir, int depth = 0)
{
string indent(++depth, '\t');
@@ -41,7 +41,7 @@ listRecursive(const DirectoryPrx & dir, int depth = 0)
}
int
-main(int argc, char * argv[])
+main(int argc, char* argv[])
{
int status = 0;
Ice::CommunicatorPtr ic;
diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.cpp b/cpp/demo/book/simple_filesystem/FilesystemI.cpp
index 81839b84fe3..ea0dbbc5e4a 100755
--- a/cpp/demo/book/simple_filesystem/FilesystemI.cpp
+++ b/cpp/demo/book/simple_filesystem/FilesystemI.cpp
@@ -3,7 +3,7 @@
// Copyright (c) 2003-2008 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.
+// ICE_LICENSE file include, in this distribution.
//
// **********************************************************************
@@ -12,52 +12,55 @@
using namespace std;
-Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter; // static member
-
// Slice Node::name() operation
std::string
-Filesystem::NodeI::name(const Ice::Current &)
+Filesystem::NodeI::name(const Ice::Current&)
{
return _name;
}
// NodeI constructor
-Filesystem::NodeI::NodeI(const Ice::CommunicatorPtr & ic, const string & name, const DirectoryIPtr & parent) :
+Filesystem::NodeI::NodeI(const Ice::CommunicatorPtr& communicator, const string& name, const DirectoryIPtr& parent) :
_name(name), _parent(parent)
{
- // Create an identity. The parent has the fixed identity "RootDir"
+ // Create an identity. The root directory has the fixed identity "RootDir"
//
// COMPILERFIX:
//
- // The line below causes a "thread synchronization error" exception on HP-UX (64 bit only):
+ // The line below causes "thread synchronization error" exception on HP-UX (64-bit only):
//
- // Ice::Identity myID = Ice::stringToIdentity(parent ? IceUtil::generateUUID() : "RootDir");
+ // _id = communicator->stringToIdentity(parent ? IceUtil::generateUUID() : "RootDir");
//
// We've rearranged the code to avoid the problem.
//
- Ice::Identity myID;
- if (parent)
- myID = ic->stringToIdentity(IceUtil::generateUUID());
+ if(parent)
+ {
+ _id = communicator->stringToIdentity(IceUtil::generateUUID());
+ }
else
- myID = ic->stringToIdentity("RootDir");
+ {
+ _id = communicator->stringToIdentity("RootDir");
+ }
+}
- // Create a proxy for the new node and add it as a child to the parent
- //
- NodePrx thisNode = NodePrx::uncheckedCast(_adapter->createProxy(myID));
- if (parent)
- parent->addChild(thisNode);
+// NodeI activate() member function
- // Activate the servant
- //
- _adapter->add(this, myID);
+void
+Filesystem::NodeI::activate(const Ice::ObjectAdapterPtr& a)
+{
+ NodePrx thisNode = NodePrx::uncheckedCast(a->add(this, _id));
+ if(_parent)
+ {
+ _parent->addChild(thisNode);
+ }
}
// Slice File::read() operation
Filesystem::Lines
-Filesystem::FileI::read(const Ice::Current &)
+Filesystem::FileI::read(const Ice::Current&)
{
return _lines;
}
@@ -65,31 +68,31 @@ Filesystem::FileI::read(const Ice::Current &)
// Slice File::write() operation
void
-Filesystem::FileI::write(const Filesystem::Lines & text,
- const Ice::Current &)
+Filesystem::FileI::write(const Filesystem::Lines& text, const Ice::Current&)
{
_lines = text;
}
// FileI constructor
-Filesystem::FileI::FileI(const Ice::CommunicatorPtr & ic, const string & name, const DirectoryIPtr & parent) :
- NodeI(ic, name, parent)
+Filesystem::FileI::FileI(const Ice::CommunicatorPtr& communicator, const string& name, const DirectoryIPtr& parent) :
+ NodeI(communicator, name, parent)
{
}
// Slice Directory::list() operation
Filesystem::NodeSeq
-Filesystem::DirectoryI::list(const Ice::Current &)
+Filesystem::DirectoryI::list(const Ice::Current& c)
{
return _contents;
}
// DirectoryI constructor
-Filesystem::DirectoryI::DirectoryI(const Ice::CommunicatorPtr & ic, const string & name, const DirectoryIPtr & parent) :
- NodeI(ic, name, parent)
+Filesystem::DirectoryI::DirectoryI(const Ice::CommunicatorPtr& communicator, const string& name,
+ const DirectoryIPtr& parent) :
+ NodeI(communicator, name, parent)
{
}
@@ -97,7 +100,7 @@ Filesystem::DirectoryI::DirectoryI(const Ice::CommunicatorPtr & ic, const string
// itself to the _contents member of the parent
void
-Filesystem::DirectoryI::addChild(const NodePrx child)
+Filesystem::DirectoryI::addChild(const NodePrx& child)
{
_contents.push_back(child);
}
diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.h b/cpp/demo/book/simple_filesystem/FilesystemI.h
index ea51a9eae45..226bd99ddec 100755
--- a/cpp/demo/book/simple_filesystem/FilesystemI.h
+++ b/cpp/demo/book/simple_filesystem/FilesystemI.h
@@ -14,38 +14,44 @@
#include <Filesystem.h>
namespace Filesystem {
+
class DirectoryI;
typedef IceUtil::Handle<DirectoryI> DirectoryIPtr;
class NodeI : virtual public Node {
public:
- virtual std::string name(const Ice::Current &);
- NodeI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr & parent);
- static Ice::ObjectAdapterPtr _adapter;
+ 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;
};
+ typedef IceUtil::Handle<NodeI> NodeIPtr;
+
class FileI : virtual public File,
virtual public NodeI {
public:
- virtual Lines read(const Ice::Current &);
- virtual void write(const Lines &,
- const Ice::Current &);
- FileI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &);
+ 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 {
public:
- virtual NodeSeq list(const Ice::Current &);
- DirectoryI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &);
- void addChild(NodePrx child);
+ virtual NodeSeq list(const Ice::Current&);
+ DirectoryI(const Ice::CommunicatorPtr&, const std::string&, const DirectoryIPtr&);
+ void addChild(const Filesystem::NodePrx&);
private:
- NodeSeq _contents;
+ Filesystem::NodeSeq _contents;
};
}
diff --git a/cpp/demo/book/simple_filesystem/Server.cpp b/cpp/demo/book/simple_filesystem/Server.cpp
index 664ae8ecb4c..9a86a002d8e 100755
--- a/cpp/demo/book/simple_filesystem/Server.cpp
+++ b/cpp/demo/book/simple_filesystem/Server.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <IceUtil/UUID.h>
#include <Ice/Ice.h>
#include <FilesystemI.h>
@@ -15,32 +16,34 @@ using namespace Filesystem;
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 (stored in the NodeI::_adapter
- // static member)
+ // Create an object adapter.
//
- NodeI::_adapter =
+ Ice::ObjectAdapterPtr adapter =
communicator()->createObjectAdapterWithEndpoints(
"SimpleFilesystem", "default -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
//
- FilePtr file = new FileI(communicator(), "README", root);
+ FileIPtr file = new FileI(communicator(), "README", root);
Lines text;
text.push_back("This file system contains a collection of poetry.");
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
//
@@ -52,10 +55,11 @@ public:
text.push_back("Through caverns measureless to man");
text.push_back("Down to a sunless sea.");
file->write(text);
+ file->activate(adapter);
// All objects are created, allow client requests now
//
- NodeI::_adapter->activate();
+ adapter->activate();
// Wait until we are done
//
@@ -65,8 +69,6 @@ public:
<< ": received signal, shutting down" << endl;
}
- NodeI::_adapter = 0;
-
return 0;
};
};
diff --git a/cs/demo/book/lifecycle/DirectoryI.cs b/cs/demo/book/lifecycle/DirectoryI.cs
index d71f91433ec..fe3f5c7395e 100644
--- a/cs/demo/book/lifecycle/DirectoryI.cs
+++ b/cs/demo/book/lifecycle/DirectoryI.cs
@@ -118,8 +118,7 @@ namespace FilesystemI
{
throw new NameInUse(name);
}
- FileI f = new FileI(c.adapter, name, this);
- return FilePrxHelper.uncheckedCast(c.adapter.createProxy(f.id()));
+ return new FileI(c.adapter, name, this).activate(c.adapter);
}
}
@@ -143,8 +142,7 @@ namespace FilesystemI
{
throw new NameInUse(name);
}
- DirectoryI d = new DirectoryI(c.adapter, name, this);
- return DirectoryPrxHelper.uncheckedCast(c.adapter.createProxy(d.id()));
+ return new DirectoryI(name, this).activate(c.adapter);
}
}
@@ -182,14 +180,14 @@ namespace FilesystemI
// DirectoryI constructor for root directory.
- public DirectoryI(ObjectAdapter a)
- : this(a, "RootDir", null)
+ public DirectoryI()
+ : this("/", null)
{
}
// DirectoryI constructor. parent == null indicates root directory.
- public DirectoryI(ObjectAdapter a, string name, DirectoryI parent)
+ public DirectoryI(string name, DirectoryI parent)
{
lcMutex = new System.Object();
_name = name;
@@ -200,14 +198,25 @@ namespace FilesystemI
if(parent == null)
{
- _id.name = name;
+ _id.name = "RootDir";
}
else
{
_id.name = Util.generateUUID();
- _parent.addChild(name, this);
}
- a.add(this, _id);
+ }
+
+ // Add servant to ASM and to parent's _contents map.
+
+ public DirectoryPrx
+ activate(Ice.ObjectAdapter a)
+ {
+ DirectoryPrx node = DirectoryPrxHelper.uncheckedCast(a.add(this, _id));
+ if(_parent != null)
+ {
+ _parent.addChild(_name, this);
+ }
+ return node;
}
// Add the name-node pair to the _contents map.
diff --git a/cs/demo/book/lifecycle/FileI.cs b/cs/demo/book/lifecycle/FileI.cs
index 74585d0129e..0c0b4e6cfe5 100644
--- a/cs/demo/book/lifecycle/FileI.cs
+++ b/cs/demo/book/lifecycle/FileI.cs
@@ -85,8 +85,14 @@ namespace FilesystemI
_destroyed = false;
_id = new Identity();
_id.name = Util.generateUUID();
- _parent.addChild(name, this);
- a.add(this, _id);
+ }
+
+ public FilePrx
+ activate(Ice.ObjectAdapter a)
+ {
+ FilePrx node = FilePrxHelper.uncheckedCast(a.add(this, _id));
+ _parent.addChild(_name, this);
+ return node;
}
private string _name;
diff --git a/cs/demo/book/lifecycle/Server.cs b/cs/demo/book/lifecycle/Server.cs
index 28fc9e31c71..d43aead275f 100644
--- a/cs/demo/book/lifecycle/Server.cs
+++ b/cs/demo/book/lifecycle/Server.cs
@@ -34,7 +34,8 @@ public class Server
// Create the root directory.
//
- new DirectoryI(adapter);
+ DirectoryI root = new DirectoryI();
+ root.activate(adapter);
// All objects are created, allow client requests now.
//
diff --git a/cs/demo/book/simple_filesystem/DirectoryI.cs b/cs/demo/book/simple_filesystem/DirectoryI.cs
index 6266ef77481..21f797304cd 100644
--- a/cs/demo/book/simple_filesystem/DirectoryI.cs
+++ b/cs/demo/book/simple_filesystem/DirectoryI.cs
@@ -14,25 +14,14 @@ public class DirectoryI : DirectoryDisp_
{
// DirectoryI constructor
- public DirectoryI(string name, DirectoryI parent)
+ public DirectoryI(Ice.Communicator communicator, string name, DirectoryI parent)
{
_name = name;
_parent = parent;
- // Create an identity. The parent has the fixed identity "/"
+ // Create an identity. The root directory has the fixed identity "RootDir"
//
- Ice.Identity myID =
- adapter.getCommunicator().stringToIdentity(_parent != null ? Ice.Util.generateUUID() : "RootDir");
-
- // Add the identity to the object adapter
- //
- adapter.add(this, myID);
-
- // Create a proxy for the new node and add it as a child to the parent
- //
- NodePrx thisNode = NodePrxHelper.uncheckedCast(adapter.createProxy(myID));
- if (_parent != null)
- _parent.addChild(thisNode);
+ _id = communicator.stringToIdentity(_parent != null ? Ice.Util.generateUUID() : "RootDir");
}
// Slice Node::name() operation
@@ -57,8 +46,19 @@ public class DirectoryI : DirectoryDisp_
_contents.Add(child);
}
- public static Ice.ObjectAdapter adapter;
+ // Add servant to ASM and parent's _contents map.
+
+ public void activate(Ice.ObjectAdapter a)
+ {
+ NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
+ if(_parent != null)
+ {
+ _parent.addChild(thisNode);
+ }
+ }
+
private string _name;
private DirectoryI _parent;
+ private Ice.Identity _id;
private ArrayList _contents = new ArrayList();
}
diff --git a/cs/demo/book/simple_filesystem/FileI.cs b/cs/demo/book/simple_filesystem/FileI.cs
index 905409fcf15..f5cd63f7bb7 100644
--- a/cs/demo/book/simple_filesystem/FileI.cs
+++ b/cs/demo/book/simple_filesystem/FileI.cs
@@ -14,7 +14,7 @@ public class FileI : FileDisp_
{
// FileI constructor
- public FileI(string name, DirectoryI parent)
+ public FileI(Ice.Communicator communicator, string name, DirectoryI parent)
{
_name = name;
_parent = parent;
@@ -23,16 +23,7 @@ public class FileI : FileDisp_
// Create an identity
//
- Ice.Identity myID = adapter.getCommunicator().stringToIdentity(Ice.Util.generateUUID());
-
- // Add the identity to the object adapter
- //
- adapter.add(this, myID);
-
- // Create a proxy for the new node and add it as a child to the parent
- //
- NodePrx thisNode = NodePrxHelper.uncheckedCast(adapter.createProxy(myID));
- _parent.addChild(thisNode);
+ _id = communicator.stringToIdentity(Ice.Util.generateUUID());
}
// Slice Node::name() operation
@@ -56,8 +47,16 @@ public class FileI : FileDisp_
_lines = text;
}
- public static Ice.ObjectAdapter adapter;
+ // Add servant to ASM and parent's _contents map.
+
+ public void activate(Ice.ObjectAdapter a)
+ {
+ NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
+ _parent.addChild(thisNode);
+ }
+
private string _name;
private DirectoryI _parent;
+ private Ice.Identity _id;
private string[] _lines;
}
diff --git a/cs/demo/book/simple_filesystem/Server.cs b/cs/demo/book/simple_filesystem/Server.cs
index 8b8b0704fce..847cb80d2d2 100644
--- a/cs/demo/book/simple_filesystem/Server.cs
+++ b/cs/demo/book/simple_filesystem/Server.cs
@@ -27,21 +27,19 @@ public class Server
//
shutdownOnInterrupt();
- // Create an object adapter (stored in the _adapter
- // static members)
+ // Create an object adapter.
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
"SimpleFilesystem", "default -p 10000");
- DirectoryI.adapter = adapter;
- FileI.adapter = adapter;
// Create the root directory (with name "/" and no parent)
//
- DirectoryI root = new DirectoryI("/", null);
+ DirectoryI root = new DirectoryI(communicator(), "/", null);
+ root.activate(adapter);
// Create a file called "README" in the root directory
//
- File file = new FileI("README", root);
+ FileI file = new FileI(communicator(), "README", root);
string[] text;
text = new string[]{ "This file system contains a collection of poetry." };
try {
@@ -49,14 +47,16 @@ public class Server
} catch (GenericError e) {
Console.Error.WriteLine(e.reason);
}
+ file.activate(adapter);
// Create a directory called "Coleridge" in the root directory
//
- DirectoryI coleridge = new DirectoryI("Coleridge", root);
+ DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
+ coleridge.activate(adapter);
// Create a file called "Kubla_Khan" in the Coleridge directory
//
- file = new FileI("Kubla_Khan", coleridge);
+ file = new FileI(communicator(), "Kubla_Khan", coleridge);
text = new string[]{ "In Xanadu did Kubla Khan",
"A stately pleasure-dome decree:",
"Where Alph, the sacred river, ran",
@@ -67,6 +67,7 @@ public class Server
} catch (GenericError e) {
Console.Error.WriteLine(e.reason);
}
+ file.activate(adapter);
// All objects are created, allow client requests now
//
diff --git a/demoscript/book/freeze_filesystem.py b/demoscript/book/freeze_filesystem.py
index cfaa96d72a6..fe3032277b2 100755
--- a/demoscript/book/freeze_filesystem.py
+++ b/demoscript/book/freeze_filesystem.py
@@ -13,13 +13,12 @@ import sys, signal
def run(client, server):
print "testing...",
sys.stdout.flush()
- client.expect('Created README')
+ client.expect('Created Coleridge/Kubla_Khan')
server.expect('added')
client.expect('Contents of filesystem:')
server.expect('added')
server.expect('added')
server.expect('locate')
- client.expect('Contents of file')
server.expect('locate')
client.expect('Down to a sunless sea')
server.expect('locate')
diff --git a/java/demo/book/freeze_filesystem/Client.java b/java/demo/book/freeze_filesystem/Client.java
index 5c9b158630e..01aac52f880 100644
--- a/java/demo/book/freeze_filesystem/Client.java
+++ b/java/demo/book/freeze_filesystem/Client.java
@@ -11,6 +11,33 @@ import Filesystem.*;
public class Client extends Ice.Application
{
+ // 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).
+
+ static void
+ listRecursive(DirectoryPrx dir, int depth)
+ {
+ char[] indentCh = new char[++depth];
+ java.util.Arrays.fill(indentCh, '\t');
+ String indent = new String(indentCh);
+
+ NodeDesc[] contents = dir.list();
+
+ for (int i = 0; i < contents.length; ++i) {
+ DirectoryPrx subdir = DirectoryPrxHelper.checkedCast(contents[i].proxy);
+ FilePrx file = FilePrxHelper.uncheckedCast(contents[i].proxy);
+ System.out.println(indent + contents[i].name + (subdir != null ? " (directory):" : " (file):"));
+ if (subdir != null) {
+ listRecursive(subdir, depth);
+ } else {
+ String[] text = file.read();
+ for (int j = 0; j < text.length; ++j)
+ System.out.println(indent + "\t" + text[j]);
+ }
+ }
+ }
+
class ShutdownHook extends Thread
{
public void
@@ -78,7 +105,7 @@ public class Client extends Ice.Application
}
catch(NameInUse ex)
{
- NodeDesc desc = rootDir.resolve("Coleridge");
+ NodeDesc desc = rootDir.find("Coleridge");
coleridge = DirectoryPrxHelper.checkedCast(desc.proxy);
assert(coleridge != null);
}
@@ -106,33 +133,16 @@ public class Client extends Ice.Application
}
System.out.println("Contents of filesystem:");
- java.util.Map contents = rootDir.list(ListMode.RecursiveList);
- java.util.Iterator p = contents.keySet().iterator();
- while(p.hasNext())
- {
- System.out.println(" " + (String)p.next());
- }
-
- NodeDesc desc = rootDir.resolve("Coleridge/Kubla_Khan");
- FilePrx file = FilePrxHelper.checkedCast(desc.proxy);
- assert(file != null);
- String[] text = file.read();
- System.out.println("Contents of file Coleridge/Kubla_Khan:");
- for(int i = 0; i < text.length; ++i)
- {
- System.out.println(" " + text[i]);
- }
+ listRecursive(rootDir, 0);
//
// Destroy the filesystem.
//
- contents = rootDir.list(ListMode.NormalList);
- p = contents.entrySet().iterator();
- while(p.hasNext())
+ NodeDesc[] contents = rootDir.list();
+ for(int i = 0; i < contents.length; ++i)
{
- java.util.Map.Entry e = (java.util.Map.Entry)p.next();
- NodeDesc d = (NodeDesc)e.getValue();
- System.out.println("Destroying " + (String)e.getKey() + "...");
+ NodeDesc d = contents[i];
+ System.out.println("Destroying " + d.name);
d.proxy.destroy();
}
}
diff --git a/java/demo/book/freeze_filesystem/DirectoryI.java b/java/demo/book/freeze_filesystem/DirectoryI.java
index 9502c94092d..81724029384 100644
--- a/java/demo/book/freeze_filesystem/DirectoryI.java
+++ b/java/demo/book/freeze_filesystem/DirectoryI.java
@@ -74,111 +74,44 @@ public final class DirectoryI extends PersistentDirectory
_evictor.remove(_ID);
}
- public java.util.Map
- list(ListMode mode, Ice.Current current)
+ public synchronized NodeDesc[]
+ list(Ice.Current current)
{
- java.util.Map result = null;
- synchronized(this)
+ if(_destroyed)
{
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- result = (java.util.Map)((java.util.HashMap)nodes).clone();
+ throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
}
- if(mode == ListMode.RecursiveList)
+ NodeDesc[] result = new NodeDesc[nodes.size()];
+ int i = 0;
+ java.util.Iterator p = nodes.values().iterator();
+ while(p.hasNext())
{
- java.util.Map children = new java.util.HashMap();
- java.util.Iterator p = result.entrySet().iterator();
- while(p.hasNext())
- {
- java.util.Map.Entry e = (java.util.Map.Entry)p.next();
- NodeDesc desc = (NodeDesc)e.getValue();
- if(desc.type == NodeType.DirType)
- {
- DirectoryPrx dir = DirectoryPrxHelper.uncheckedCast(desc.proxy);
- try
- {
- java.util.Map d = dir.list(mode);
- java.util.Iterator q = d.entrySet().iterator();
- while(q.hasNext())
- {
- java.util.Map.Entry e2 = (java.util.Map.Entry)q.next();
- NodeDesc desc2 = (NodeDesc)e2.getValue();
- children.put(desc.name + "/" + desc2.name, desc2);
- }
- }
- catch(Ice.ObjectNotExistException ex)
- {
- // This node may have been destroyed, so skip it.
- }
- }
- }
- result.putAll(children);
+ result[i++] = (NodeDesc)p.next();
}
-
return result;
}
- public NodeDesc
- resolve(String path, Ice.Current current)
+ public synchronized NodeDesc
+ find(String name, Ice.Current current)
throws NoSuchName
{
- int pos = path.indexOf('/');
- String child, remainder = null;
- if(pos == -1)
- {
- child = path;
- }
- else
+ if(_destroyed)
{
- child = path.substring(0, pos);
- while(pos < path.length() && path.charAt(pos) == '/')
- {
- ++pos;
- }
- if(pos < path.length())
- {
- remainder = path.substring(pos);
- }
+ throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
}
- synchronized(this)
+ if(!nodes.containsKey(name))
{
- if(_destroyed)
- {
- throw new Ice.ObjectNotExistException(current.id, current.facet, current.operation);
- }
-
- if(!nodes.containsKey(child))
- {
- throw new NoSuchName("no node exists with name `" + child + "'");
- }
-
- NodeDesc desc = (NodeDesc)nodes.get(child);
- if(remainder == null)
- {
- return desc;
- }
- else
- {
- if(desc.type != NodeType.DirType)
- {
- throw new NoSuchName("node `" + child + "' is not a directory");
- }
- DirectoryPrx dir = DirectoryPrxHelper.checkedCast(desc.proxy);
- assert(dir != null);
- return dir.resolve(remainder);
- }
+ throw new NoSuchName(name);
}
+
+ return (NodeDesc)nodes.get(name);
}
public synchronized DirectoryPrx
createDirectory(String name, Ice.Current current)
- throws IllegalName,
- NameInUse
+ throws NameInUse
{
if(_destroyed)
{
@@ -204,8 +137,7 @@ public final class DirectoryI extends PersistentDirectory
public synchronized FilePrx
createFile(String name, Ice.Current current)
- throws IllegalName,
- NameInUse
+ throws NameInUse
{
if(_destroyed)
{
@@ -238,16 +170,11 @@ public final class DirectoryI extends PersistentDirectory
private
void checkName(String name)
- throws IllegalName, NameInUse
+ throws NameInUse
{
- if(name.length() == 0 || name.indexOf('/') >= 0)
- {
- throw new IllegalName("illegal name `" + name + "'");
- }
-
- if(nodes.containsKey(name))
+ if(name.length() == 0 || nodes.containsKey(name))
{
- throw new NameInUse("name `" + name + "' is already in use");
+ throw new NameInUse(name);
}
}
diff --git a/java/demo/book/freeze_filesystem/Filesystem.ice b/java/demo/book/freeze_filesystem/Filesystem.ice
index b8427f36525..b8b5b38d351 100644
--- a/java/demo/book/freeze_filesystem/Filesystem.ice
+++ b/java/demo/book/freeze_filesystem/Filesystem.ice
@@ -15,7 +15,6 @@ module Filesystem
};
exception PermissionDenied extends GenericError {};
exception NameInUse extends GenericError {};
- exception IllegalName extends GenericError {};
exception NoSuchName extends GenericError {};
interface Node
@@ -23,8 +22,7 @@ module Filesystem
idempotent string name();
["freeze:write"]
- void destroy()
- throws PermissionDenied;
+ void destroy() throws PermissionDenied;
};
sequence<string> Lines;
@@ -34,8 +32,7 @@ module Filesystem
idempotent Lines read();
["freeze:write"]
- idempotent void write(Lines text)
- throws GenericError;
+ idempotent void write(Lines text) throws GenericError;
};
enum NodeType { DirType, FileType };
@@ -47,23 +44,18 @@ module Filesystem
Node* proxy;
};
- dictionary<string, NodeDesc> NodeDict;
-
- enum ListMode { NormalList, RecursiveList };
+ sequence<NodeDesc> NodeDescSeq;
interface Directory extends Node
{
- idempotent NodeDict list(ListMode mode);
+ idempotent NodeDescSeq list();
- idempotent NodeDesc resolve(string path)
- throws NoSuchName;
+ idempotent NodeDesc find(string name) throws NoSuchName;
["freeze:write"]
- File* createFile(string name)
- throws NameInUse, IllegalName;
+ File* createFile(string name) throws NameInUse;
["freeze:write"]
- Directory* createDirectory(string name)
- throws NameInUse, IllegalName;
+ Directory* createDirectory(string name) throws NameInUse;
};
};
diff --git a/java/demo/book/freeze_filesystem/PersistentFilesystem.ice b/java/demo/book/freeze_filesystem/PersistentFilesystem.ice
index 774d2603eab..2895d2f5d14 100644
--- a/java/demo/book/freeze_filesystem/PersistentFilesystem.ice
+++ b/java/demo/book/freeze_filesystem/PersistentFilesystem.ice
@@ -24,6 +24,8 @@ module Filesystem
Lines text;
};
+ dictionary<string, NodeDesc> NodeDict;
+
class PersistentDirectory extends PersistentNode implements Directory
{
["freeze:write"]
diff --git a/java/demo/book/lifecycle/FilesystemI/DirectoryI.java b/java/demo/book/lifecycle/FilesystemI/DirectoryI.java
index d3ebea1d195..189ceceb759 100644
--- a/java/demo/book/lifecycle/FilesystemI/DirectoryI.java
+++ b/java/demo/book/lifecycle/FilesystemI/DirectoryI.java
@@ -119,8 +119,7 @@ public class DirectoryI extends _DirectoryDisp implements NodeI, _DirectoryOpera
{
throw new NameInUse(name);
}
- FileI f = new FileI(c.adapter, name, this);
- return FilePrxHelper.uncheckedCast(c.adapter.createProxy(f.id()));
+ return new FileI(name, this).activate(c.adapter);
}
}
@@ -145,8 +144,7 @@ public class DirectoryI extends _DirectoryDisp implements NodeI, _DirectoryOpera
{
throw new NameInUse(name);
}
- DirectoryI d = new DirectoryI(c.adapter, name, this);
- return DirectoryPrxHelper.uncheckedCast(c.adapter.createProxy(d.id()));
+ return new DirectoryI(name, this).activate(c.adapter);
}
}
@@ -185,14 +183,14 @@ public class DirectoryI extends _DirectoryDisp implements NodeI, _DirectoryOpera
// DirectoryI constructor for root directory.
- public DirectoryI(ObjectAdapter a)
+ public DirectoryI()
{
- this(a, "RootDir", null);
+ this("/", null);
}
// DirectoryI constructor. parent == null indicates root directory.
- public DirectoryI(ObjectAdapter a, String name, DirectoryI parent)
+ public DirectoryI(String name, DirectoryI parent)
{
_name = name;
_parent = parent;
@@ -202,14 +200,26 @@ public class DirectoryI extends _DirectoryDisp implements NodeI, _DirectoryOpera
if(parent == null)
{
- _id.name = name;
+ _id.name = "RootDir";
}
else
{
_id.name = Util.generateUUID();
- _parent.addChild(name, this);
}
- a.add(this, _id);
+ }
+
+
+ // Add servant to ASM and to parent's _contents map.
+
+ public DirectoryPrx
+ activate(Ice.ObjectAdapter a)
+ {
+ DirectoryPrx node = DirectoryPrxHelper.uncheckedCast(a.add(this, _id));
+ if(_parent != null)
+ {
+ _parent.addChild(_name, this);
+ }
+ return node;
}
// Add the name-node pair to the _contents map.
diff --git a/java/demo/book/lifecycle/FilesystemI/FileI.java b/java/demo/book/lifecycle/FilesystemI/FileI.java
index 8bd8d93158e..cb0fd1b5eec 100644
--- a/java/demo/book/lifecycle/FilesystemI/FileI.java
+++ b/java/demo/book/lifecycle/FilesystemI/FileI.java
@@ -72,15 +72,21 @@ public class FileI extends _FileDisp implements NodeI, _FileOperations
}
}
- public FileI(ObjectAdapter a, String name, DirectoryI parent)
+ public FileI(String name, DirectoryI parent)
{
_name = name;
_parent = parent;
_destroyed = false;
_id = new Identity();
_id.name = Util.generateUUID();
- _parent.addChild(name, this);
- a.add(this, _id);
+ }
+
+ public FilePrx
+ activate(Ice.ObjectAdapter a)
+ {
+ FilePrx node = FilePrxHelper.uncheckedCast(a.add(this, _id));
+ _parent.addChild(_name, this);
+ return node;
}
private String _name;
diff --git a/java/demo/book/lifecycle/Server.java b/java/demo/book/lifecycle/Server.java
index 77e05c806f7..c6f681db73a 100644
--- a/java/demo/book/lifecycle/Server.java
+++ b/java/demo/book/lifecycle/Server.java
@@ -26,7 +26,9 @@ class FilesystemApp extends Ice.Application
// Create the root directory.
//
- new DirectoryI(adapter);
+ DirectoryI root = new DirectoryI();
+ root.activate(adapter);
+
// All objects are created, allow client requests now.
//
diff --git a/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java b/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
index 2f963a7def6..016e7ff2275 100755
--- a/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
+++ b/java/demo/book/simple_filesystem/Filesystem/DirectoryI.java
@@ -14,25 +14,15 @@ public final class DirectoryI extends _DirectoryDisp
// DirectoryI constructor
public
- DirectoryI(String name, DirectoryI parent)
+ DirectoryI(Ice.Communicator communicator, String name, DirectoryI parent)
{
_name = name;
_parent = parent;
- // Create an identity. The parent has the fixed identity "RootDir"
+ // Create an identity. The root directory has the fixed identity "RootDir"
//
- Ice.Identity myID =
- _adapter.getCommunicator().stringToIdentity(_parent != null ? Ice.Util.generateUUID() : "RootDir");
+ _id = communicator.stringToIdentity(_parent != null ? Ice.Util.generateUUID() : "RootDir");
- // Add the identity to the object adapter
- //
- _adapter.add(this, myID);
-
- // Create a proxy for the new node and add it as a child to the parent
- //
- NodePrx thisNode = NodePrxHelper.uncheckedCast(_adapter.createProxy(myID));
- if (_parent != null)
- _parent.addChild(thisNode);
}
// Slice Node::name() operation
@@ -62,8 +52,21 @@ public final class DirectoryI extends _DirectoryDisp
_contents.add(child);
}
- public static Ice.ObjectAdapter _adapter;
+ // activate adds the servant to the object adapter and
+ // adds child nodes ot the parent's _contents list.
+
+ public void
+ activate(Ice.ObjectAdapter a)
+ {
+ NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
+ if(_parent != null)
+ {
+ _parent.addChild(thisNode);
+ }
+ }
+
private String _name;
private DirectoryI _parent;
+ private Ice.Identity _id;
private java.util.List<NodePrx> _contents = new java.util.ArrayList<NodePrx>();
}
diff --git a/java/demo/book/simple_filesystem/Filesystem/FileI.java b/java/demo/book/simple_filesystem/Filesystem/FileI.java
index 03661e0c93b..296bc1aadf4 100755
--- a/java/demo/book/simple_filesystem/Filesystem/FileI.java
+++ b/java/demo/book/simple_filesystem/Filesystem/FileI.java
@@ -14,7 +14,7 @@ public class FileI extends _FileDisp
// FileI constructor
public
- FileI(String name, DirectoryI parent)
+ FileI(Ice.Communicator communicator, String name, DirectoryI parent)
{
_name = name;
_parent = parent;
@@ -23,16 +23,7 @@ public class FileI extends _FileDisp
// Create an identity
//
- Ice.Identity myID = _adapter.getCommunicator().stringToIdentity(Ice.Util.generateUUID());
-
- // Add the identity to the object adapter
- //
- _adapter.add(this, myID);
-
- // Create a proxy for the new node and add it as a child to the parent
- //
- NodePrx thisNode = NodePrxHelper.uncheckedCast(_adapter.createProxy(myID));
- _parent.addChild(thisNode);
+ _id = communicator.stringToIdentity(Ice.Util.generateUUID());
}
// Slice Node::name() operation
@@ -60,8 +51,15 @@ public class FileI extends _FileDisp
_lines = text;
}
- public static Ice.ObjectAdapter _adapter;
+ public void
+ activate(Ice.ObjectAdapter a)
+ {
+ NodePrx thisNode = NodePrxHelper.uncheckedCast(a.add(this, _id));
+ _parent.addChild(thisNode);
+ }
+
private String _name;
private DirectoryI _parent;
+ private Ice.Identity _id;
private String[] _lines;
}
diff --git a/java/demo/book/simple_filesystem/Server.java b/java/demo/book/simple_filesystem/Server.java
index 8e4142ea757..831c27354a8 100755
--- a/java/demo/book/simple_filesystem/Server.java
+++ b/java/demo/book/simple_filesystem/Server.java
@@ -17,21 +17,19 @@ public class Server extends Ice.Application {
//
shutdownOnInterrupt();
- // Create an object adapter (stored in the _adapter
- // static members)
+ // Create an object adapter.
//
Ice.ObjectAdapter adapter = communicator().createObjectAdapterWithEndpoints(
"SimpleFilesystem", "default -p 10000");
- DirectoryI._adapter = adapter;
- FileI._adapter = adapter;
// Create the root directory (with name "/" and no parent)
//
- DirectoryI root = new DirectoryI("/", null);
+ DirectoryI root = new DirectoryI(communicator(), "/", null);
+ root.activate(adapter);
// Create a file called "README" in the root directory
//
- File file = new FileI("README", root);
+ FileI file = new FileI(communicator(), "README", root);
String[] text;
text = new String[]{ "This file system contains a collection of poetry." };
try {
@@ -39,14 +37,16 @@ public class Server extends Ice.Application {
} catch (GenericError e) {
System.err.println(e.reason);
}
+ file.activate(adapter);
// Create a directory called "Coleridge" in the root directory
//
- DirectoryI coleridge = new DirectoryI("Coleridge", root);
+ DirectoryI coleridge = new DirectoryI(communicator(), "Coleridge", root);
+ coleridge.activate(adapter);
// Create a file called "Kubla_Khan" in the Coleridge directory
//
- file = new FileI("Kubla_Khan", coleridge);
+ file = new FileI(communicator(), "Kubla_Khan", coleridge);
text = new String[]{ "In Xanadu did Kubla Khan",
"A stately pleasure-dome decree:",
"Where Alph, the sacred river, ran",
@@ -57,6 +57,7 @@ public class Server extends Ice.Application {
} catch (GenericError e) {
System.err.println(e.reason);
}
+ file.activate(adapter);
// All objects are created, allow client requests now
//
diff --git a/py/demo/book/simple_filesystem/Server.py b/py/demo/book/simple_filesystem/Server.py
index cf411d40b77..feccab79534 100755
--- a/py/demo/book/simple_filesystem/Server.py
+++ b/py/demo/book/simple_filesystem/Server.py
@@ -14,27 +14,17 @@ Ice.loadSlice('Filesystem.ice')
import Filesystem
class DirectoryI(Filesystem.Directory):
- def __init__(self, name, parent):
+ def __init__(self, communicator, name, parent):
self._name = name
self._parent = parent
self._contents = []
- # Create an identity. The parent has the fixed identity "RootDir"
+ # Create an identity. The root directory has the fixed identity "RootDir"
#
if self._parent:
- myID = self._adapter.getCommunicator().stringToIdentity(Ice.generateUUID())
+ self._id = communicator.stringToIdentity(Ice.generateUUID())
else:
- myID = self._adapter.getCommunicator().stringToIdentity("RootDir")
-
- # Add the identity to the object adapter
- #
- self._adapter.add(self, myID)
-
- # Create a proxy for the new node and add it as a child to the parent
- thisNode = Filesystem.NodePrx.uncheckedCast(self._adapter.createProxy(myID))
-
- if self._parent:
- self._parent.addChild(thisNode)
+ self._id = communicator.stringToIdentity("RootDir")
# Slice Node::name() operation
@@ -52,10 +42,15 @@ class DirectoryI(Filesystem.Directory):
def addChild(self, child):
self._contents.append(child)
- _adpater = None
+ # Add servant to ASM and Parent's _contents map.
+
+ def activate(self, a):
+ thisNode = Filesystem.DirectoryPrx.uncheckedCast(a.add(self, self._id))
+ if self._parent:
+ self._parent.addChild(thisNode)
class FileI(Filesystem.File):
- def __init__(self, name, parent):
+ def __init__(self, communicator, name, parent):
self._name = name
self._parent = parent
self.lines = []
@@ -64,23 +59,14 @@ class FileI(Filesystem.File):
# Create an identity
#
- myID = self._adapter.getCommunicator().stringToIdentity(Ice.generateUUID())
-
- # Add the identity to the object adapter
- #
- self._adapter.add(self, myID)
-
- # Create a proxy for the new node and add it as a child to the parent
- #
- thisNode = Filesystem.NodePrx.uncheckedCast(self._adapter.createProxy(myID))
- self._parent.addChild(thisNode)
+ self._id = communicator.stringToIdentity(Ice.generateUUID())
# Slice Node::name() operation
def name(self, current=None):
return self._name
- # Slice File::reas() operation
+ # Slice File::read() operation
def read(self, current=None):
return self._lines
@@ -90,7 +76,12 @@ class FileI(Filesystem.File):
def write(self, text, current=None):
self._lines = text
- _adapter = None
+ # Add servant to ASM and Parent's _contents map.
+
+ def activate(self, a):
+ thisNode = Filesystem.FilePrx.uncheckedCast(a.add(self, self._id))
+ self._parent.addChild(thisNode)
+
class Server(Ice.Application):
def run(self, args):
@@ -98,32 +89,33 @@ class Server(Ice.Application):
#
self.shutdownOnInterrupt()
- # Create an object adapter (stored in the _adapter static members)
+ # Create an object adapter
#
adapter = self.communicator().createObjectAdapterWithEndpoints("SimpleFileSystem", "default -p 10000")
- DirectoryI._adapter = adapter
- FileI._adapter = adapter
# Create the root directory (with name "/" and no parent)
#
- root = DirectoryI("/", None)
+ root = DirectoryI(self.communicator(), "/", None)
+ root.activate(adapter)
# Create a file called "README" in the root directory
#
- file = FileI("README", root)
+ file = FileI(self.communicator(), "README", root)
text = [ "This file system contains a collection of poetry." ]
try:
file.write(text)
except Filesystem.GenericError, e:
print e.reason
+ file.activate(adapter)
# Create a directory called "Coleridge" in the root directory
#
- coleridge = DirectoryI("Coleridge", root)
+ coleridge = DirectoryI(self.communicator(), "Coleridge", root)
+ coleridge.activate(adapter)
# Create a file called "Kubla_Khan" in the Coleridge directory
#
- file = FileI("Kubla_Khan", coleridge)
+ file = FileI(self.communicator(), "Kubla_Khan", coleridge)
text = [ "In Xanadu did Kubla Khan",
"A stately pleasure-dome decree:",
"Where Alph, the sacred river, ran",
@@ -133,6 +125,7 @@ class Server(Ice.Application):
file.write(text)
except Filesystem.GenericError, e:
print e.reason
+ file.activate(adapter)
# All objects are created, allow client requests now
#
diff --git a/vb/demo/book/simple_filesystem/DirectoryI.vb b/vb/demo/book/simple_filesystem/DirectoryI.vb
index 3553791ed35..722efc77138 100755
--- a/vb/demo/book/simple_filesystem/DirectoryI.vb
+++ b/vb/demo/book/simple_filesystem/DirectoryI.vb
@@ -10,7 +10,7 @@ Public Class DirectoryI
_parent = parent
' Create an identity. The
- ' parent has the fixed identity "/"
+ ' root directory as the fixed identity "RootDir"
'
Dim myId As Ice.Identity
If Not _parent Is Nothing Then