Fresco/Berlin/server Makefile.in,1.28,1.29 ServerContextImpl.cc,1.7,1.8 ServerContextImpl.hh,1.4,1.5 ServerImpl.cc,1.10,1.11 ServerImpl.hh,1.8,1.9 server.cc,1.68,1.69

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Berlin/server
In directory purcel:/tmp/cvs-serv31700/Berlin/server

Modified Files:
	Makefile.in ServerContextImpl.cc ServerContextImpl.hh 
	ServerImpl.cc ServerImpl.hh server.cc 
Log Message:
a somewhat lengthy fix for http://issues.fresco.org/bug92

Index: Makefile.in
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/Makefile.in,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- Makefile.in	10 Dec 2002 05:46:11 -0000	1.28
+++ Makefile.in	18 Feb 2003 07:26:39 -0000	1.29
@@ -37,7 +37,7 @@
 CPPFLAGS	+= -DVERSION='"@PACKAGE_VERSION@"'
 LIBS		+= -L../lib -L../../lib -lBerlin -lFresco -lBabylon -lPrague
 
-SRC		:= ServerImpl.cc ServerContextImpl.cc server.cc kits.cc devices.cc
+SRC		:= server.cc kits.cc devices.cc
 DEP		:= $(patsubst %.cc, %.d, $(SRC))
 
 TARGETS		:= ../bin/berlin ../bin/berlin-kits ../bin/berlin-devices
@@ -76,11 +76,11 @@
 
 endif
 
-../bin/berlin:	ServerImpl.o ServerContextImpl.o server.o
+../bin/berlin:	server.o
 	@echo linking $(@F)
 	$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
 
-../bin/berlin-kits:	ServerImpl.o ServerContextImpl.o kits.o
+../bin/berlin-kits:	kits.o
 	@echo linking $(@F)
 	$(CXX) $(LDFLAGS) -o $@ $^ $(LIBS)
 
@@ -119,15 +119,11 @@
 
 maintainer-clean: distclean
 
-%.o:	$(srcdir)/%.cc
+%.o:	%.cc
 	@echo compiling $(@F)
 	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
 
 %.d:    %.cc
-	@echo generating dependencies for $(<F)
-	$(SHELL) -ec '$(CXX) $(DEPFLAGS) $(CPPFLAGS) $< | sed "s/$*\\.o[ :]*/$*\\.d $*\\.o : /g" > $@'
-
-Server%.d:    %.cc %.hh
 	@echo generating dependencies for $(<F)
 	$(SHELL) -ec '$(CXX) $(DEPFLAGS) $(CPPFLAGS) $< | sed "s/$*\\.o[ :]*/$*\\.d $*\\.o : /g" > $@'
 

Index: ServerContextImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/ServerContextImpl.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ServerContextImpl.cc	8 Feb 2003 02:12:39 -0000	1.7
+++ ServerContextImpl.cc	18 Feb 2003 07:26:39 -0000	1.8
@@ -43,10 +43,10 @@
 // occasionally pings the client to make sure it's still there.
 
 ServerContextImpl::ServerContextImpl(ServerImpl *s, const CORBA::PolicyList &policies, ClientContext_ptr c)
