1 package org.codehaus.xfire.handler;
2
3 import javax.xml.namespace.QName;
4
5 import org.codehaus.xfire.MessageContext;
6 import org.codehaus.xfire.fault.XFireFault;
7
8 /***
9 * <p>
10 * A handler is just something that processes an XML message.
11 * </p>
12 * <p>
13 * If an exception occurrs in the invoke method, the entity which
14 * started the invocation, is responsible for turning the exception
15 * into a fault.
16 * </p>
17 *
18 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse </a>
19 * @since Feb 18, 2004
20 */
21 public interface Handler
22 {
23 String ROLE = Handler.class.getName();
24
25 /***
26 * @return null or an empty array if there are no headers.
27 */
28 QName[] getUnderstoodHeaders();
29
30 /***
31 * The roles which this service applies to.
32 *
33 * @return <code>null</code> or an empty if this endpoint handles no
34 * roles.
35 */
36 String[] getRoles();
37
38 /***
39 * The phase which this handler would like to be in.
40 *
41 * @return
42 * @see Phase
43 */
44 String getPhase();
45
46 /***
47 * Invoke a handler. If a fault occurs it will be handled via the
48 * <code>handleFault</code> method.
49 *
50 * @param message
51 * The message context.
52 */
53 void invoke(MessageContext context)
54 throws Exception;
55
56 /***
57 * Handles faults that occur in this handler. This is not responsible for
58 * actually writing the fault response message.
59 *
60 * @param context
61 */
62 void handleFault(XFireFault fault, MessageContext context);
63 }