1 package org.codehaus.xfire.handler;
2
3 import org.codehaus.xfire.MessageContext;
4 import org.codehaus.xfire.exchange.OutMessage;
5 import org.codehaus.xfire.fault.XFireFault;
6 import org.codehaus.xfire.transport.DefaultEndpoint;
7
8 /***
9 * Reads in the message body using the service binding.
10 *
11 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
12 */
13 public class DispatchServiceHandler
14 extends AbstractHandler
15 {
16 public String getPhase()
17 {
18 return Phase.DISPATCH;
19 }
20
21 public void invoke(MessageContext context)
22 throws XFireFault
23 {
24 Boolean b = (Boolean) context.getProperty(DefaultEndpoint.SERVICE_HANDLERS_REGISTERED);
25 if (b == null || b.equals(Boolean.FALSE))
26 {
27 context.getInPipeline().addHandlers(context.getService().getInHandlers());
28 }
29
30 if (context.getExchange().hasOutMessage())
31 {
32 HandlerPipeline pipeline = new HandlerPipeline(context.getXFire().getOutPhases());
33 pipeline.addHandlers(context.getService().getOutHandlers());
34 pipeline.addHandlers(context.getXFire().getOutHandlers());
35 OutMessage msg = context.getExchange().getOutMessage();
36 pipeline.addHandlers(msg.getChannel().getTransport().getOutHandlers());
37
38 context.setOutPipeline(pipeline);
39 }
40 }
41 }