001package ca.uhn.hl7v2.app; 002 003 004/** 005 * Contains configuration which will be applied to any servers which are created using the given 006 * HAPI Context. 007 * 008 * @see ca.uhn.hl7v2.HapiContext#getServerConfiguration() 009 */ 010public class ServerConfiguration { 011 012 private ApplicationExceptionPolicy myApplicationExceptionPolicy = ApplicationExceptionPolicy.DEFAULT; 013 014 015 016 /** 017 * @see #setApplicationExceptionPolicy(ApplicationExceptionPolicy) 018 */ 019 public ApplicationExceptionPolicy getApplicationExceptionPolicy() { 020 return myApplicationExceptionPolicy; 021 } 022 023 /** 024 * Sets the server behaviour when a {@link ca.uhn.hl7v2.protocol.ReceivingApplication} throws an exception while 025 * processing a message. 026 * <p> 027 * The {@link ApplicationExceptionPolicy#DEFAULT default} behaviour is to invoke the 028 * {@link ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler exception handler} if one has been 029 * {@link HL7Service#setExceptionHandler(ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler) registered} 030 * with the server, and then return the ACK/NAK message it provides. If no exception handler has 031 * been provided, HAPI will generate a NAK message using the default implementation and an 032 * {@link ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl#DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE AE} acknowlegement code. 033 * </p> 034 * 035 * @see ApplicationExceptionPolicy For other possible values 036 */ 037 // NB: The default explanation part of this javadoc is duplicated below! Keep in sync! 038 public void setApplicationExceptionPolicy(ApplicationExceptionPolicy applicationExceptionPolicy) { 039 if (applicationExceptionPolicy == null) { 040 throw new NullPointerException("Application Exception Policy must not be null"); 041 } 042 myApplicationExceptionPolicy = applicationExceptionPolicy; 043 } 044 045 046 /** 047 * @see ServerConfiguration#setApplicationExceptionPolicy(ApplicationExceptionPolicy) 048 */ 049 public static enum ApplicationExceptionPolicy 050 { 051 052 /** 053 * The <code>DEFAULT</code> behaviour is to invoke the 054 * {@link ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler exception handler} if one has been 055 * {@link HL7Service#setExceptionHandler(ca.uhn.hl7v2.protocol.ReceivingApplicationExceptionHandler) registered} 056 * with the server, and then return the ACK/NAK message it provides. If no exception handler has 057 * been provided, HAPI will generate a NAK message using the default implementation and an 058 * {@link ca.uhn.hl7v2.protocol.impl.ApplicationRouterImpl#DEFAULT_EXCEPTION_ACKNOWLEDGEMENT_CODE AE} acknowlegement code. 059 */ 060 // NB: this javadoc is duplicated above! Keep in sync! 061 DEFAULT, 062 063 /** 064 * If set to <code>DO_NOT_RESPOND</code>, the server will simply not provide any response to the 065 * client in the event that an application exception is thrown. 066 * <p> 067 * Note that this is not generally good practice, but it may be neccesary when 068 * dealing with some systems that don't behave correctly when they receive 069 * a negative acknowledment (NAK) message. Use with caution! 070 * </p> 071 */ 072 DO_NOT_RESPOND 073 074 } 075 076}