-    : _server(s), _policies(policies), _client(ClientContext::_duplicate(c))
+    : my_server(s), my_policies(policies), my_client(ClientContext::_duplicate(c))
 {
   Trace trace("ServerContextImpl::ServerContextImpl");
-  Babylon::String title = Unicode::to_internal(*_client->application_title());
+  Babylon::String title = Unicode::to_internal(*my_client->application_title());
   Logger::log(Logger::corba) << (void *)(this) << " is the ServerContext "
 			     << "for application \"" << title.utf8()
 			     << "\"." << std::endl;
@@ -55,32 +55,35 @@
 ServerContextImpl::~ServerContextImpl()
 {
   Trace trace("ServerContextImpl::~ServerContextImpl");
-  for (klist_t::iterator i = _kits.begin(); i != _kits.end(); ++i)
+  for (klist_t::iterator i = my_kits.begin(); i != my_kits.end(); ++i)
     (*i).second->decrement();
   Logger::log(Logger::corba) << "ServerContext " << (void *)(this)
 			     << " destructed." << std::endl;
 }
 
-ClientContext_ptr ServerContextImpl::client() { return ClientContext::_duplicate(_client);}
+ClientContext_ptr ServerContextImpl::client()
+{
+  return ClientContext::_duplicate(my_client);
+}
 
 // will fill the rest of these in as needs arise. They should do something reasonably obvious.
 
 void ServerContextImpl::set_singleton(const char *name, CORBA::Object_ptr singleton)
   throw (SecurityException, SingletonFailureException)
 {
-  _server->set_singleton(name, singleton);
+  my_server->set_singleton(name, singleton);
 }
 
 void ServerContextImpl::remove_singleton(const char *name)
   throw (SecurityException, SingletonFailureException)
 {
-  _server->remove_singleton(name);
+  my_server->remove_singleton(name);
 }
 
 CORBA::Object_ptr ServerContextImpl::get_singleton(const char *name) 
   throw (SecurityException, SingletonFailureException)
 {
-  return _server->get_singleton(name);
+  return my_server->get_singleton(name);
 }
 
 // this method should eventually do some kind of checking on the
@@ -94,28 +97,31 @@
   /*
    * look for loaded kits first
    */
-  klist_t::iterator k1 = _kits.lower_bound(type), k2 = _kits.upper_bound(type);
+  klist_t::iterator k1 = my_kits.lower_bound(type), k2 = my_kits.upper_bound(type);
   for (klist_t::iterator i = k1; i != k2; ++i)
     if ((*i).second->supports(properties))
-      {
-	(*i).second->increment();
-	return (*i).second->_this();
-      }
+    {
+      (*i).second->increment();
+      return (*i).second->_this();
+    }
   /*
    * now try the factories
    */
   PortableServer::POA_var root = _default_POA();
   std::ostringstream oss;
-  oss << '#' << _counter++ << std::ends;
+  oss << '#' << my_counter++;
+  std::cout << " (id is " << oss.str() << ')' << std::endl;
   PortableServer::POAManager_var manager = root->the_POAManager();
   PortableServer::POA_var poa =
-    root->create_POA(oss.str().c_str(), manager, _policies);
+    root->create_POA(oss.str().c_str(), manager, my_policies);
   Logger::log(Logger::lifecycle) << "created new POA for kit of type "
 	  << type << " (id is " << oss.str() << ')' << std::endl;
-  KitImpl *kit = _server->create(type, properties, poa);
+  std::cout << "created new POA for kit of type "
+	  << type << " (id is " << oss.str() << ')' << std::endl;
+  KitImpl *kit = my_server->create(type, properties, poa, this);
   if (!kit) throw CreationFailureException();
   kit->bind(ServerContext_var(_this()));
-  _kits.insert(klist_t::value_type(type, kit));
+  my_kits.insert(klist_t::value_type(type, kit));
   return kit->_this();
 }
 
@@ -125,11 +131,15 @@
 bool ServerContextImpl::ping()
 {
   Trace trace("ServerContextImpl::ping");
-  Prague::Guard<Mutex> guard(_mutex);
+  Prague::Guard<Mutex> guard(my_mutex);
   bool alive = true;
-  if (CORBA::is_nil(_client)) alive = false;
+  if (CORBA::is_nil(my_client)) alive = false;
   else
-    try { _client->ping();}
+    try { my_client->ping();}
     catch (...) { alive = false;}
   return alive;
+}
+
+void ServerContextImpl::erase(KitImpl *kit)
+{
 }

Index: ServerContextImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/ServerContextImpl.hh,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ServerContextImpl.hh	2 Jun 2002 23:42:19 -0000	1.4
+++ ServerContextImpl.hh	18 Feb 2003 07:26:39 -0000	1.5
@@ -39,7 +39,8 @@
 			  public DefaultPOA
 {
   typedef std::multimap<std::string, KitImpl *> klist_t;
- public:
+  friend class KitImpl;
+public:
   ServerContextImpl(ServerImpl *, const CORBA::PolicyList &, Fresco::ClientContext_ptr);
   ~ServerContextImpl();
   PortableServer::POA_ptr _default_POA() { return DefaultPOA::_default_POA();}
@@ -54,13 +55,14 @@
   CORBA::Object_ptr get_singleton(const char *) 
     throw (Fresco::SecurityException, Fresco::SingletonFailureException);
   bool ping();
- private:
-  static unsigned long      _counter;
-  ServerImpl               *_server;
-  CORBA::PolicyList         _policies;
-  Fresco::ClientContext_var _client;
-  klist_t                   _kits;
-  Prague::Mutex             _mutex;
+private:
+  void erase(KitImpl *);
+  static unsigned long      my_counter;
+  ServerImpl               *my_server;
+  CORBA::PolicyList         my_policies;
+  Fresco::ClientContext_var my_client;
+  klist_t                   my_kits;
+  Prague::Mutex             my_mutex;
 };
 
 #endif

Index: ServerImpl.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/ServerImpl.cc,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ServerImpl.cc	23 Jan 2003 00:43:01 -0000	1.10
+++ ServerImpl.cc	18 Feb 2003 07:26:39 -0000	1.11
@@ -25,30 +25,30 @@
 #include <Prague/Sys/Directory.hh>
 #include "Berlin/Logger.hh"
 #include "Berlin/ImplVar.hh"
-#include "ServerImpl.hh"
-#include "ServerContextImpl.hh"
+#include "Berlin/ServerImpl.hh"
+#include "Berlin/ServerContextImpl.hh"
 
 using namespace Prague;
 using namespace Fresco;
 
