1 package org.codehaus.xfire; 2 3 import java.util.HashMap; 4 import java.util.Map; 5 6 import org.codehaus.xfire.exchange.InExchange; 7 import org.codehaus.xfire.exchange.InMessage; 8 import org.codehaus.xfire.exchange.MessageExchange; 9 import org.codehaus.xfire.exchange.OutMessage; 10 import org.codehaus.xfire.exchange.RobustInOutExchange; 11 import org.codehaus.xfire.handler.HandlerPipeline; 12 import org.codehaus.xfire.service.OperationInfo; 13 import org.codehaus.xfire.service.Service; 14 import org.codehaus.xfire.soap.SoapConstants; 15 import org.codehaus.xfire.transport.Session; 16 17 /*** 18 * Holds inforrmation about the message request and response. 19 * 20 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 21 * @since Feb 13, 2004 22 */ 23 public class MessageContext 24 { 25 private Session session; 26 private Map properties; 27 28 private Service service; 29 30 private MessageExchange exchange; 31 32 private HandlerPipeline inPipeline; 33 private HandlerPipeline outPipeline; 34 private XFire xfire; 35 36 public MessageContext() 37 { 38 properties = new HashMap(); 39 } 40 41 public XFire getXFire() 42 { 43 return xfire; 44 } 45 46 public void setXFire(XFire xfire) 47 { 48 this.xfire = xfire; 49 } 50 51 public MessageExchange createMessageExchange(OperationInfo operation) 52 { 53 MessageExchange ex = createMessageExchange(operation.getMEP()); 54 ex.setOperation(operation); 55 56 return ex; 57 } 58 59 public MessageExchange createMessageExchange(String mepUri) 60 { 61 MessageExchange ex = null; 62 63 if (mepUri.equals(SoapConstants.MEP_ROBUST_IN_OUT)) 64 { 65 ex = new RobustInOutExchange(this); 66 } 67 else if (mepUri.equals(SoapConstants.MEP_IN)) 68 { 69 ex = new InExchange(this); 70 } 71 72 setExchange(ex); 73 74 return ex; 75 } 76 77 public MessageExchange getExchange() 78 { 79 return exchange; 80 } 81 82 public void setExchange(MessageExchange exchange) 83 { 84 this.exchange = exchange; 85 } 86 87 public OutMessage getOutMessage() 88 { 89 return exchange.getOutMessage(); 90 } 91 92 public InMessage getInMessage() 93 { 94 return exchange.getInMessage(); 95 } 96 97 public Object getProperty(Object key) 98 { 99 return properties.get(key); 100 } 101 102 public void setProperty(Object key, Object value) 103 { 104 properties.put(key, value); 105 } 106 107 /*** 108 * The session that this request is a part of. 109 * 110 * @return 111 */ 112 public Session getSession() 113 { 114 return session; 115 } 116 117 public void setSession(Session session) 118 { 119 this.session = session; 120 } 121 122 /*** 123 * The service being invoked. 124 * 125 * @return 126 */ 127 public Service getService() 128 { 129 return service; 130 } 131 132 public void setService(Service service) 133 { 134 this.service = service; 135 } 136 137 public HandlerPipeline getInPipeline() 138 { 139 return inPipeline; 140 } 141 142 public void setInPipeline(HandlerPipeline messagePipeline) 143 { 144 this.inPipeline = messagePipeline; 145 } 146 147 public HandlerPipeline getOutPipeline() 148 { 149 return outPipeline; 150 } 151 152 public void setOutPipeline(HandlerPipeline outPipeline) 153 { 154 this.outPipeline = outPipeline; 155 } 156 }