public static SIPDispatcherJob CreateJob(string jobClass, XmlNode configNode, SIPTransport sipTransport) { SIPDispatcherJob job = null; if (jobClass != null) { try { Type jobType = Type.GetType(jobClass); job = (SIPDispatcherJob)Activator.CreateInstance(jobType, new object[] { sipTransport, configNode }); logger.Debug("A SIPDispatcherJob of type, " + jobClass + ", was created."); } catch (ArgumentNullException nullExcp) { logger.Error("ArgumentNullException attempting to create a SIPDispatcherJob instance of type, " + jobClass + ". " + nullExcp.Message); throw new ApplicationException("Unable to create SIPDispatcherJob of type " + jobClass + ". Check that the assembly is available and the class exists."); } catch (Exception excp) { logger.Error("Exception attempting to create a SIPDispatcherJobinstance of type, " + jobClass + ". " + excp.Message); throw excp; } } else { throw new ApplicationException("No class element existed to create a SIPDispatcherJob from."); } return(job); }
public Dictionary <string, SIPDispatcherJob> Load(SIPTransport sipTransport) { try { Dictionary <string, SIPDispatcherJob> dispatcherJobs = new Dictionary <string, SIPDispatcherJob>(); if (sipTransport == null) { SIPChannel dispatcherChannel = new SIPUDPChannel(new IPEndPoint(IPAddress.Loopback, 0)); sipTransport = new SIPTransport(SIPDNSManager.ResolveSIPService, new SIPTransactionEngine(), dispatcherChannel, true); } foreach (XmlNode dispatcherNode in m_configNode.ChildNodes) { string jobType = dispatcherNode.Attributes.GetNamedItem("class").Value; string jobKey = dispatcherNode.Attributes.GetNamedItem("key").Value; if (!jobKey.IsNullOrBlank() && !jobType.IsNullOrBlank()) { SIPDispatcherJob job = SIPDispatcherJobFactory.CreateJob(jobType, dispatcherNode, sipTransport); if (job != null && !dispatcherJobs.ContainsKey(jobKey)) { ThreadPool.QueueUserWorkItem(delegate { job.Start(); }); dispatcherJobs.Add(jobKey, job); } } else { logger.Warn("The job key or class were empty for a SIPDispatcherJob node.\n" + dispatcherNode.OuterXml); } } return(dispatcherJobs); } catch (Exception dispatcherExcp) { logger.Error("Exception StatelessProxyCore Starting Dispatcher. " + dispatcherExcp.Message); return(null); } }