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 public class ServerConfiguration {
11
12 private ApplicationExceptionPolicy myApplicationExceptionPolicy = ApplicationExceptionPolicy.DEFAULT;
13
14
15
16 /**
17 * @see #setApplicationExceptionPolicy(ApplicationExceptionPolicy)
18 */
19 public ApplicationExceptionPolicy getApplicationExceptionPolicy() {
20 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 if (applicationExceptionPolicy == null) {
40 throw new NullPointerException("Application Exception Policy must not be null");
41 }
42 myApplicationExceptionPolicy = applicationExceptionPolicy;
43 }
44
45
46 /**
47 * @see ServerConfiguration#setApplicationExceptionPolicy(ApplicationExceptionPolicy)
48 */
49 public 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 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 DO_NOT_RESPOND
73
74 }
75
76 }