public MsControlFactory getFactory(Properties config) throws MsControlException { // if factory already created just return it if (factory != null) { return factory; } scheduler = Executors.newSingleThreadScheduledExecutor(); if (config == null) { config = new Properties(); config.setProperty("mgcp.bind.address", "127.0.0.1"); config.setProperty("mgcp.server.address", "127.0.0.1"); config.setProperty("mgcp.local.port", "2729"); config.setProperty("mgcp.server.port", "2427"); } // get the bind address and port localHost = config.getProperty("mgcp.bind.address"); remoteHost = config.getProperty("mgcp.server.address"); localPort = Integer.parseInt(config.getProperty("mgcp.local.port")); remotePort = Integer.parseInt(config.getProperty("mgcp.server.port")); InetAddress bindAddress = null; try { bindAddress = InetAddress.getByName(localHost); } catch (UnknownHostException e) { } boolean testMode = config.getProperty("driver.test.mode") != null && Boolean.parseBoolean(config.getProperty("driver.test.mode")); if (!testMode) { logger.info("Initializing MGCP on " + bindAddress + ":" + localPort); // create and bind MGCP stack try { mgcpStack = new JainMgcpStackImpl(bindAddress, localPort); mgcpProvider = mgcpStack.createProvider(); // assign itself as listener mgcpProvider.addJainMgcpListener(this); } catch (Exception e) { throw new MsControlException(e.getMessage()); } } callAgent = new NotifiedEntity("mscontrol", localHost, localPort); factory = new MsControlFactoryImpl(this); return factory; }
public void shutdown() { if (scheduler != null) { scheduler.shutdownNow(); } scheduler = null; if (mgcpProvider != null) { try { mgcpProvider.getJainMgcpStack().deleteProvider(mgcpProvider); } catch (DeleteProviderException e) { // TODO Auto-generated catch block e.printStackTrace(); } mgcpProvider = null; mgcpStack = null; } factory = null; }