Author: dblevins Date: Fri Mar 25 18:48:26 2005 New Revision: 159090 URL: http://svn.apache.org/viewcvs?view=rev&rev=159090 Log: Basic POJO and EJB handler support. Relies on uncommitted axis patch AXIS-1902
Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ServiceInfo.java Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java?view=diff&r1=159089&r2=159090 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisBuilder.java Fri Mar 25 18:48:26 2005 @@ -52,6 +52,7 @@ import org.apache.axis.soap.SOAPConstants; import org.apache.axis.providers.java.RPCProvider; import org.apache.axis.handlers.soap.SOAPService; +import org.apache.axis.handlers.HandlerInfoChainFactory; import org.apache.axis.MessageContext; import org.apache.axis.Handler; import org.apache.geronimo.axis.client.*; @@ -89,8 +90,8 @@ //WebServiceBuilder public void configurePOJO(GBeanData targetGBean, Object portInfoObject, String seiClassName, ClassLoader classLoader) throws DeploymentException { PortInfo portInfo = (PortInfo) portInfoObject; - - JavaServiceDesc serviceDesc = AxisServiceBuilder.createServiceDesc(portInfo, classLoader); + ServiceInfo serviceInfo = AxisServiceBuilder.createServiceInfo(portInfo, classLoader); + JavaServiceDesc serviceDesc = serviceInfo.getServiceDesc(); Class pojoClass = null; try { @@ -103,6 +104,10 @@ SOAPService service = new SOAPService(null, provider, null); service.setServiceDescription(serviceDesc); service.setOption("className", seiClassName); + + HandlerInfoChainFactory handlerInfoChainFactory = new HandlerInfoChainFactory(serviceInfo.getHanlderInfos()); + service.setOption(org.apache.axis.Constants.ATTR_HANDLERINFOCHAIN, handlerInfoChainFactory); + URL wsdlURL = null; try { wsdlURL = new URL(serviceDesc.getWSDLFile()); Modified: geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java?view=diff&r1=159089&r2=159090 ============================================================================== --- geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java (original) +++ geronimo/trunk/modules/axis-builder/src/java/org/apache/geronimo/axis/builder/AxisServiceBuilder.java Fri Mar 25 18:48:26 2005 @@ -22,12 +22,16 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.HashMap; +import java.util.ArrayList; import java.util.jar.JarFile; +import java.io.Serializable; import javax.wsdl.*; import javax.wsdl.extensions.soap.SOAPAddress; import javax.wsdl.extensions.soap.SOAPBinding; import javax.wsdl.extensions.soap.SOAPBody; import javax.xml.namespace.QName; +import javax.xml.rpc.handler.HandlerInfo; import org.apache.axis.constants.Style; import org.apache.axis.constants.Use; @@ -43,6 +47,9 @@ import org.apache.geronimo.kernel.ClassLoading; import org.apache.geronimo.xbeans.j2ee.JavaXmlTypeMappingType; import org.apache.geronimo.xbeans.j2ee.ServiceEndpointMethodMappingType; +import org.apache.geronimo.xbeans.j2ee.PortComponentHandlerType; +import org.apache.geronimo.xbeans.j2ee.ParamValueType; +import org.apache.geronimo.xbeans.j2ee.XsdQNameType; import org.apache.geronimo.axis.server.ReadOnlyServiceDesc; import org.apache.xmlbeans.SchemaType; @@ -59,7 +66,7 @@ } - public static JavaServiceDesc createEJBServiceDesc(JarFile jarFile, String ejbName, ClassLoader classLoader) throws DeploymentException { + public static ServiceInfo createServiceInfo(JarFile jarFile, String ejbName, ClassLoader classLoader) throws DeploymentException { Map portComponentsMap = null; try { URL webservicesURL = DeploymentUtil.createJarURL(jarFile, "META-INF/webservices.xml"); @@ -70,21 +77,69 @@ // Grab the portInfo for this ejb PortInfo portInfo = (PortInfo) portComponentsMap.get(ejbName); - return createServiceDesc(portInfo, classLoader); + JavaServiceDesc serviceDesc = createServiceDesc(portInfo, classLoader); + List handlerInfos = createHandlerInfos(portInfo, classLoader); + return new ServiceInfo(serviceDesc, handlerInfos); } - public static JavaServiceDesc createPOJOServiceDesc(JarFile jarFile, String pojoName, ClassLoader classLoader) throws DeploymentException { + public static JavaServiceDesc createEJBServiceDesc(JarFile jarFile, String ejbName, ClassLoader classLoader) throws DeploymentException { Map portComponentsMap = null; try { - URL webservicesURL = DeploymentUtil.createJarURL(jarFile, "WEB-INF/webservices.xml"); + URL webservicesURL = DeploymentUtil.createJarURL(jarFile, "META-INF/webservices.xml"); portComponentsMap = WSDescriptorParser.parseWebServiceDescriptor(webservicesURL, jarFile, true); } catch (MalformedURLException e1) { throw new DeploymentException("Invalid URL to webservices.xml", e1); } - // Grab the portInfo for this pojo - PortInfo portInfo = (PortInfo) portComponentsMap.get(pojoName); + // Grab the portInfo for this ejb + PortInfo portInfo = (PortInfo) portComponentsMap.get(ejbName); return createServiceDesc(portInfo, classLoader); + } + + private static List createHandlerInfos(PortInfo portInfo, ClassLoader classLoader) throws DeploymentException { + List list = new ArrayList(); + + PortComponentHandlerType[] handlers = portInfo.getHandlers(); + + for (int i = 0; i < handlers.length; i++) { + PortComponentHandlerType handler = handlers[i]; + + // Get handler class + Class handlerClass = null; + String className = handler.getHandlerClass().getStringValue().trim(); + try { + handlerClass = classLoader.loadClass(className); + } catch (ClassNotFoundException e) { + throw new DeploymentException("Unable to load handler class: "+className, e); + } + + // config data for the handler + Map config = new HashMap(); + ParamValueType[] paramValues = handler.getInitParamArray(); + for (int j = 0; j < paramValues.length; j++) { + ParamValueType paramValue = paramValues[j]; + String paramName = paramValue.getParamName().getStringValue().trim(); + String paramStringValue = paramValue.getParamValue().getStringValue().trim(); + config.put(paramName, paramStringValue); + } + + // QName array of headers it processes + XsdQNameType[] soapHeaderQNames = handler.getSoapHeaderArray(); + QName[] headers = new QName[soapHeaderQNames.length]; + for (int j = 0; j < soapHeaderQNames.length; j++) { + XsdQNameType soapHeaderQName = soapHeaderQNames[j]; + headers[j] = soapHeaderQName.getQNameValue(); + } + + list.add(new HandlerInfo(handlerClass, config, headers)); + } + return list; + } + + public static ServiceInfo createServiceInfo(PortInfo portInfo, ClassLoader classLoader) throws DeploymentException { + JavaServiceDesc serviceDesc = createServiceDesc(portInfo, classLoader); + List handlerInfos = createHandlerInfos(portInfo, classLoader); + return new ServiceInfo(serviceDesc, handlerInfos); } public static JavaServiceDesc createServiceDesc(PortInfo portInfo, ClassLoader classLoader) throws DeploymentException { Added: geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ServiceInfo.java URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ServiceInfo.java?view=auto&rev=159090 ============================================================================== --- geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ServiceInfo.java (added) +++ geronimo/trunk/modules/axis/src/java/org/apache/geronimo/axis/server/ServiceInfo.java Fri Mar 25 18:48:26 2005 @@ -0,0 +1,46 @@ +/** + * + * Copyright 2004 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.geronimo.axis.builder; + +import java.io.Serializable; +import java.util.List; + +import org.apache.axis.description.JavaServiceDesc; + +/** + * @version $Rev$ $Date$ + */ +public class ServiceInfo implements Serializable { + private final JavaServiceDesc serviceDesc; + /** List of javax.xml.rpc.handler.HandlerInfo objects */ + private final List hanlderInfos; + + public ServiceInfo(JavaServiceDesc serviceDesc, List hanlderInfos) { + this.serviceDesc = serviceDesc; + this.hanlderInfos = hanlderInfos; + } + + public JavaServiceDesc getServiceDesc() { + return serviceDesc; + } + + /** List of javax.xml.rpc.handler.HandlerInfo objects */ + public List getHanlderInfos() { + return hanlderInfos; + } + +}