-ServerImpl *ServerImpl::_server = 0;;
+ServerImpl *ServerImpl::my_server = 0;;
 
 ServerImpl *ServerImpl::create(PortableServer::POA_ptr poa, const CORBA::PolicyList &policies)
 {
-  assert(_server == 0);
-  _server = new ServerImpl(policies);
-  _server->_poa = PortableServer::POA::_duplicate(poa);
-  return _server;
+  assert(my_server == 0);
+  my_server = new ServerImpl(policies);
+  my_server->_poa = PortableServer::POA::_duplicate(poa);
+  return my_server;
 }
 
 ServerImpl *ServerImpl::instance()
 {
-  return _server;
+  return my_server;
 }
 
 ServerImpl::ServerImpl(const CORBA::PolicyList &policies)
-  : _policies(policies),
-    _thread(&ServerImpl::run, this)
+  : my_policies(policies),
+    my_thread(&ServerImpl::run, this)
 {
 }
 
@@ -57,9 +57,9 @@
     throw (SecurityException)
 {
   Trace trace("ServerImpl::create_server_context");
-  Prague::Guard<Mutex> guard (_mutex);
-  Impl_var<ServerContextImpl> sc(new ServerContextImpl(this, _policies, c));
-  _contexts.push_back(sc);
+  Prague::Guard<Mutex> guard(my_mutex);
+  Impl_var<ServerContextImpl> sc(new ServerContextImpl(this, my_policies, c));
+  my_contexts.push_back(sc);
   return sc._retn()->_this();
 }
 
@@ -67,63 +67,63 @@
 			       CORBA::Object_ptr singleton) 
   throw (SecurityException, SingletonFailureException)
 {
-  Prague::Guard<Mutex> guard (_mutex);
+  Prague::Guard<Mutex> guard(my_mutex);
   // test wether the name is allready in use:
-  smap_t::iterator p = _singletons.find(name);
-  if (p != _singletons.end()) throw SingletonFailureException();
-  else _singletons[name] = singleton;
+  smap_t::iterator p = my_singletons.find(name);
+  if (p != my_singletons.end()) throw SingletonFailureException();
+  else my_singletons[name] = singleton;
 }
 
 void ServerImpl::remove_singleton(const char *name) 
   throw (SecurityException, SingletonFailureException)
 {
-  Prague::Guard<Mutex> guard (_mutex);
-  smap_t::iterator p = _singletons.find(name);
-  if (p != _singletons.end()) _singletons.erase(p);
+  Prague::Guard<Mutex> guard(my_mutex);
+  smap_t::iterator p = my_singletons.find(name);
+  if (p != my_singletons.end()) my_singletons.erase(p);
   throw SingletonFailureException();
 }
 
 CORBA::Object_ptr ServerImpl::get_singleton(const char *name) 
   throw (SecurityException, SingletonFailureException)
 {
-  Prague::Guard<Mutex> guard (_mutex);
-  smap_t::iterator p = _singletons.find(name);
-  if (p != _singletons.end()) return CORBA::Object::_duplicate(p->second);
+  Prague::Guard<Mutex> guard(my_mutex);
+  smap_t::iterator p = my_singletons.find(name);
+  if (p != my_singletons.end()) return CORBA::Object::_duplicate(p->second);
   throw SingletonFailureException();
 }
 
 void ServerImpl::start()
 {
-  _thread.start();
+  my_thread.start();
 }
 
 void ServerImpl::stop()
 {
   Trace trace("ServerImpl::stop");
-  Prague::Guard<Mutex> guard (_mutex);
-  for (clist_t::iterator i = _contexts.begin(); i != _contexts.end(); i++)
+  Prague::Guard<Mutex> guard (my_mutex);
+  for (clist_t::iterator i = my_contexts.begin(); i != my_contexts.end(); i++)
     ServerImpl::destroy_context(*i);
-  _contexts.clear();
+  my_contexts.clear();
 }
 
 void ServerImpl::ping()
 {
   Trace trace("ServerImpl::ping");
-  Prague::Guard<Mutex> guard (_mutex);
+  Prague::Guard<Mutex> guard(my_mutex);
   clist_t updated_contexts;
-  for (clist_t::iterator i = _contexts.begin(); i != _contexts.end(); i++)
+  for (clist_t::iterator i = my_contexts.begin(); i != my_contexts.end(); i++)
   {
     if ((*i)->ping())
-	updated_contexts.push_back(*i);
+      updated_contexts.push_back(*i);
     else
-	destroy_context(*i);
+      destroy_context(*i);
   }
-  _contexts = updated_contexts;
+  my_contexts = updated_contexts;
 };
 
 void ServerImpl::scan(const std::string &name)
 {
-  Prague::Guard<Mutex> guard(_mutex);
+  Prague::Guard<Mutex> guard(my_mutex);
   /*
    * load all files in <name> according to the regexp '\\.so$'
    */
@@ -139,7 +139,7 @@
 	  Logger::log(Logger::loader) << (*i)->name() << " not loadable " << e.what() << std::endl;
 	  continue;
 	}
-      _plugins.push_back(plugin);
+      my_plugins.push_back(plugin);
       Logger::log(Logger::loader) << "ServerImpl: loaded plugin for " << (*plugin)->repo_id() << " from " << (*i)->name() << std::endl;
     }
 }
