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 */ 019 package org.apache.geronimo.axis2.pojo; 020 021 import org.apache.axis2.context.ServiceContext; 022 import org.apache.axis2.jaxws.context.factory.MessageContextFactory; 023 import org.apache.axis2.jaxws.context.utils.ContextUtils; 024 import org.apache.axis2.jaxws.core.MessageContext; 025 import org.apache.axis2.jaxws.handler.SoapMessageContext; 026 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleException; 027 import org.apache.axis2.jaxws.server.endpoint.lifecycle.EndpointLifecycleManager; 028 029 public class POJOEndpointLifecycleManager implements EndpointLifecycleManager { 030 031 /* 032 * This method is called on each web service call. 033 */ 034 public Object createServiceInstance(MessageContext context, Class serviceClass) throws EndpointLifecycleException { 035 org.apache.axis2.context.MessageContext msgContext = context.getAxisMessageContext(); 036 037 ServiceContext serviceContext = msgContext.getServiceContext(); 038 Object instance = serviceContext.getProperty(ServiceContext.SERVICE_OBJECT); 039 040 // associate JAX-WS MessageContext with the thread 041 POJOWebServiceContext.setMessageContext(createSOAPMessageContext(context)); 042 043 return instance; 044 } 045 046 private javax.xml.ws.handler.MessageContext createSOAPMessageContext(MessageContext mc) { 047 SoapMessageContext soapMessageContext = 048 (SoapMessageContext)MessageContextFactory.createSoapMessageContext(mc); 049 ContextUtils.addProperties(soapMessageContext, mc); 050 return soapMessageContext; 051 } 052 053 public void invokePostConstruct() throws EndpointLifecycleException { 054 } 055 056 public void invokePreDestroy() throws EndpointLifecycleException { 057 } 058 059 }