Coverage Report - ca.uhn.hl7v2.app.ServerConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ServerConfiguration
85%
6/7
50%
1/2
2
ServerConfiguration$ApplicationExceptionPolicy
100%
3/3
N/A
2
 
 1  
 package ca.uhn.hl7v2.app;
 2  
 
 3  
 
 4  
 /**
 5  
  * Contains configuration which will be applied to any servers which are created using the given
 6  
  * HAPI Context.
 7  
  * 
 8  
  * @see ca.uhn.hl7v2.HapiContext#getServerConfiguration()
 9  
  */
 10  5580
 public class ServerConfiguration {
 11  
 
 12  5580
         private ApplicationExceptionPolicy myApplicationExceptionPolicy = ApplicationExceptionPolicy.DEFAULT;
 13  
 
 14  
 
 15  
         
 16  
         /**
 17  
          * @see #setApplicationExceptionPolicy(ApplicationExceptionPolicy)
 18  
          */
 19  
         public ApplicationExceptionPolicy getApplicationExceptionPolicy() {
 20  35
                 return myApplicationExceptionPolicy;
 21  
         }
 22  
 
 23  
         /**
 24  
          * Sets the server behaviour when a {@link ca.uhn.hl7v2.protocol.ReceivingApplication} throws an exception while
 25  
          * processing a message.
 26  
          * <p>
 27  
          * The {@link ApplicationExceptionPolicy#DEFAULT default} behaviour is to invoke the 
 28  
          * {@link ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler exception handler} if one has been
 29  
          * {@link HL7Service#setExceptionHandler(ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler) registered} 
 30  
          * with the server, and then return the ACK/NAK message it provides. If no exception handler has
 31  
          * been provided, HAPI will generate a NAK message using the default implementation and an
 32  
          * {@link ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl#DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE AE} acknowlegement code.
 33  
          * </p>
 34  
          * 
 35  
          * @see ApplicationExceptionPolicy For other possible values
 36  
          */
 37  
         // NB: The default explanation part of this javadoc is duplicated below! Keep in sync!
 38  
         public void setApplicationExceptionPolicy(ApplicationExceptionPolicy applicationExceptionPolicy) {
 39  15
                 if (applicationExceptionPolicy == null) {
 40  0
                         throw new NullPointerException("Application Exception Policy must not be null");
 41  
                 }
 42  15
                 myApplicationExceptionPolicy = applicationExceptionPolicy;
 43  15
         }
 44  
 
 45  
 
 46  
         /**
 47  
          * @see ServerConfiguration#setApplicationExceptionPolicy(ApplicationExceptionPolicy)
 48  
          */
 49  20
         public static enum ApplicationExceptionPolicy
 50  
         {
 51  
 
 52  
                 /**
 53  
                  * The <code>DEFAULT</code> behaviour is to invoke the 
 54  
                  * {@link ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler exception handler} if one has been
 55  
                  * {@link HL7Service#setExceptionHandler(ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler) registered} 
 56  
                  * with the server, and then return the ACK/NAK message it provides. If no exception handler has
 57  
                  * been provided, HAPI will generate a NAK message using the default implementation and an
 58  
                  * {@link ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl#DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE AE} acknowlegement code.
 59  
                  */
 60  
                 // NB: this javadoc is duplicated above! Keep in sync!
 61  5
                 DEFAULT,
 62  
                 
 63  
                 /**
 64  
                  * If set to <code>DO_NOT_RESPOND</code>, the server will simply not provide any response to the
 65  
                  * client in the event that an application exception is thrown. 
 66  
                  * <p>
 67  
                  * Note that this is not generally good practice, but it may be neccesary when 
 68  
                  * dealing with some systems that don't behave correctly when they receive 
 69  
                  * a negative acknowledment (NAK) message. Use with caution!
 70  
                  * </p>
 71  
                  */
 72  5
                 DO_NOT_RESPOND
 73  
                 
 74  
         }
 75  
         
 76  
 }