@@ -147,35 +147,36 @@
 //. hope you know what you are doing if you call this...
 void ServerImpl::clear()
 {
-  Prague::Guard<Mutex> guard(_mutex);
-  for (pmap_t::iterator i = _plugins.begin(); i != _plugins.end(); ++i) delete *i;
-  _plugins.clear();
+  Prague::Guard<Mutex> guard(my_mutex);
+  for (pmap_t::iterator i = my_plugins.begin(); i != my_plugins.end(); ++i) delete *i;
+  my_plugins.clear();
 }
 
 ServerImpl::PluginList ServerImpl::list()
 {
   PluginList pl;
-  for (pmap_t::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
+  for (pmap_t::iterator i = my_plugins.begin(); i != my_plugins.end(); ++i)
     pl.insert(PluginList::value_type((**i)->repo_id(), (**i)->properties()));
   return pl;
 }
 
 KitImpl *ServerImpl::create(const char *type,
 			    const Kit::PropertySeq &properties,
-			    PortableServer::POA_ptr poa)
+			    PortableServer::POA_ptr poa,
+			    ServerContextImpl *context)
 {
   Trace trace("ServerImpl::create");
-  for (pmap_t::iterator i = _plugins.begin(); i != _plugins.end(); ++i)
+  for (pmap_t::iterator i = my_plugins.begin(); i != my_plugins.end(); ++i)
     if ((**i)->_is_a(type) && (**i)->supports(properties))
-      {
-	KitImpl *kit = (**i)->clone(properties);
-	kit->_poa = PortableServer::POA::_duplicate(poa);
-	PortableServer::POA_var root = kit->_default_POA();
-	PortableServer::ObjectId *oid = root->activate_object(kit);
-	kit->_remove_ref();
-	delete oid;
-	return kit;
-      }
+    {
+      KitImpl *kit = (**i)->clone(properties, context);
+      kit->my_poa = PortableServer::POA::_duplicate(poa);
+      PortableServer::POA_var root = kit->_default_POA();
+      PortableServer::ObjectId *oid = root->activate_object(kit);
+      kit->_remove_ref();
+      delete oid;
+      return kit;
+    }
   return 0;
 }
 
@@ -183,10 +184,10 @@
 {
   ServerImpl *server = reinterpret_cast<ServerImpl *>(X);
   while (true)
-    {
-      Thread::delay(1000);
-      server->ping();
-    }
+  {
+    Thread::delay(1000);
+    server->ping();
+  }
   return 0;
 }
 
