01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19:
20: package org.apache.axis2.transport.nhttp;
21:
22: import org.apache.commons.logging.LogFactory;
23: import org.apache.commons.logging.Log;
24: import org.apache.axis2.context.MessageContext;
25: import org.apache.axis2.AxisFault;
26: import org.apache.axis2.Constants;
27: import org.apache.axis2.transport.RequestResponseTransport;
28:
29: /**
30: * This interface is a point of control for Axis2 (and Sandesha2 in particular) to control
31: * the behaviour of a Request-Response transport such as HTTP/s
32: *
33: * For nhttp, this does not make much of a difference, as we are capable of keeping a socket open
34: * and writing to it from a different thread, while letting the initial thread that read the request
35: * go free. However, it seems like Sandesha2 is looking for this interface, and it is not going to
36: * create much of an issue anyway
37: */
38: public class HttpCoreRequestResponseTransport implements
39: RequestResponseTransport {
40:
41: private static final Log log = LogFactory
42: .getLog(HttpCoreRequestResponseTransport.class);
43: private RequestResponseTransportStatus status = RequestResponseTransportStatus.INITIAL;
44: private MessageContext msgContext = null;
45: private boolean responseWritten = false;
46:
47: HttpCoreRequestResponseTransport(MessageContext msgContext) {
48: this .msgContext = msgContext;
49: }
50:
51: public void acknowledgeMessage(MessageContext msgContext)
52: throws AxisFault {
53: log.debug("Acking one-way request");
54: }
55:
56: public void awaitResponse() throws InterruptedException, AxisFault {
57: log
58: .debug("Returning thread but keeping socket open -- awaiting response");
59: status = RequestResponseTransportStatus.WAITING;
60: msgContext.getOperationContext().setProperty(
61: Constants.RESPONSE_WRITTEN, "SKIP");
62: }
63:
64: public void signalResponseReady() {
65: log.debug("Signal response available");
66: status = RequestResponseTransportStatus.SIGNALLED;
67: }
68:
69: public RequestResponseTransportStatus getStatus() {
70: return status;
71: }
72:
73: public void signalFaultReady(AxisFault fault) {
74: }
75:
76: public boolean isResponseWritten() {
77: return responseWritten;
78: }
79:
80: public void setResponseWritten(boolean responseWritten) {
81: this.responseWritten = responseWritten;
82: }
83: }
|