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: */package org.apache.cxf.transport.servlet;
19:
20: import java.io.IOException;
21: import java.util.logging.Level;
22: import java.util.logging.Logger;
23:
24: import org.apache.cxf.Bus;
25: import org.apache.cxf.message.MessageImpl;
26: import org.apache.cxf.service.model.EndpointInfo;
27: import org.apache.cxf.transport.ConduitInitiator;
28: import org.apache.cxf.transport.MessageObserver;
29: import org.apache.cxf.transport.http.AbstractHTTPDestination;
30:
31: public class ServletDestination extends AbstractHTTPDestination {
32:
33: static final Logger LOG = Logger.getLogger(ServletDestination.class
34: .getName());
35:
36: private static final long serialVersionUID = 1L;
37:
38: final ServletTransportFactory factory;
39: final String path;
40:
41: /**
42: * Constructor, allowing subsititution of configuration.
43: *
44: * @param b the associated Bus
45: * @param ci the associated conduit initiator
46: * @param ei the endpoint info of the destination
47: * @param cfg the configuration
48: * @throws IOException
49: */
50: public ServletDestination(Bus b, ConduitInitiator ci,
51: EndpointInfo ei, ServletTransportFactory fact, String p)
52: throws IOException {
53: // would add the default port to the address
54: super (b, ci, ei, false);
55: factory = fact;
56: path = p;
57: }
58:
59: protected Logger getLogger() {
60: return LOG;
61: }
62:
63: protected void doMessage(MessageImpl inMessage) throws IOException {
64: try {
65:
66: setHeaders(inMessage);
67:
68: inMessage.setDestination(this );
69:
70: incomingObserver.onMessage(inMessage);
71:
72: } finally {
73: if (LOG.isLoggable(Level.FINE)) {
74: LOG.fine("Finished servicing http request on thread: "
75: + Thread.currentThread());
76: }
77: }
78: }
79:
80: @Override
81: public void shutdown() {
82: factory.removeDestination(path);
83:
84: super .shutdown();
85: }
86:
87: public MessageObserver getMessageObserver() {
88: return this .incomingObserver;
89: }
90:
91: public EndpointInfo getEndpointInfo() {
92: return endpointInfo;
93: }
94: }
|