Ejemplo n.º 1
0
		public static ConnectionManager getInstance()
		{
			if (m_mgr == null)
			{
				m_mgr = new ConnectionManager();
			}
			return m_mgr;
		}
Ejemplo n.º 2
0
		private void startApplication()
		{
			
			logger = Logger.getInstance();
			logger.initialize(m_debug);
			logger.info("");
			logger.info("===============================");
			logger.info("*** Starting up WinTunnel ****");
			logger.info("===============================");

			logger.info("Starting thread... ");

			//create a signal handler to detect Ctrl-C to stop the service
			if (m_debug)
			{
				m_ctrl = new ConsoleCtrl();
				m_ctrl.ControlEvent += new ConsoleCtrl.ControlEventHandler(consoleEventHandler);
			}

			//Load configuration and startup
			m_config = new AppConfig();
			if ( ! m_config.initialize() )
			{
				logger.error("Error loading configuration file.  Exiting...");
				return;
			}

			//Initialize the threadpool
			ThreadPool pool = ThreadPool.getInstance();
			pool.initialize(3); //start pool with 3 threads

			m_connMgr = ConnectionManager.getInstance();
		
			foreach (ProxyConfig cfg in m_config.m_proxyConfigs)
			{
				ProxyClientListenerTask task = new ProxyClientListenerTask(cfg);
				pool.addTask(task);
			}

			shutdownEvent.WaitOne(); //now just wait for signal to exit
			logger.info("Thread is initiating shutdown... ");

			if (m_ctrl != null)
			{
				logger.info("Releasing Console Event handler. ");
				m_ctrl = null;
			}
			
			//Shutdown the connection manager
			m_connMgr.shutdown();
			logger.info("Connection Manager has been terminated. ");

			//Shutdown the thread pool
			pool.Stop();
			logger.info("ThreadPool has been stopped. ");

			logger.info("Terminating thread... ");
			logger.info("*** WinTunnel exited. ****");
			logger.close();
		}