Index: source/ariba/utility/system/StartupWrapper.cpp
===================================================================
--- source/ariba/utility/system/StartupWrapper.cpp	(revision 12775)
+++ source/ariba/utility/system/StartupWrapper.cpp	(revision 2378)
@@ -1,3 +1,3 @@
-// [License]
+// [Licence]
 // The Ariba-Underlay Copyright
 //
@@ -35,15 +35,7 @@
 // official policies, either expressed or implied, of the Institute of
 // Telematics.
-// [License]
-
-// XXX NOTE: Use this class with caution! Config support is outdated.
+// [Licence]
 
 #include "StartupWrapper.h"
-#include "ariba/config.h"
-
-#ifdef HAVE_LOG4CXX
-	#include <log4cxx/logger.h>
-	#include <log4cxx/basicconfigurator.h>
-#endif // HAVE_LOG4CXX
 
 namespace ariba {
@@ -55,7 +47,8 @@
 #endif
 
-SystemEventType StartupWrapperEventStartup("StartupWrapperEventStartup");
+SystemEventType StartupWrapperEventType("StartupWrapperEventType");
 
-StartupWrapper::StartupWrapper(StartupInterface* _service) : service( _service ){
+StartupWrapper::StartupWrapper(StartupInterface* _service, bool _block)
+	: blocking( _block ), service( _service ){
 }
 
@@ -80,11 +73,9 @@
 #endif
 
-void StartupWrapper::startSystem(){
+void StartupWrapper::initSystem(){
 
-	//
-	// having seeded the pseudo rng is always good
-	//
-
-	srand( time(NULL) );
+	static bool initialized = false;
+	if( initialized ) return;
+	initialized = true;
 
 	//
@@ -98,18 +89,24 @@
 	// init the logging system
 	//
-
-#ifdef HAVE_LOG4CXX
-	log4cxx::BasicConfigurator::configure();
-#endif //HAVE_LOG4CXX
-
-	//
-	// configure the default logging level to info
+	// configure the logging
 	//
 
-	logging_rootlevel_info();
-}
+	log4cxx::BasicConfigurator::configure();
 
-void StartupWrapper::stopSystem(){
-	SystemQueue::instance().cancel();
+	// set the global log level
+	{
+		log4cxx::LoggerPtr logger(log4cxx::Logger::getRootLogger());
+		logger->setLevel(log4cxx::Level::getDebug());
+	}
+
+	// set up again an individual level if you like
+	{
+ 		// log4cxx::LoggerPtr logger(log4cxx::Logger::getLogger("BaseOverlay"));
+ 		// logger->setLevel(log4cxx::Level::getInfo());
+	}
+
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+	// DON'T SVN COMMIT YOUR CHANTED LOGGING! THE ABOVE CODE MUST REMAIN AS IS!
+	//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
 }
 
@@ -119,68 +116,51 @@
 }
 
-void StartupWrapper::handleSystemEvent(const SystemEvent& event){
-
-	if( event.getType() == StartupWrapperEventStartup ){
-
-		if(!configurations.empty()){
-			string config = configurations.front();
-			configurations.pop();
-			Configuration::setConfigFilename( config );
-		}
-
-		//
-		// start the actual application
-		//
-
-		// TODO: im falle von omnet ist service = null, da von SpoVNetOmnetModule so ÃŒbergeben
-		// wie wird im Falle von omnet die anwendung erstellt?
-
-		service->startup();
-
-	}
-
-}
-
 void StartupWrapper::startup(StartupInterface* service, bool block){
 
-	StartupWrapper* startup = new StartupWrapper(service);
-	service->wrapper = startup;
+	StartupWrapper* spovnet = new StartupWrapper(service, block);
 
+#ifdef UNDERLAY_OMNET
 	SystemQueue::instance().scheduleEvent(
-		SystemEvent( startup, StartupWrapperEventStartup, NULL), 0 );
-
-#ifndef UNDERLAY_OMNET
-	if( block ) getchar();
+		SystemEvent( spovnet, StartupWrapperEventType, NULL), 0 );
+#else
+	spovnet->handleSystemEvent(
+		SystemEvent( spovnet, StartupWrapperEventType, NULL));
 #endif
 }
 
-void StartupWrapper::shutdown(StartupInterface* service, bool block){
+void StartupWrapper::handleSystemEvent(const SystemEvent& event){
 
-	if( service == NULL || service->wrapper == NULL ) return;
+	string config = configurations.front();
+	configurations.pop();
+	Configuration::setConfigFilename( config );
 
+	//
+	// start the actual application
+	//
+
+	// TODO: im falle von omnet ist service = null, da von SpoVNetOmnetModule so ÃŒbergeben
+	// wie wird im Falle von omnet die anwendung erstellt?
+
+	service->startup();
+	waitForExit();
+
+#ifndef UNDERLAY_OMNET
+	service->shutdown();
+	delete event.getListener();
+#endif
+}
+
+void StartupWrapper::waitForExit(){
+#ifndef UNDERLAY_OMNET
+	if( blocking ) getchar();
+#endif
+}
+
+void StartupWrapper::shutdown(){
 #ifdef UNDERLAY_OMNET
 	//TODO: service->shutdown();
 #endif
 
-	if(block){
-		// call directly
-		service->shutdown();
-	}else{
-		// call async, but not using systemqueue! // TODO: mem leak
-		AsyncShutdown* async = new AsyncShutdown(service);
-		async->runBlockingMethod();
-	}
-}
-
-StartupWrapper::AsyncShutdown::AsyncShutdown(StartupInterface* _service)
-	: service(_service){
-}
-
-void StartupWrapper::AsyncShutdown::blockingFunction(){
-	service->shutdown();
-}
-
-void StartupWrapper::AsyncShutdown::dispatchFunction(){
-	//unused
+	SystemQueue::instance().cancel();
 }
 
