1 package org.codehaus.xfire; 2 3 import java.io.OutputStream; 4 import java.util.HashMap; 5 import java.util.Map; 6 import org.codehaus.xfire.service.Service; 7 import org.codehaus.xfire.session.Session; 8 9 /*** 10 * Holds inforrmation about the message request and response. 11 * 12 * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a> 13 * @since Feb 13, 2004 14 */ 15 public class MessageContext 16 { 17 private static ThreadLocal messageContexts = new ThreadLocal(); 18 19 private Session session; 20 private OutputStream responseStream; 21 private String requestUri; 22 private String serviceName; 23 private String action; 24 private Map properties; 25 private String soapVersion; 26 private Service service; 27 28 /*** 29 * Create a MessageContext to invoke a service with the 30 * specified document as the request. 31 */ 32 public MessageContext( String service, 33 String action, 34 OutputStream response, 35 Session session, 36 String requestUri ) 37 { 38 messageContexts.set(this); 39 40 properties = new HashMap(); 41 42 this.serviceName = service; 43 this.action = action; 44 this.responseStream = response; 45 this.session = session; 46 this.requestUri = requestUri; 47 } 48 49 /*** 50 * Get the message context for the current thread. 51 * 52 * @return The current MessageContext or null if there is none. 53 */ 54 public static MessageContext getCurrentMessageContext() 55 { 56 return (MessageContext) messageContexts.get(); 57 } 58 59 public Object getProperty( Object key ) 60 { 61 return properties.get(key); 62 } 63 64 public void setProperty( Object key, Object value ) 65 { 66 properties.put(key, value); 67 } 68 69 public String getRequestUri() 70 { 71 return requestUri; 72 } 73 74 public void setRequestUri( String requestUri ) 75 { 76 this.requestUri = requestUri; 77 } 78 79 public OutputStream getResponseStream() 80 { 81 return responseStream; 82 } 83 84 public void setResponseStream( OutputStream responseStream ) 85 { 86 this.responseStream = responseStream; 87 } 88 89 /*** 90 * The session that this request is a part of. 91 * 92 * @return 93 */ 94 public Session getSession() 95 { 96 return session; 97 } 98 99 public void setSession( Session session ) 100 { 101 this.session = session; 102 } 103 104 public String getAction() 105 { 106 return action; 107 } 108 109 public void setAction( String action ) 110 { 111 this.action = action; 112 } 113 114 public String getServiceName() 115 { 116 return serviceName; 117 } 118 119 public void setServiceName( String service ) 120 { 121 this.serviceName = service; 122 } 123 124 public String getSoapVersion() 125 { 126 return soapVersion; 127 } 128 129 public void setSoapVersion( String soapVersion ) 130 { 131 this.soapVersion = soapVersion; 132 } 133 134 /*** 135 * The service being invoked. 136 * 137 * @return 138 */ 139 public Service getService() 140 { 141 return service; 142 } 143 144 public void setService( Service service ) 145 { 146 this.service = service; 147 } 148 }