/// <param name="theServerSocket">a ServerSocket on which to listen for connections that will /// be used for both locally-driven and remotely-driven message exchanges /// </param> /// <param name="theRouter">used to send incoming messages to appropriate <code>Application</code>s /// </param> /// <param name="theStorage">used to commit incoming messages to safe storage before returning /// an accept ACK /// </param> public NuGenHL7Server(System.Net.Sockets.TcpListener theServerSocket, NuGenApplicationRouter theRouter, NuGenSafeStorage theStorage) { myServerSocket = theServerSocket; myRouter = theRouter; myStorage = theStorage; initProcessorList(); }
/// <param name="theLocallyDriven">a ServerSocket on which to listen for connections that will /// be used for locally-initiated message exchanges /// </param> /// <param name="theRemotelyDriven">a ServerSocket on which to listen for connections that will /// be used for remotely-initiated message exchanges /// </param> /// <param name="theRouter">used to send incoming messages to appropriate <code>Application</code>s /// </param> /// <param name="theStorage">used to commit incoming messages to safe storage before returning /// an accept ACK /// </param> public NuGenHL7Server(System.Net.Sockets.TcpListener theLocallyDriven, System.Net.Sockets.TcpListener theRemotelyDriven, NuGenApplicationRouter theRouter, NuGenSafeStorage theStorage) { myServerSocket = theLocallyDriven; myServerSocket2 = theRemotelyDriven; myRouter = theRouter; myStorage = theStorage; initProcessorList(); }
/// <summary> Creates a new instance that uses the given resources. /// /// </summary> /// <param name="theRouter"> /// </param> /// <param name="theTransport">a <code>TransportLayer</code> used for both locally-initiated /// and remotely-initiated message exchanges /// </param> /// <param name="theStorage"> /// </param> public NuGenProcessorContextImpl(NuGenApplicationRouter theRouter, NuGenTransportLayer theTransport, NuGenSafeStorage theStorage) { myRouter = theRouter; myRemotelyDrivenTransport = theTransport; myLocallyDrivenTransport = theTransport; mySafeStorage = theStorage; myValidators = new System.Collections.ArrayList(8); myMetadataFields = new System.Collections.ArrayList(30); }
/// <summary> <p>A convenience method for binding applications to an <code>ApplicationRouter</code> /// Information about bindings is read from a file at a specified URL. Each line in the /// file should have the following format (entries TAB delimited):</p> /// /// <p>message_type 	 trigger_event 	 processing_id 	 version_id 	 app_class</p> /// /// <p>Note that the first four fields can be the wildcard "*", which means any.</p> /// /// <p>For example, if you write an Application called org.yourorganiztion.ADTProcessor /// that processes several types of ADT messages, and another called /// org.yourorganization.ResultProcessor that processes result messages, you might have a /// file that looks like this: </p> /// /// <p>ADT 	 * 	 * 	 * 	 org.yourorganization.ADTProcessor<br> /// ORU 	 R01 	 * 	 * 	 org.yourorganization.ResultProcessor</p> /// /// <p>Each class listed in this file must implement either Genetibase.NuGenHL7.app.Application or /// Genetibase.NuGenHL7.protocol.ReceivingApplication, and must have a zero-argument constructor.</p> /// /// </summary> /// <param name="theRouter">the <code>ApplicationRouter</code> on which to make the binding /// </param> /// <param name="theSource">a URL pointing to the bindings file /// </param> public static void loadApplications(NuGenApplicationRouter theRouter, System.Uri theSource) { if (theSource == null) { throw new NuGenHL7Exception("Can't load application bindings: the given URL is null"); } System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(System.Net.WebRequest.Create(theSource).GetResponse().GetResponseStream(), System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(System.Net.WebRequest.Create(theSource).GetResponse().GetResponseStream(), System.Text.Encoding.Default).CurrentEncoding); System.String line = null; while ((line = in_Renamed.ReadLine()) != null) { //parse application registration information SupportClass.Tokenizer tok = new SupportClass.Tokenizer(line, "\t", false); System.String type = null, event_Renamed = null, procId = null, verId = null, className = null; if (tok.HasMoreTokens()) { //skip blank lines try { type = tok.NextToken(); event_Renamed = tok.NextToken(); procId = tok.NextToken(); verId = tok.NextToken(); className = tok.NextToken(); } catch (System.ArgumentOutOfRangeException) { throw new NuGenHL7Exception("Can't register applications from " + theSource.ToString() + ". The line '" + line + "' is not of the form: message_type [tab] trigger_event " + "[tab] processing ID [tab] version ID [tab] application_class. " + "*** NOTE TWO NEW FIELDS AS OF HAPI 0.5 ****. ", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR); } System.Type appClass = System.Type.GetType(className); //may throw ClassNotFoundException System.Object appObject = System.Activator.CreateInstance(appClass); NuGenReceivingApplication app = null; if (appObject is NuGenReceivingApplication) { app = (NuGenReceivingApplication) appObject; } else if (appObject is Application) { app = new NuGenAppWrapper((Application) appObject); } else { throw new NuGenHL7Exception("The specified class, " + appClass.FullName + ", doesn't implement Application or ReceivingApplication.", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR); } Genetibase.NuGenHL7.protocol.AppRoutingData rd = new NuGenAppRoutingDataImpl(type, event_Renamed, procId, verId); theRouter.bindApplication(rd, app); } } }
/// <summary> <p>A convenience method for binding applications to an <code>ApplicationRouter</code> /// Information about bindings is read from a file at a specified URL. Each line in the /// file should have the following format (entries TAB delimited):</p> /// /// <p>message_type 	 trigger_event 	 processing_id 	 version_id 	 app_class</p> /// /// <p>Note that the first four fields can be the wildcard "*", which means any.</p> /// /// <p>For example, if you write an Application called org.yourorganiztion.ADTProcessor /// that processes several types of ADT messages, and another called /// org.yourorganization.ResultProcessor that processes result messages, you might have a /// file that looks like this: </p> /// /// <p>ADT 	 * 	 * 	 * 	 org.yourorganization.ADTProcessor<br> /// ORU 	 R01 	 * 	 * 	 org.yourorganization.ResultProcessor</p> /// /// <p>Each class listed in this file must implement either Genetibase.NuGenHL7.app.Application or /// Genetibase.NuGenHL7.protocol.ReceivingApplication, and must have a zero-argument constructor.</p> /// /// </summary> /// <param name="theRouter">the <code>ApplicationRouter</code> on which to make the binding /// </param> /// <param name="theSource">a URL pointing to the bindings file /// </param> public static void loadApplications(NuGenApplicationRouter theRouter, System.Uri theSource) { if (theSource == null) { throw new NuGenHL7Exception("Can't load application bindings: the given URL is null"); } System.IO.StreamReader in_Renamed = new System.IO.StreamReader(new System.IO.StreamReader(System.Net.WebRequest.Create(theSource).GetResponse().GetResponseStream(), System.Text.Encoding.Default).BaseStream, new System.IO.StreamReader(System.Net.WebRequest.Create(theSource).GetResponse().GetResponseStream(), System.Text.Encoding.Default).CurrentEncoding); System.String line = null; while ((line = in_Renamed.ReadLine()) != null) { //parse application registration information SupportClass.Tokenizer tok = new SupportClass.Tokenizer(line, "\t", false); System.String type = null, event_Renamed = null, procId = null, verId = null, className = null; if (tok.HasMoreTokens()) { //skip blank lines try { type = tok.NextToken(); event_Renamed = tok.NextToken(); procId = tok.NextToken(); verId = tok.NextToken(); className = tok.NextToken(); } catch (System.ArgumentOutOfRangeException) { throw new NuGenHL7Exception("Can't register applications from " + theSource.ToString() + ". The line '" + line + "' is not of the form: message_type [tab] trigger_event " + "[tab] processing ID [tab] version ID [tab] application_class. " + "*** NOTE TWO NEW FIELDS AS OF HAPI 0.5 ****. ", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR); } System.Type appClass = System.Type.GetType(className); //may throw ClassNotFoundException System.Object appObject = System.Activator.CreateInstance(appClass); NuGenReceivingApplication app = null; if (appObject is NuGenReceivingApplication) { app = (NuGenReceivingApplication)appObject; } else if (appObject is Application) { app = new NuGenAppWrapper((Application)appObject); } else { throw new NuGenHL7Exception("The specified class, " + appClass.FullName + ", doesn't implement Application or ReceivingApplication.", NuGenHL7Exception.APPLICATION_INTERNAL_ERROR); } Genetibase.NuGenHL7.protocol.AppRoutingData rd = new NuGenAppRoutingDataImpl(type, event_Renamed, procId, verId); theRouter.bindApplication(rd, app); } } }
/// <summary> Creates a new instance that uses the given resources. /// /// </summary> /// <param name="theRouter"> /// </param> /// <param name="theLocallyDrivenTransport">a <code>TransportLayer</code> used for locally-initiated /// and message exchanges /// </param> /// <param name="theRemotelyDrivenTransport">a <code>TransportLayer</code> used for remotely-initiated /// and message exchanges /// </param> /// <param name="theStorage"> /// </param> public NuGenProcessorContextImpl(NuGenApplicationRouter theRouter, NuGenTransportLayer theLocallyDrivenTransport, NuGenTransportLayer theRemotelyDrivenTransport, NuGenSafeStorage theStorage) { myRouter = theRouter; myRemotelyDrivenTransport = theRemotelyDrivenTransport; myLocallyDrivenTransport = theLocallyDrivenTransport; mySafeStorage = theStorage; myValidators = new System.Collections.ArrayList(8); myMetadataFields = new System.Collections.ArrayList(30); }