Search in sources :

Example 1 with ConnectionListener

use of ca.uhn.hl7v2.app.ConnectionListener in project streamsx.health by IBMStreams.

the class TestServer method main.

public static void main(String[] args) {
    try {
        HapiContext ctx = new DefaultHapiContext();
        CanonicalModelClassFactory mcf = new CanonicalModelClassFactory("2.6");
        ctx.setModelClassFactory(mcf);
        ctx.setValidationRuleBuilder(new NoValidationBuilder());
        ctx.setExecutorService(Executors.newCachedThreadPool());
        HL7Service server = ctx.newServer(8082, false);
        server.registerApplication(new HapiMessageHandler(null));
        server.registerConnectionListener(new ConnectionListener() {

            @Override
            public void connectionReceived(Connection c) {
                System.out.println("Connection received.");
            }

            @Override
            public void connectionDiscarded(Connection c) {
                System.out.println("Connection discarded.");
            }
        });
        server.startAndWait();
        ctx.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : NoValidationBuilder(ca.uhn.hl7v2.validation.builder.support.NoValidationBuilder) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) HL7Service(ca.uhn.hl7v2.app.HL7Service) Connection(ca.uhn.hl7v2.app.Connection) ConnectionListener(ca.uhn.hl7v2.app.ConnectionListener) IOException(java.io.IOException) HapiContext(ca.uhn.hl7v2.HapiContext) DefaultHapiContext(ca.uhn.hl7v2.DefaultHapiContext) CanonicalModelClassFactory(ca.uhn.hl7v2.parser.CanonicalModelClassFactory)

Aggregations

DefaultHapiContext (ca.uhn.hl7v2.DefaultHapiContext)1 HapiContext (ca.uhn.hl7v2.HapiContext)1 Connection (ca.uhn.hl7v2.app.Connection)1 ConnectionListener (ca.uhn.hl7v2.app.ConnectionListener)1 HL7Service (ca.uhn.hl7v2.app.HL7Service)1 CanonicalModelClassFactory (ca.uhn.hl7v2.parser.CanonicalModelClassFactory)1 NoValidationBuilder (ca.uhn.hl7v2.validation.builder.support.NoValidationBuilder)1 IOException (java.io.IOException)1