1 16 package org.apache.axis2.context; 17 18 import org.apache.axis2.addressing.EndpointReference; 19 import org.apache.axis2.addressing.MessageInformationHeadersCollection; 20 import org.apache.axis2.addressing.miheaders.RelatesTo; 21 import org.apache.axis2.description.*; 22 import org.apache.axis2.engine.AxisConfiguration; 23 import org.apache.axis2.engine.AxisFault; 24 import org.apache.axis2.soap.SOAPEnvelope; 25 26 import javax.xml.namespace.QName ; 27 28 34 public class MessageContext extends AbstractContext { 35 38 public static final String TRANSPORT_OUT = "TRANSPORT_OUT"; 39 40 43 public static final String TRANSPORT_IN = "TRANSPORT_IN"; 44 45 46 47 50 public static final String TRANSPORT_SUCCEED = "TRANSPORT_SUCCEED"; 51 52 55 private boolean processingFault = false; 56 57 63 64 private MessageInformationHeadersCollection messageInformationHeaders; 65 66 private OperationContext operationContext; 67 private ServiceContext serviceContext; 68 private ConfigurationContext configurationContext; 69 70 private TransportInDescription transportIn; 71 72 private TransportOutDescription transportOut; 73 74 77 private final SessionContext sessionContext; 78 79 82 83 86 private SOAPEnvelope envelope; 87 88 91 private boolean responseWritten; 92 93 96 private boolean inFaultFlow; 97 98 101 private boolean serverSide; 102 103 106 private String messageID; 107 108 111 private boolean newThreadRequired = false; 112 113 private boolean paused = false; 114 115 public boolean outPutWritten = false; 116 117 private String serviceInstanceID; 118 119 private String pausedPhaseName; 120 121 private QName pausedHandlerName; 122 123 private String soapAction; 124 125 126 private boolean doingMTOM = false; 128 private boolean doingREST = false; 130 131 136 137 public MessageContext(ConfigurationContext engineContext) throws AxisFault { 138 this(engineContext, null, null, null); 139 } 140 141 public MessageContext( 142 ConfigurationContext engineContext, 143 TransportInDescription transportIn, 144 TransportOutDescription transportOut) 145 throws AxisFault { 146 this(engineContext, null, transportIn, transportOut); 147 } 148 149 156 157 public MessageContext( 158 ConfigurationContext engineContext, 159 SessionContext sessionContext, 160 TransportInDescription transportIn, 161 TransportOutDescription transportOut) 162 throws AxisFault { 163 super(null); 164 165 if (sessionContext == null) { 166 this.sessionContext = new SessionContext(null); 167 } else { 168 this.sessionContext = sessionContext; 169 } 170 messageInformationHeaders = new MessageInformationHeadersCollection(); 171 this.transportIn = transportIn; 172 this.transportOut = transportOut; 173 this.configurationContext = engineContext; 174 175 } 176 177 180 public EndpointReference getFaultTo() { 181 return messageInformationHeaders.getFaultTo(); 182 } 183 184 187 public EndpointReference getFrom() { 188 return messageInformationHeaders.getFrom(); 189 } 190 191 194 public boolean isInFaultFlow() { 195 return inFaultFlow; 196 } 197 198 201 public SOAPEnvelope getEnvelope() { 202 return envelope; 203 } 204 205 208 public String getMessageID() { 209 return messageInformationHeaders.getMessageId(); 210 } 211 212 215 public boolean isProcessingFault() { 216 return processingFault; 217 } 218 219 222 public RelatesTo getRelatesTo() { 223 return messageInformationHeaders.getRelatesTo(); 224 } 225 226 229 public EndpointReference getReplyTo() { 230 return messageInformationHeaders.getReplyTo(); 231 } 232 233 236 public boolean isResponseWritten() { 237 return responseWritten; 238 } 239 240 243 public boolean isServerSide() { 244 return serverSide; 245 } 246 247 250 public SessionContext getSessionContext() { 251 return sessionContext; 252 } 253 254 257 public EndpointReference getTo() { 258 return messageInformationHeaders.getTo(); 259 } 260 261 264 public void setFaultTo(EndpointReference reference) { 265 messageInformationHeaders.setFaultTo(reference); 266 } 267 268 271 public void setFrom(EndpointReference reference) { 272 messageInformationHeaders.setFrom(reference); 273 } 274 275 278 public void setInFaultFlow(boolean b) { 279 inFaultFlow = b; 280 } 281 282 285 public void setEnvelope(SOAPEnvelope envelope) { 286 this.envelope = envelope; 287 } 288 289 292 public void setMessageID(String string) { 293 messageInformationHeaders.setMessageId(string); 294 } 295 296 299 public void setProcessingFault(boolean b) { 300 processingFault = b; 301 } 302 303 306 public void setRelatesTo(RelatesTo reference) { 307 messageInformationHeaders.setRelatesTo(reference); 308 } 309 310 313 public void setReplyTo(EndpointReference referance) { 314 messageInformationHeaders.setReplyTo(referance); 315 } 316 317 320 public void setResponseWritten(boolean b) { 321 responseWritten = b; 322 } 323 324 327 public void setServerSide(boolean b) { 328 serverSide = b; 329 } 330 331 334 public void setTo(EndpointReference referance) { 335 messageInformationHeaders.setTo(referance); 336 } 337 338 341 public boolean isNewThreadRequired() { 342 return newThreadRequired; 343 } 344 345 348 public void setNewThreadRequired(boolean b) { 349 newThreadRequired = b; 350 } 351 352 357 358 public void setWSAAction(String actionURI) { 359 messageInformationHeaders.setAction(actionURI); 360 } 361 362 public String getWSAAction() { 363 return messageInformationHeaders.getAction(); 364 } 365 366 public void setWSAMessageId(String messageID) { 367 messageInformationHeaders.setMessageId(messageID); 368 } 369 370 public String getWSAMessageId() { 371 return messageInformationHeaders.getMessageId(); 372 } 373 374 public MessageInformationHeadersCollection getMessageInformationHeaders() { 375 return messageInformationHeaders; 376 } 377 378 381 public boolean isPaused() { 382 return paused; 383 } 384 385 388 public void setPausedTrue(QName handlerName) { 389 paused = true; 390 this.pausedHandlerName = handlerName; 391 } 392 393 public void setPausedFalse() { 394 paused = false; 395 } 396 397 400 public TransportInDescription getTransportIn() { 401 return transportIn; 402 } 403 404 407 public TransportOutDescription getTransportOut() { 408 return transportOut; 409 } 410 411 414 public void setTransportIn(TransportInDescription in) { 415 transportIn = in; 416 } 417 418 421 public void setTransportOut(TransportOutDescription out) { 422 transportOut = out; 423 } 424 425 428 public OperationContext getOperationContext() { 429 return operationContext; 430 } 431 432 435 public void setOperationContext(OperationContext context) { 436 operationContext = context; 437 if (serviceContext != null && operationContext.getParent() == null) { 438 operationContext.setParent(serviceContext); 439 } 440 this.setParent(operationContext); 441 } 442 443 446 public boolean isOutPutWritten() { 447 return outPutWritten; 448 } 449 450 453 public void setOutPutWritten(boolean b) { 454 outPutWritten = b; 455 } 456 457 460 public String getServiceInstanceID() { 461 return serviceInstanceID; 462 } 463 464 467 public void setServiceInstanceID(String serviceInstanceID) { 468 this.serviceInstanceID = serviceInstanceID; 469 } 470 471 public ConfigurationContext getSystemContext() { 472 return configurationContext; 473 } 474 475 478 public ServiceContext getServiceContext() { 479 return serviceContext; 480 } 481 482 485 public void setConfigurationContext(ConfigurationContext context) { 486 configurationContext = context; 487 } 488 489 492 public void setServiceContext(ServiceContext context) { 493 serviceContext = context; 494 if (operationContext != null && operationContext.getParent() != null) { 495 operationContext.setParent(context); 496 } 497 } 498 499 502 public void setMessageInformationHeaders(MessageInformationHeadersCollection collection) { 503 messageInformationHeaders = collection; 504 } 505 506 509 public Object getProperty(String key, boolean persistent) { 510 Object obj = super.getProperty(key, persistent); 511 512 if (obj == null && operationContext == null && serviceContext != null) { 515 obj = serviceContext.getProperty(key, persistent); 516 } 517 if (obj == null && operationContext == null) { 518 obj = configurationContext.getProperty(key, persistent); 519 } 520 Parameter param = null; 522 if (obj == null && operationContext != null) { 523 OperationDescription opDesc = operationContext.getAxisOperation(); 524 param = opDesc.getParameter(key); 525 } 526 if (param == null && serviceContext != null) { 527 ServiceDescription serviceDesc = serviceContext.getServiceConfig(); 528 param = serviceDesc.getParameter(key); 529 } 530 if (param == null && configurationContext != null) { 531 AxisConfiguration baseConfig = configurationContext.getAxisConfiguration(); 532 param = baseConfig.getParameter(key); 533 } 534 if (param != null) { 535 obj = param.getValue(); 536 } 537 return obj; 538 } 539 542 public QName getPausedHandlerName() { 543 return pausedHandlerName; 544 } 545 546 549 public String getPausedPhaseName() { 550 return pausedPhaseName; 551 } 552 553 556 public void setPausedPhaseName(String name) { 557 pausedPhaseName = name; 558 } 559 560 563 public String getSoapAction() { 564 return soapAction; 565 } 566 567 570 public void setSoapAction(String string) { 571 soapAction = string; 572 } 573 574 577 public boolean isDoingMTOM() { 578 return doingMTOM; 579 } 580 581 584 public void setDoingMTOM(boolean b) { 585 doingMTOM = b; 586 } 587 588 591 public boolean isDoingREST() { 592 return doingREST; 593 } 594 595 598 public void setDoingREST(boolean b) { 599 doingREST = b; 600 } 601 602 } 603 | Popular Tags |