1 package org.codehaus.xfire.message;
2
3 import org.codehaus.xfire.MessageContext;
4 import org.codehaus.xfire.service.object.ObjectService;
5 import org.codehaus.xfire.soap.SoapConstants;
6
7 /***
8 * Create a MessageReaders and MessageWriters for a ObjectService.
9 *
10 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
11 * @since Apr 7, 2004
12 */
13 public class MessageBridgeFactory
14 {
15 public static MessageBridge createMessageBridge(MessageContext context)
16 {
17 ObjectService service = (ObjectService) context.getService();
18
19 AbstractMessageBridge bridge;
20 if (service.getStyle().equals(SoapConstants.STYLE_WRAPPED)
21 && service.getUse().equals(SoapConstants.USE_LITERAL))
22 {
23 bridge = new WrappedBridge(context);
24 }
25 else if (service.getStyle().equals(SoapConstants.STYLE_DOCUMENT)
26 && service.getUse().equals(SoapConstants.USE_LITERAL))
27 {
28 bridge = new DocumentBridge(context);
29 }
30 else if (service.getStyle().equals(SoapConstants.STYLE_RPC)
31 && service.getUse().equals(SoapConstants.USE_ENCODED))
32 {
33 bridge = new RPCEncodedBridge(context);
34 }
35 else
36 {
37 throw new UnsupportedOperationException( "Service style/use not supported." );
38 }
39
40 return bridge;
41 }
42 }