Saminda, When you need to introduce changes such as AXIS2-1106 that break backward compat. *PLEASE* discuss first on list. At least highlight such a change in the commit message so that it can be caught earlier.
thanks, dims On 9/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: saminda Date: Sat Sep 2 00:37:20 2006 New Revision: 439555 URL: http://svn.apache.org/viewvc?rev=439555&view=rev Log: 1. Added ServiceObjectSupplier interface, thus, if an .aar contains a "ServiceObjectSuppler" this will give the correct service object, at deployment time as well as when calling the MR that's been extenteded from Abstract Message Receiver 2. First implementation of this has been tried out with Spring 3. Added ServletConfig instance to AxisConfiguration. TODO // SchemaGeneration only takes a full qualified service object name. A Constructor should be added to take the Class, thus, the code will be efficient. Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/ServiceObjectSupplier.java Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringAppContextAwareObjectSupplier.java webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringServletContextObjectSupplier.java Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/ServiceObjectSupplier.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/ServiceObjectSupplier.java?rev=439555&view=auto ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/ServiceObjectSupplier.java (added) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/ServiceObjectSupplier.java Sat Sep 2 00:37:20 2006 @@ -0,0 +1,26 @@ +/* + * Copyright 2004,2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.axis2; + +import org.apache.axis2.description.AxisService; +/* + * + */ + +public interface ServiceObjectSupplier { + /* Deployment Engine uses this method */ + public Object getServiceObject(AxisService axisService) throws AxisFault; +} Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/deployment/util/Utils.java Sat Sep 2 00:37:20 2006 @@ -31,6 +31,7 @@ import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import java.lang.reflect.Method; /* * Copyright 2004,2005 The Apache Software Foundation. @@ -211,10 +212,37 @@ */ public static void fillAxisService(AxisService axisService, AxisConfiguration axisConfig, ArrayList excludeOperations) throws Exception { + String serviceClass; Parameter implInfoParam = axisService.getParameter(Constants.SERVICE_CLASS); - if (implInfoParam == null) { - // Nothing to do. - return; + ClassLoader serviceClassLoader = axisService.getClassLoader(); + + if (implInfoParam != null) { + serviceClass = (String) implInfoParam.getValue(); + } else { + // if Service_Class is null, every AbstractMR will look for + // ServiceObjectSupplier. This is user specific and may contain + // other looks. + implInfoParam = axisService.getParameter(Constants.SERVICE_OBJECT_SUPPLIER); + if (implInfoParam != null) { + Class serviceObjectMaker = Class.forName(((String) + implInfoParam.getValue()).trim(), true, serviceClassLoader); + + // Find static getServiceObject() method, call it if there + Method method = serviceObjectMaker. + getMethod("getServiceObject", + new Class[] { AxisService.class }); + Object obj = null; + if (method != null) { + obj = method.invoke(serviceObjectMaker.newInstance(), new Object[] { axisService }); + } + if (obj == null) { + throw new Exception("ServiceObjectSupplier implmentation Object could not be found"); + } + serviceClass = obj.getClass().getName(); + } else { + return; + } + } // adding name spaces Map map = new HashMap(); @@ -223,8 +251,6 @@ map.put(Java2WSDLConstants.DEFAULT_SCHEMA_NAMESPACE_PREFIX, Java2WSDLConstants.URI_2001_SCHEMA_XSD); axisService.setNameSpacesMap(map); - String serviceClass = (String) implInfoParam.getValue(); - ClassLoader serviceClassLoader = axisService.getClassLoader(); SchemaGenerator schemaGenerator = new SchemaGenerator(serviceClassLoader, serviceClass.trim(), axisService.getSchematargetNamespace(), axisService.getSchematargetNamespacePrefix()); Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/receivers/AbstractMessageReceiver.java Sat Sep 2 00:37:20 2006 @@ -81,9 +81,9 @@ // Find static getServiceObject() method, call it if there Method method = serviceObjectMaker. getMethod("getServiceObject", - new Class[] { MessageContext.class }); + new Class[] { AxisService.class }); if (method != null) - return method.invoke(null, new Object[] { msgContext }); + return method.invoke(serviceObjectMaker.newInstance(), new Object[] { service }); } Parameter implInfoParam = service.getParameter(Constants.SERVICE_CLASS); Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/AxisServlet.java Sat Sep 2 00:37:20 2006 @@ -102,7 +102,6 @@ msgContext.setProperty(Constants.Configuration.TRANSPORT_IN_URL, req.getRequestURL().toString()); msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP); msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req); - msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, servletConfig.getServletContext()); return msgContext; } @@ -278,6 +277,11 @@ axisConfiguration = configContext.getAxisConfiguration(); config.getServletContext().setAttribute(CONFIGURATION_CONTEXT, configContext); + // setting the ServletConfig to AxisConfiguration + Parameter servletConfigParam = new Parameter(); + servletConfigParam.setName(HTTPConstants.HTTP_SERVLETCONFIG); + servletConfigParam.setValue(this.servletConfig); + axisConfiguration.addParameter(servletConfigParam); ListenerManager listenerManager = new ListenerManager(); listenerManager.init(configContext); TransportInDescription transportInDescription = new TransportInDescription( @@ -453,7 +457,6 @@ msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, getHeaders(req)); msgContext.setServiceGroupContextId(UUIDGenerator.getUUID()); msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST, req); - msgContext.setProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT, servletConfig.getServletContext()); return msgContext; } Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java (original) +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/transport/http/HTTPConstants.java Sat Sep 2 00:37:20 2006 @@ -155,8 +155,14 @@ /** * Field MC_HTTP_SERVLETCONTEXT + * @deprecated */ public static String MC_HTTP_SERVLETCONTEXT = "transport.http.servletContext"; + + /** + * transport.http.servletConfig + */ + public static String HTTP_SERVLETCONFIG = "transport.http.servletConfig"; /** * Field HEADER_USER_AGENT Modified: webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringAppContextAwareObjectSupplier.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringAppContextAwareObjectSupplier.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringAppContextAwareObjectSupplier.java (original) +++ webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringAppContextAwareObjectSupplier.java Sat Sep 2 00:37:20 2006 @@ -17,45 +17,45 @@ package org.apache.axis2.extensions.spring.receivers; import org.apache.axis2.AxisFault; -import org.apache.axis2.context.MessageContext; +import org.apache.axis2.ServiceObjectSupplier; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; import org.apache.axis2.i18n.Messages; - import org.springframework.context.ApplicationContext; -public class SpringAppContextAwareObjectSupplier { +public class SpringAppContextAwareObjectSupplier implements ServiceObjectSupplier { + public static final String SERVICE_SPRING_BEANNAME = "SpringBeanName"; /** - * Method getServiceObject that is Spring aware via Spring interface - * ApplicationContextAware. + * Method getServiceObject that is Spring aware via Spring interface + * ApplicationContextAware. * - * @param msgContext + * @param axisService * @return Returns Object. * @throws AxisFault */ - public static Object getServiceObject(MessageContext msgContext) throws AxisFault { + + public Object getServiceObject(AxisService axisService) throws AxisFault { try { - AxisService service = - msgContext.getOperationContext().getServiceContext().getAxisService(); // Name of spring aware bean to be injected, taken from services.xml - // via 'SERVICE_SPRING_BEANNAME ' . The Bean and its properties are pre-configured + // via 'SERVICE_SPRING_BEANNAME ' . The Bean and its properties are pre-configured // as normally done in a spring type of way and subsequently loaded by Spring. // Axis2 just assumes that the bean is configured and is in the classloader. - Parameter implBeanParam = service.getParameter(SERVICE_SPRING_BEANNAME); + Parameter implBeanParam = axisService.getParameter(SERVICE_SPRING_BEANNAME); String beanName = ((String) implBeanParam.getValue()).trim(); if (beanName != null) { // ApplicationContextHolder implements Spring interface ApplicationContextAware - ApplicationContext aCtx = ApplicationContextHolder.getContext(); - if (aCtx == null) { - throw new Exception("Axis2 Can't find Spring's ApplicationContext"); - } else if (aCtx.getBean(beanName) == null) { - throw new Exception("Axis2 Can't find Spring Bean: " + beanName); - } + ApplicationContext aCtx = ApplicationContextHolder.getContext(); + if (aCtx == null) { + throw new Exception("Axis2 Can't find Spring's ApplicationContext"); + } else if (aCtx.getBean(beanName) == null) { + throw new Exception("Axis2 Can't find Spring Bean: " + beanName); + } return aCtx.getBean(beanName); } else { - throw new AxisFault(Messages.getMessage("paramIsNotSpecified", "SERVICE_SPRING_BEANNAME")); + throw new AxisFault( + Messages.getMessage("paramIsNotSpecified", "SERVICE_SPRING_BEANNAME")); } } catch (Exception e) { throw AxisFault.makeFault(e); Modified: webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringServletContextObjectSupplier.java URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringServletContextObjectSupplier.java?rev=439555&r1=439554&r2=439555&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringServletContextObjectSupplier.java (original) +++ webservices/axis2/trunk/java/modules/spring/src/org/apache/axis2/extensions/spring/receivers/SpringServletContextObjectSupplier.java Sat Sep 2 00:37:20 2006 @@ -17,58 +17,59 @@ package org.apache.axis2.extensions.spring.receivers; import org.apache.axis2.AxisFault; -import org.apache.axis2.context.MessageContext; +import org.apache.axis2.ServiceObjectSupplier; import org.apache.axis2.description.AxisService; import org.apache.axis2.description.Parameter; import org.apache.axis2.i18n.Messages; -import org.apache.axis2.Constants; import org.apache.axis2.transport.http.HTTPConstants; - -import javax.servlet.ServletContext; - import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; -public class SpringServletContextObjectSupplier { +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; + +public class SpringServletContextObjectSupplier implements ServiceObjectSupplier { public static final String SERVICE_SPRING_BEANNAME = "SpringBeanName"; /** - * Method getServiceObject that is Spring aware via ServletContext. + * Method getServiceObject that is Spring aware via ServletContext. * - * @param msgContext + * @param axisService * @return Returns Object. * @throws AxisFault */ - public static Object getServiceObject(MessageContext msgContext) throws AxisFault { + public Object getServiceObject(AxisService axisService) throws AxisFault { try { - AxisService service = - msgContext.getOperationContext().getServiceContext().getAxisService(); // Name of spring aware bean to be injected, taken from services.xml - // via 'SERVICE_SPRING_BEANNAME ' . The Bean and its properties are pre-configured + // via 'SERVICE_SPRING_BEANNAME ' . The Bean and its properties are pre-configured // as normally done in a spring type of way and subsequently loaded by Spring. // Axis2 just assumes that the bean is configured and is in the classloader. - Parameter implBeanParam = service.getParameter(SERVICE_SPRING_BEANNAME); + Parameter implBeanParam = axisService.getParameter(SERVICE_SPRING_BEANNAME); String beanName = ((String) implBeanParam.getValue()).trim(); if (beanName != null) { - ServletContext servletContext = (ServletContext) msgContext.getOptions(). - getProperty(HTTPConstants.MC_HTTP_SERVLETCONTEXT); - if (servletContext == null) { - throw new Exception("Axis2 Can't find ServletContext"); + ServletConfig servletConfig = (ServletConfig) axisService.getAxisConfiguration() + .getParameter(HTTPConstants.HTTP_SERVLETCONFIG); + if (servletConfig == null) { + throw new Exception("Axis2 Can't find ServletConfig"); + } + ServletContext servletContext = servletConfig.getServletContext(); + + ApplicationContext aCtx = + WebApplicationContextUtils.getWebApplicationContext(servletContext); + if (aCtx == null) { + throw new Exception("Axis2 Can't find Spring's ApplicationContext"); + } else if (aCtx.getBean(beanName) == null) { + throw new Exception("Axis2 Can't find Spring Bean: " + beanName); } - ApplicationContext aCtx = - WebApplicationContextUtils.getWebApplicationContext(servletContext); - if (aCtx == null) { - throw new Exception("Axis2 Can't find Spring's ApplicationContext"); - } else if (aCtx.getBean(beanName) == null) { - throw new Exception("Axis2 Can't find Spring Bean: " + beanName); - } return aCtx.getBean(beanName); } else { - throw new AxisFault(Messages.getMessage("paramIsNotSpecified", "SERVICE_SPRING_BEANNAME")); + throw new AxisFault( + Messages.getMessage("paramIsNotSpecified", "SERVICE_SPRING_BEANNAME")); } } catch (Exception e) { throw AxisFault.makeFault(e); } + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