@@ -202,38 +203,38 @@
    */
   catch (const CORBA::OBJECT_NOT_EXIST &)
   {
-      std::cerr << "Caught CORBA::OBJECT_NOT_EXIST while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught CORBA::OBJECT_NOT_EXIST while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   catch (const CORBA::COMM_FAILURE &)
   {
-      std::cerr << "Caught CORBA::COMM_FAILURE while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught CORBA::COMM_FAILURE while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   catch (const CORBA::TRANSIENT &)
   {
-      std::cerr << "Caught CORBA::TRANSIENT while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught CORBA::TRANSIENT while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   catch (const PortableServer::POA::ObjectNotActive &)
   {
-      std::cerr << "Caught POA::ObjectNotActive while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught POA::ObjectNotActive while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   catch (const PortableServer::POA::WrongPolicy &)
   {
-      std::cerr << "Caught POA::WrongPolicy while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught POA::WrongPolicy while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   catch(const std::exception & e)
   {
-      std::cerr << "Caught a std::exeception while cleaning up "
-		<< "a ServerContext (" << e.what() << ")" << std::endl;
+    std::cerr << "Caught a std::exeception while cleaning up "
+	      << "a ServerContext (" << e.what() << ")" << std::endl;
   }
   catch(...)
   {
-      std::cerr << "Caught unknown exception while cleaning up "
-		<< "a ServerContext" << std::endl;
+    std::cerr << "Caught unknown exception while cleaning up "
+	      << "a ServerContext" << std::endl;
   }
   delete oid;
 }

Index: ServerImpl.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/ServerImpl.hh,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- ServerImpl.hh	23 Jan 2003 00:43:01 -0000	1.8
+++ ServerImpl.hh	18 Feb 2003 07:26:39 -0000	1.9
@@ -50,7 +50,7 @@
   typedef std::map<std::string, CORBA::Object_var> smap_t;
 
 public:
-  PortableServer::POA_ptr _default_POA() { return PortableServer::POA::_duplicate(_poa);}
+  PortableServer::POA_ptr _default_POA() { return PortableServer::POA::_duplicate(my_poa);}
 
   typedef std::multimap<std::string, Fresco::Kit::PropertySeq_var> PluginList;
 
@@ -108,7 +108,8 @@
   //. Use resolve,
   KitImpl *create(const char *,
 		  const Fresco::Kit::PropertySeq &,
-		  PortableServer::POA_ptr);
+		  PortableServer::POA_ptr,
+		  ServerContextImpl *);
 
 private:
   ServerImpl(const CORBA::PolicyList &);
@@ -119,21 +120,23 @@
   //. Destroys a given Servercontext (and with that the client's resources
   //. in this server).
   static void destroy_context(ServerContextImpl *);
-  PortableServer::POA_var _poa;
-  CORBA::PolicyList       _policies;
-  Prague::Thread          _thread;
-  Prague::Mutex           _mutex;
-  smap_t                  _singletons;
-  clist_t                 _contexts;
-  pmap_t                  _plugins;
-  kmap_t                  _kits;
-  static ServerImpl      *_server;
+  PortableServer::POA_var my_poa;
+  CORBA::PolicyList       my_policies;
+  Prague::Thread          my_thread;
+  Prague::Mutex           my_mutex;
+  smap_t                  my_singletons;
+  clist_t                 my_contexts;
+  pmap_t                  my_plugins;
+  kmap_t                  my_kits;
+  static ServerImpl      *my_server;
 };
 
 template <class K>
-typename K::_ptr_type ServerImpl::resolve(const char *type, const Fresco::Kit::PropertySeq &properties, PortableServer::POA_ptr poa)
+typename K::_ptr_type ServerImpl::resolve(const char *type,
+					  const Fresco::Kit::PropertySeq &properties,
+					  PortableServer::POA_ptr poa)
 {
-    KitImpl *kit = create(type, properties, poa);
+    KitImpl *kit = create(type, properties, poa, 0);
     if (!kit) return K::_nil();
     typename K::_var_type reference;
     try

Index: server.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/server/server.cc,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- server.cc	9 Feb 2003 19:23:52 -0000	1.68
+++ server.cc	18 Feb 2003 07:26:39 -0000	1.69
@@ -40,12 +40,11 @@
 #include <Berlin/Logger.hh>
 #include <Berlin/DesktopImpl.hh>
 #include <Berlin/RCManager.hh>
+#include <Berlin/ServerImpl.hh>
 
 // to allow to override the default Babylon path:
 #include <Babylon/Dictionary.hh>
 
-#include "ServerImpl.hh"
-
 #include <fstream>
 #include <sstream>
 
@@ -376,240 +375,239 @@
   CORBA::ORB_var orb;
   try
   {
-      orb = CORBA::ORB_init(argc, argv);
-      PortableServer::POA_var poa = 
-              resolve_init<PortableServer::POA>(orb, "RootPOA");
-      PortableServer::POAManager_var pman = poa->the_POAManager();
-      pman->activate();
-      Logger::log(Logger::corba) << "Root POA is activated." << std::endl;
-       
-      CORBA::PolicyList policies;
+    orb = CORBA::ORB_init(argc, argv);
+    PortableServer::POA_var poa = 
+      resolve_init<PortableServer::POA>(orb, "RootPOA");
+    PortableServer::POAManager_var pman = poa->the_POAManager();
+    pman->activate();
+    Logger::log(Logger::corba) << "Root POA is activated." << std::endl;
+    
+    CORBA::PolicyList policies;
 #ifdef COLOCATION_OPTIMIZATION
 #  if defined(ORB_omniORB)
-      {
-        // create a POA for global objects derived from ServantBase
-        policies.length(2);
-        policies[0] = poa->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION);
-        CORBA::Any value;
-        value <<= omniPolicy::LOCAL_CALLS_SHORTCUT; 
-        policies[1] = orb->create_policy(omniPolicy::LOCAL_SHORTCUT_POLICY_TYPE,
-                                         value);
-        poa = poa->create_POA("shortcut", pman, policies);
-
-        // create a policy list to be used by kit specific POAs
-        policies.length(1);
-        policies[0] = orb->create_policy(omniPolicy::LOCAL_SHORTCUT_POLICY_TYPE,
-                                         value);
-       }
+    {
+      // create a POA for global objects derived from ServantBase
+      policies.length(2);
+      policies[0] = poa->create_implicit_activation_policy(PortableServer::IMPLICIT_ACTIVATION);
+      CORBA::Any value;
+      value <<= omniPolicy::LOCAL_CALLS_SHORTCUT; 
+      policies[1] = orb->create_policy(omniPolicy::LOCAL_SHORTCUT_POLICY_TYPE,
+				       value);
+      poa = poa->create_POA("shortcut", pman, policies);
+      
+      // create a policy list to be used by kit specific POAs
+      policies.length(1);
+      policies[0] = orb->create_policy(omniPolicy::LOCAL_SHORTCUT_POLICY_TYPE,
+				       value);
+    }
 #  elif defined(ORB_TAO)
-       // fillin TAO-specific initialisation here...
+    // fillin TAO-specific initialisation here...
 #  endif
-      Logger::log(Logger::corba) << "Colocation optimization activated."
-                                 << std::endl;
+    Logger::log(Logger::corba) << "Colocation optimization activated."
+			       << std::endl;
 #endif
       
-       DefaultPOA::default_POA(poa);
-
-       Logger::log(Logger::corba) << "Default POA set up." << std::endl;
-
-       // ---------------------------------------------------------------
-       // Setup Babylon
-       // ---------------------------------------------------------------
-       
-       {
-           Prague::Path path = RCManager::get_path("babylonpath");
-           Babylon::override_path(path);
-       }
-
-       Logger::log(Logger::loader) << "Babylon path set." << std::endl;
-
-       // ---------------------------------------------------------------
-       // Open the Console
-       // ---------------------------------------------------------------
-      
-       std::string pixels;
-       Fresco::PixelCoord x_pixels(640), y_pixels(480);
-       if (getopt.is_set("pixels")) 
-       {
-	 getopt.get("pixels",&pixels);
-	 unsigned x_position = pixels.find("x");
-	 bool invalid_format = false;
-	 if (x_position == std::string::npos) invalid_format = true;
-	 else
-	 {
-           std::stringstream s(pixels.substr(0,x_position));
-	   s >> x_pixels;
-	   std::stringstream t(pixels.substr(x_position+1,pixels.size()));
-	   t >> y_pixels;
-	 }
-	 if ((x_pixels <= 0) || (y_pixels <= 0)) invalid_format = true;
-	 if (invalid_format)
-	 {
-	   std::cerr << "ERROR: Format of 'pixels' option should be:\n"
-		     << " --pixels=800x600, with 800 and 600 replaced\n"
-		     << "by the desired x and y values"
-		     << std::endl;
-	   exit(1);
-	 }
-       }
-       
-       value = "";
-       getopt.get("console", &value);
-       try { Console::open(value, argc, argv, poa, x_pixels, y_pixels); }
-       catch (const std::runtime_error &e)
-       {
-	 std::cerr << "ERROR: Failed to open the Console \"" << value
-		   << "\":\n\t" << e.what() << std::endl;
-	 exit(2);
-       }
-       
-       Logger::log(Logger::console) << "Console is initialized." << std::endl;
-       
-       // ---------------------------------------------------------------
-       // Construct Server and load it with kits
-       // ---------------------------------------------------------------
-       
-       // NOTE: currently pass default poa; ideally function would know
-       PortableServer::POA_var server_poa = get_server_poa(orb,poa);
-       ServerImpl * server = ServerImpl::create(server_poa, policies);
-       Logger::log(Logger::loader) << "Server created in server-POA" 
-                                   << std::endl;
+    DefaultPOA::default_POA(poa);
 
-       Prague::Path path = RCManager::get_path("modulepath");
-       for (Prague::Path::iterator i = path.begin(); i != path.end(); ++i)
-           server->scan(*i);
-       Logger::log(Logger::loader) << "Kits are loaded." << std::endl;
-       
-       // ---------------------------------------------------------------
-       // Setup default DrawingKit
-       // ---------------------------------------------------------------
-       
-       Kit::PropertySeq props;
-       props.length(1);
-       props[0].name = CORBA::string_dup("implementation");
-       value = "";
-       getopt.get("drawing", &value);
-       if (!value.empty()) props[0].value = CORBA::string_dup(value.c_str());
-       else props[0].value = CORBA::string_dup("LibArtDrawingKit");
-       DrawingKit_var drawing =
-         server->resolve<DrawingKit>("IDL:fresco.org/Fresco/DrawingKit:1.0",
-                                     props, poa);
-       Logger::log(Logger::drawing) << "DrawingKit is resolved." << std::endl;
-       if (CORBA::is_nil(drawing))
-       {
-         std::cerr << "ERROR: Unable to open "
-                   << "IDL:fresco.org/Fresco/DrawingKit:1.0"
-                   << " with attribute "
-                   << props[0].name << '=' << props[0].value << std::endl;
-         exit(3);
-       }
-       Logger::log(Logger::drawing) << "Drawing system is set up." << std::endl;
-      
-       // ---------------------------------------------------------------
-       // make a Screen graphic to hold this server's scene graph
-       // ---------------------------------------------------------------
-       
-       ScreenImpl *screen = new ScreenImpl();
-       EventManager *emanager = 
-               new EventManager(Controller_var(screen->_this()), 
-                                screen->allocation());
-       ScreenManager *smanager = 
-               new ScreenManager(Graphic_var(screen->_this()), 
-                                 emanager, drawing);
-       screen->bind_managers(emanager, smanager);
-       Logger::log(Logger::loader) << "Screen is set up and managers are "
-                                   << "bound to it." << std::endl;
+    Logger::log(Logger::corba) << "Default POA set up." << std::endl;
 
-       props.length(0);
-       LayoutKit_var layout = 
-               server->resolve<LayoutKit>("IDL:fresco.org/Fresco/LayoutKit:1.0",
-                                          props, poa);
-       Layout::Stage_var stage = layout->create_stage();
-       DesktopImpl *desktop = new DesktopImpl(orb, stage, sem);
-       screen->body(Desktop_var(desktop->_this()));
-       screen->append_controller(Desktop_var(desktop->_this()));
-       Logger::log(Logger::layout) << "Desktop is created." << std::endl;
+    // ---------------------------------------------------------------
+    // Setup Babylon
+    // ---------------------------------------------------------------
        
-       server->set_singleton("IDL:fresco.org/Fresco/Desktop:1.0", 
-                             Desktop_var(desktop->_this()));
-       server->set_singleton("IDL:fresco.org/Fresco/DrawingKit:1.0", drawing);
-       Logger::log(Logger::loader) << "singletons set" << std::endl;
-
-       // ---------------------------------------------------------------
-       // Start the server thread - start the client listener and publish it
-       // ---------------------------------------------------------------
-
-       server->start();
-       Logger::log(Logger::loader) << "Server started." << std::endl;
+    {
+      Prague::Path path = RCManager::get_path("babylonpath");
+      Babylon::override_path(path);
+    }
 
-       Server_var server_ref = server->_this();
-       publish_server(server_ref, getopt, orb); 
+    Logger::log(Logger::loader) << "Babylon path set." << std::endl;
 
-       Logger::log(Logger::corba) << "Server location published."
-                                  << std::endl;
+    // ---------------------------------------------------------------
+    // Open the Console
+    // ---------------------------------------------------------------
+    
+    std::string pixels;
+    Fresco::PixelCoord x_pixels(640), y_pixels(480);
+    if (getopt.is_set("pixels")) 
+    {
+      getopt.get("pixels",&pixels);
+      unsigned x_position = pixels.find("x");
+      bool invalid_format = false;
+      if (x_position == std::string::npos) invalid_format = true;
+      else
+      {
+	std::stringstream s(pixels.substr(0,x_position));
+	s >> x_pixels;
+	std::stringstream t(pixels.substr(x_position+1,pixels.size()));
+	t >> y_pixels;
+      }
+      if ((x_pixels <= 0) || (y_pixels <= 0)) invalid_format = true;
+      if (invalid_format)
+      {
+	std::cerr << "ERROR: Format of 'pixels' option should be:\n"
+		  << " --pixels=800x600, with 800 and 600 replaced\n"
+		  << "by the desired x and y values"
+		  << std::endl;
+	exit(1);
+      }
+    }
        
-       // ---------------------------------------------------------------
-       // Start any clients specified using --execute
-       // ---------------------------------------------------------------
-       value = "";
-       getopt.get("execute", &value);
-       if (!value.empty())
-       {
-         exec_child(child, value);
-         Logger::log(Logger::loader) << "Child process started." << std::endl;
-       }
-
-       // ---------------------------------------------------------------
-       // Start ScreenManager thread
-       // ---------------------------------------------------------------
-
-       smanager->start();
-       Logger::log(Logger::loader) << "ScreenManager is running." << std::endl;
-
-       // ---------------------------------------------------------------
-       // Wait until we receive a request to shut down, then do so
-       // NOTE: server/smanager threads assumed to be shut-down implicitly
-       // ---------------------------------------------------------------
-
-       Logger::log(Logger::loader) << "Blocking waiting for shutdown request." 
-                                   << std::endl;
-       sem.wait();
-       Logger::log(Logger::loader) << "Starting server shutdown." << std::endl;
- 
-       unpublish_server(orb);
-       Logger::log(Logger::loader) << "Un-published Server." << std::endl;
-
-       server->stop();
-       Logger::log(Logger::loader) << "Server stopped." << std::endl;
+    value = "";
+    getopt.get("console", &value);
+    try { Console::open(value, argc, argv, poa, x_pixels, y_pixels); }
+    catch (const std::runtime_error &e)
+    {
+      std::cerr << "ERROR: Failed to open the Console \"" << value
+		<< "\":\n\t" << e.what() << std::endl;
+      exit(2);
+    }
+    
+    Logger::log(Logger::console) << "Console is initialized." << std::endl;
+    
+    // ---------------------------------------------------------------
+    // Construct Server and load it with kits
+    // ---------------------------------------------------------------
+    
+    // NOTE: currently pass default poa; ideally function would know
+    PortableServer::POA_var server_poa = get_server_poa(orb,poa);
+    ServerImpl * server = ServerImpl::create(server_poa, policies);
+    Logger::log(Logger::loader) << "Server created in server-POA" 
+				<< std::endl;
+    
+    Prague::Path path = RCManager::get_path("modulepath");
+    for (Prague::Path::iterator i = path.begin(); i != path.end(); ++i)
+      server->scan(*i);
+    Logger::log(Logger::loader) << "Kits are loaded." << std::endl;
+    
+    // ---------------------------------------------------------------
+    // Setup default DrawingKit
+    // ---------------------------------------------------------------
+    
+    Kit::PropertySeq props;
+    props.length(1);
+    props[0].name = CORBA::string_dup("implementation");
+    value = "";
+    getopt.get("drawing", &value);
+    if (!value.empty()) props[0].value = CORBA::string_dup(value.c_str());
+    else props[0].value = CORBA::string_dup("LibArtDrawingKit");
+    DrawingKit_var drawing =
+      server->resolve<DrawingKit>("IDL:fresco.org/Fresco/DrawingKit:1.0",
+				  props, poa);
+    Logger::log(Logger::drawing) << "DrawingKit is resolved." << std::endl;
+    if (CORBA::is_nil(drawing))
+    {
+      std::cerr << "ERROR: Unable to open "
+		<< "IDL:fresco.org/Fresco/DrawingKit:1.0"
+		<< " with attribute "
+		<< props[0].name << '=' << props[0].value << std::endl;
+      exit(3);
+    }
+    Logger::log(Logger::drawing) << "Drawing system is set up." << std::endl;
+    
+    // ---------------------------------------------------------------
+    // make a Screen graphic to hold this server's scene graph
+    // ---------------------------------------------------------------
+    
+    ScreenImpl *screen = new ScreenImpl();
+    EventManager *emanager = 
+      new EventManager(Controller_var(screen->_this()), 
+		       screen->allocation());
+    ScreenManager *smanager = 
+      new ScreenManager(Graphic_var(screen->_this()), 
+			emanager, drawing);
+    screen->bind_managers(emanager, smanager);
+    Logger::log(Logger::loader) << "Screen is set up and managers are "
+				<< "bound to it." << std::endl;
+    
+    props.length(0);
+    LayoutKit_var layout = 
+      server->resolve<LayoutKit>("IDL:fresco.org/Fresco/LayoutKit:1.0",
+				 props, poa);
+    Layout::Stage_var stage = layout->create_stage();
+    DesktopImpl *desktop = new DesktopImpl(orb, stage, sem);
+    screen->body(Desktop_var(desktop->_this()));
+    screen->append_controller(Desktop_var(desktop->_this()));
+    Logger::log(Logger::layout) << "Desktop is created." << std::endl;
+    
+    server->set_singleton("IDL:fresco.org/Fresco/Desktop:1.0", 
+			  Desktop_var(desktop->_this()));
+    server->set_singleton("IDL:fresco.org/Fresco/DrawingKit:1.0", drawing);
+    Logger::log(Logger::loader) << "singletons set" << std::endl;
+    
+    // ---------------------------------------------------------------
+    // Start the server thread - start the client listener and publish it
+    // ---------------------------------------------------------------
+    
+    server->start();
+    Logger::log(Logger::loader) << "Server started." << std::endl;
+    
+    Server_var server_ref = server->_this();
+    publish_server(server_ref, getopt, orb); 
+    
+    Logger::log(Logger::corba) << "Server location published."
+			       << std::endl;
+    
+    // ---------------------------------------------------------------
+    // Start any clients specified using --execute
+    // ---------------------------------------------------------------
+    value = "";
+    getopt.get("execute", &value);
+    if (!value.empty())
+    {
+      exec_child(child, value);
+      Logger::log(Logger::loader) << "Child process started." << std::endl;
+    }
+    
+    // ---------------------------------------------------------------
+    // Start ScreenManager thread
+    // ---------------------------------------------------------------
+    
+    smanager->start();
+    Logger::log(Logger::loader) << "ScreenManager is running." << std::endl;
+    
+    // ---------------------------------------------------------------
+    // Wait until we receive a request to shut down, then do so
+    // NOTE: server/smanager threads assumed to be shut-down implicitly
+    // ---------------------------------------------------------------
+    
+    Logger::log(Logger::loader) << "Blocking waiting for shutdown request." 
+				<< std::endl;
+    sem.wait();
+    Logger::log(Logger::loader) << "Starting server shutdown." << std::endl;
+    
+    unpublish_server(orb);
+    Logger::log(Logger::loader) << "Un-published Server." << std::endl;
+    
+    server->stop();
+    Logger::log(Logger::loader) << "Server stopped." << std::endl;
   }
   catch (const CORBA::SystemException &e)
   {
-      std::cerr << "ERROR: Unexpected CORBA::System exception caught: "
-                << e << std::endl;
+    std::cerr << "ERROR: Unexpected CORBA::System exception caught: "
+	      << e << std::endl;
   }
 #ifdef ORB_omniORB
   catch(const omniORB::fatalException &fe)
   {
-      std::cerr << "ERROR: OmniORB fatal exception caught at "
-                << fe.file() << " " << fe.line() << ":"
-                << fe.errmsg() << std::endl;
+    std::cerr << "ERROR: OmniORB fatal exception caught at "
+	      << fe.file() << " " << fe.line() << ":"
+	      << fe.errmsg() << std::endl;
   }
 #endif
   catch (const CORBA::Exception &e)
   {
-      std::cerr << "ERROR: Unexpected CORBA::Exception caught: "
-                << e << std::endl;
+    std::cerr << "ERROR: Unexpected CORBA::Exception caught: "
+	      << e << std::endl;
   }
   catch (const std::exception &e)
   {
-      std::cerr << "ERROR: Unexpected std::exception: "
-                << e.what() << std::endl;
+    std::cerr << "ERROR: Unexpected std::exception: "
+	      << e.what() << std::endl;
   }
   catch (...)
   {
-      std::cerr << "ERROR: *UNKNOWN* exception caught" << std::endl;
-  };
-
+    std::cerr << "ERROR: *UNKNOWN* exception caught" << std::endl;
+  }
   Logger::log(Logger::corba) << "CORBA servants gone." << std::endl;
   delete child;
   return 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.