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.systest.provider.datasource;
19:
20: import java.util.logging.Logger;
21:
22: import javax.xml.ws.Endpoint;
23: import javax.xml.ws.WebServiceContext;
24: import javax.xml.ws.handler.MessageContext;
25: import javax.xml.ws.http.HTTPBinding;
26:
27: public abstract class AbstractProvider<T> implements WebProvider {
28: static final Logger LOG = Logger.getLogger(AbstractProvider.class
29: .getName());
30: protected WebServiceContext wsContext;
31:
32: public T invoke(T req) {
33:
34: MessageContext mc = wsContext.getMessageContext();
35: String method = (String) mc
36: .get(MessageContext.HTTP_REQUEST_METHOD);
37: LOG.info("method: " + method);
38:
39: T ret = null;
40: if ("GET".equalsIgnoreCase(method)) {
41: ret = get(req);
42: } else if ("POST".equalsIgnoreCase(method)) {
43: ret = post(req);
44: }
45:
46: return ret;
47: }
48:
49: protected T get(T req) {
50: return req;
51: }
52:
53: public WebServiceContext getWebServiceContext() {
54: return wsContext;
55: }
56:
57: protected T post(T req) {
58: return req;
59: }
60:
61: public void publish(String url) {
62: Endpoint ep = Endpoint.create(HTTPBinding.HTTP_BINDING, this );
63: ep.publish(url);
64: }
65:
66: public void setWebServiceContext(WebServiceContext wsc) {
67: wsContext = wsc;
68: }
69: }
|