001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.systest.http;
019:
020: import java.util.concurrent.Future;
021: import java.util.logging.Logger;
022:
023: import javax.annotation.Resource;
024: import javax.jws.WebService;
025: import javax.servlet.http.HttpSession;
026: import javax.xml.ws.AsyncHandler;
027: import javax.xml.ws.Response;
028: import javax.xml.ws.WebServiceContext;
029: import javax.xml.ws.WebServiceException;
030: import javax.xml.ws.handler.MessageContext;
031:
032: import org.apache.cxf.greeter_control.Greeter;
033: import org.apache.cxf.greeter_control.types.GreetMeResponse;
034: import org.apache.cxf.greeter_control.types.PingMeResponse;
035: import org.apache.cxf.greeter_control.types.SayHiResponse;
036:
037: @WebService(serviceName="GreeterService",portName="GreeterPort",endpointInterface="org.apache.cxf.greeter_control.Greeter",targetNamespace="http://cxf.apache.org/greeter_control")
038: public class GreeterSessionImpl implements Greeter {
039: private static final Logger LOG = Logger
040: .getLogger(GreeterSessionImpl.class.getPackage().getName());
041:
042: @Resource
043: private WebServiceContext context;
044:
045: // greetMe will use session to return last called name
046: public String greetMe(String me) {
047: LOG.info("Executing operation greetMe");
048: LOG.info("Message received: " + me);
049: MessageContext mc = context.getMessageContext();
050: HttpSession session = ((javax.servlet.http.HttpServletRequest) mc
051: .get(MessageContext.SERVLET_REQUEST)).getSession();
052: // Get a session property "counter" from context
053: if (session == null) {
054: throw new WebServiceException(
055: "No session in WebServiceContext");
056: }
057: String name = (String) session.getAttribute("name");
058: if (name == null) {
059: name = me;
060: LOG.info("Starting the Session");
061: }
062:
063: session.setAttribute("name", me);
064:
065: return "Hello " + name;
066: }
067:
068: public String sayHi() {
069: LOG.info("Executing operation sayHi");
070:
071: return "Bonjour ";
072: }
073:
074: public void pingMe() {
075: }
076:
077: public Future<?> greetMeAsync(String requestType,
078: AsyncHandler<GreetMeResponse> asyncHandler) {
079: // TODO Auto-generated method stub
080: return null;
081: }
082:
083: public Response<GreetMeResponse> greetMeAsync(String requestType) {
084: // TODO Auto-generated method stub
085: return null;
086: }
087:
088: public void greetMeOneWay(String requestType) {
089: // TODO Auto-generated method stub
090:
091: }
092:
093: public Future<?> pingMeAsync(
094: AsyncHandler<PingMeResponse> asyncHandler) {
095: // TODO Auto-generated method stub
096: return null;
097: }
098:
099: public Response<PingMeResponse> pingMeAsync() {
100: // TODO Auto-generated method stub
101: return null;
102: }
103:
104: public Future<?> sayHiAsync(AsyncHandler<SayHiResponse> asyncHandler) {
105: // TODO Auto-generated method stub
106: return null;
107: }
108:
109: public Response<SayHiResponse> sayHiAsync() {
110: // TODO Auto-generated method stub
111: return null;
112: }
113:
114: }
|