You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by di...@apache.org on 2007/01/26 22:10:32 UTC
svn commit: r500348 - in /geronimo/server/trunk: ./ configs/cxf/
configs/jee-specs/
modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/
modules/geronimo-cxf/
modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/ testsuite/...
Author: dims
Date: Fri Jan 26 13:10:31 2007
New Revision: 500348
URL: http://svn.apache.org/viewvc?view=rev&rev=500348
Log:
Fix for GERONIMO-2781 - Improved CXF-based POJO WebService support
Modified:
geronimo/server/trunk/configs/cxf/pom.xml
geronimo/server/trunk/configs/jee-specs/pom.xml
geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
geronimo/server/trunk/modules/geronimo-cxf/pom.xml
geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java
geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoDestination.java
geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResourceResolver.java
geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java
geronimo/server/trunk/pom.xml
geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/pom.xml
geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/Greeter.java
geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/webapp/WEB-INF/webservices.xml
Modified: geronimo/server/trunk/configs/cxf/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/cxf/pom.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/configs/cxf/pom.xml (original)
+++ geronimo/server/trunk/configs/cxf/pom.xml Fri Jan 26 13:10:31 2007
@@ -139,10 +139,6 @@
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
- <dependency>
- <groupId>javax.xml.ws</groupId>
- <artifactId>jaxws-api</artifactId>
- </dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
Modified: geronimo/server/trunk/configs/jee-specs/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/configs/jee-specs/pom.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/configs/jee-specs/pom.xml (original)
+++ geronimo/server/trunk/configs/jee-specs/pom.xml Fri Jan 26 13:10:31 2007
@@ -125,6 +125,10 @@
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.xml.ws</groupId>
+ <artifactId>jaxws-api</artifactId>
+ </dependency>
<!-- build order hint -->
<dependency>
Modified: geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java Fri Jan 26 13:10:31 2007
@@ -22,22 +22,22 @@
import java.io.FileNotFoundException;
import java.net.URL;
import java.net.MalformedURLException;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import java.util.Collections;
import java.util.jar.JarFile;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
-import javax.xml.ws.handler.Handler;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.cxf.jaxws.javaee.PortComponentType;
+import org.apache.cxf.jaxws.javaee.ServiceImplBeanType;
import org.apache.cxf.jaxws.javaee.WebserviceDescriptionType;
import org.apache.cxf.jaxws.javaee.WebservicesType;
@@ -60,19 +60,15 @@
import org.apache.geronimo.deployment.service.EnvironmentBuilder;
import org.apache.geronimo.deployment.util.DeploymentUtil;
-
public class CXFBuilder implements WebServiceBuilder {
- private static final Logger LOG = Logger.getLogger(CXFBuilder.class.getName());
-
+ private static final Log LOG = LogFactory.getLog(CXFBuilder.class);
+
private final Environment defaultEnvironment;
private static final String KEY = CXFBuilder.class.getName();
- private JAXBContext ctx;
-
- public CXFBuilder(Environment defaultEnvironment) throws JAXBException {
+ public CXFBuilder(Environment defaultEnvironment) {
this.defaultEnvironment = defaultEnvironment;
- ctx = JAXBContext.newInstance(WebservicesType.class);
}
public void findWebServices(JarFile moduleFile, boolean isEJB, Map servletLocations, Environment environment, Map sharedContext) throws DeploymentException {
@@ -91,7 +87,7 @@
private Map<String, PortInfo> parseWebServiceDescriptor(URL wsDDUrl, JarFile moduleFile, boolean isEJB, Map correctedPortLocations) throws DeploymentException {
- LOG.fine("parsing descriptor " + wsDDUrl);
+ LOG.debug("Parsing descriptor " + wsDDUrl);
Map<String, PortInfo> map = new HashMap<String, PortInfo>();
@@ -101,8 +97,9 @@
throw new DeploymentException("unable to read descriptor " + wsDDUrl);
}
+ JAXBContext ctx = JAXBContext.newInstance(WebservicesType.class);
Unmarshaller unmarshaller = ctx.createUnmarshaller();
- Object obj = unmarshaller.unmarshal(new javax.xml.transform.stream.StreamSource(in), WebservicesType.class);
+ Object obj = unmarshaller.unmarshal(new StreamSource(in), WebservicesType.class);
if (obj instanceof JAXBElement) {
obj = ((JAXBElement)obj).getValue();
@@ -114,24 +111,56 @@
WebservicesType wst = (WebservicesType) obj;
for (WebserviceDescriptionType desc : wst.getWebserviceDescription()) {
- final String wsdlFile = desc.getWsdlFile().getValue();
- final String serviceName = desc.getWebserviceDescriptionName().getValue();
+ String wsdlFile = null;
+ if (desc.getWsdlFile() != null) {
+ wsdlFile = getString(desc.getWsdlFile().getValue());
+ }
+
+ String serviceName = desc.getWebserviceDescriptionName().getValue();
for (PortComponentType port : desc.getPortComponent()) {
- String servlet = port.getServiceImplBean().getServletLink().getValue();
- String sei = port.getServiceEndpointInterface().getValue();
- String portName = port.getPortComponentName().getValue();
-
+
PortInfo portInfo = new PortInfo();
-
- portInfo.setServiceName(serviceName);
- portInfo.setServletLink(servlet);
- portInfo.setServiceEndpointInterfaceName(sei);
+
+ String serviceLink = null;
+ ServiceImplBeanType beanType = port.getServiceImplBean();
+ if (beanType.getEjbLink() != null) {
+ serviceLink = beanType.getEjbLink().getValue();
+ } else if (beanType.getServletLink().getValue() != null) {
+ serviceLink = beanType.getServletLink().getValue();
+ }
+ portInfo.setServiceLink(serviceLink);
+
+ if (port.getServiceEndpointInterface() != null) {
+ String sei = port.getServiceEndpointInterface().getValue();
+ portInfo.setServiceEndpointInterfaceName(sei);
+ }
+
+ String portName = port.getPortComponentName().getValue();
portInfo.setPortName(portName);
- portInfo.setWsdlFile(wsdlFile);
- portInfo.setHandlers(port.getHandler());
-
- map.put(servlet, portInfo);
+
+ portInfo.setProtocolBinding(port.getProtocolBinding());
+ portInfo.setServiceName(serviceName);
+ portInfo.setWsdlFile(wsdlFile);
+
+ if (port.getEnableMtom() != null) {
+ portInfo.setEnableMTOM(port.getEnableMtom().isValue());
+ }
+
+ portInfo.setHandlers(port.getHandlerChains());
+
+ if (port.getWsdlPort() != null) {
+ portInfo.setWsdlPort(port.getWsdlPort().getValue());
+ }
+
+ if (port.getWsdlService() != null) {
+ portInfo.setWsdlService(port.getWsdlService().getValue());
+ }
+
+ String location = (String)correctedPortLocations.get(serviceLink);
+ portInfo.setLocation(location);
+
+ map.put(serviceLink, portInfo);
}
}
@@ -139,18 +168,25 @@
} catch (FileNotFoundException e) {
return Collections.EMPTY_MAP;
} catch (IOException ex) {
- ex.printStackTrace();
throw new DeploymentException("unable to read " + wsDDUrl, ex);
} catch (JAXBException ex) {
throw new DeploymentException("unable to parse webservices.xml", ex);
+ } catch (Exception ex) {
+ throw new DeploymentException("Unknown deployment error", ex);
}
}
-
+
+ private static String getString(String in) {
+ if (in != null) {
+ in = in.trim();
+ if (in.length() == 0) {
+ return null;
+ }
+ }
+ return in;
+ }
public boolean configurePOJO(GBeanData targetGBean, String servletName, Module module, String seiClassName, DeploymentContext context) throws DeploymentException {
-
- // assert pi instanceof PortInfo : "received incorrect portInfo object";
-
Map sharedContext = ((WebModule) module).getSharedContext();
Map portInfoMap = (Map) sharedContext.get(KEY);
PortInfo portInfo = (PortInfo) portInfoMap.get(servletName);
@@ -164,7 +200,7 @@
GBeanData moduleGBean = context.getGBeanInstance(context.getModuleName());
componentContext = (Map)moduleGBean.getAttribute("componentContext");
} catch (GBeanNotFoundException e) {
- LOG.warning("ModuleGBean not found. JNDI resource injection will not work.");
+ LOG.warn("ModuleGBean not found. JNDI resource injection will not work.");
}
LOG.info("configuring POJO webservice: " + servletName + " sei: " + seiClassName);
@@ -173,7 +209,6 @@
ClassLoader classLoader = context.getClassLoader();
loadSEI(seiClassName, classLoader);
- /*List<Handler> handlers =*/ buildHandlerChain(portInfo);
AbstractName containerFactoryName = context.getNaming().createChildName(targetGBean.getAbstractName(), "cxfWebServiceContainerFactory", NameFactory.GERONIMO_SERVICE);
GBeanData containerFactoryData = new GBeanData(containerFactoryName, CXFWebServiceContainerFactoryGBean.GBEAN_INFO);
containerFactoryData.setAttribute("portInfo", portInfo);
@@ -186,7 +221,8 @@
}
targetGBean.setReferencePattern("WebServiceContainerFactory", containerFactoryName);
- targetGBean.setAttribute("pojoClassName", seiClassName);
+ // our web container does not use that property
+ targetGBean.setAttribute("pojoClassName", "java.lang.Object");
if (context instanceof EARContext) {
containerFactoryData.setReferencePattern("TransactionManager",
@@ -196,7 +232,6 @@
return true;
}
-
public boolean configureEJB(GBeanData targetGBean, String ejbName, JarFile moduleFile, Map sharedContext, ClassLoader classLoader) throws DeploymentException {
throw new DeploymentException("configureEJB NYI");
}
@@ -207,10 +242,6 @@
} catch (ClassNotFoundException ex) {
throw new DeploymentException("unable to load Service Endpoint Interface: " + className, ex);
}
- }
-
- private List<Handler> buildHandlerChain(PortInfo portInfo) {
- return new ArrayList<Handler>();
}
public static final GBeanInfo GBEAN_INFO;
Modified: geronimo/server/trunk/modules/geronimo-cxf/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/pom.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/pom.xml (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/pom.xml Fri Jan 26 13:10:31 2007
@@ -62,6 +62,12 @@
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-annotation_1.0_spec</artifactId>
+ </dependency>
+
+
</dependencies>
</project>
Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainer.java Fri Jan 26 13:10:31 2007
@@ -18,60 +18,84 @@
import javax.naming.Context;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.binding.xml.XMLConstants;
-import org.apache.cxf.jaxws.EndpointImpl;
-import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.tools.common.extensions.soap.SoapAddress;
+import org.apache.cxf.tools.util.SOAPBindingUtil;
import org.apache.cxf.transport.DestinationFactoryManager;
import org.apache.cxf.service.model.EndpointInfo;
import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
-import org.apache.cxf.resource.ResourceManager;
import org.apache.geronimo.webservices.WebServiceContainer;
+import org.xmlsoap.schemas.wsdl.http.AddressType;
import javax.wsdl.Definition;
+import javax.wsdl.Port;
+import javax.wsdl.Service;
+import javax.wsdl.extensions.ExtensibilityElement;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLWriter;
+import java.net.URL;
import java.util.List;
import java.util.ArrayList;
-//TODO consider putting most of this in the CXFWebServiceContaInerFactoryGBean
+// TODO consider putting most of this in the CXFWebServiceContaInerFactoryGBean
public class CXFWebServiceContainer implements WebServiceContainer {
+ private static final Log LOG = LogFactory.getLog(CXFWebServiceContainer.class);
+
private final GeronimoDestination destination;
+
private final Bus bus;
- public CXFWebServiceContainer(PortInfo portInfo, Object target, Bus bus, Context context) {
- //TODO actually use portInfo
+ private final CXFEndpoint endpoint;
+
+ private URL configurationBaseUrl;
+
+ public CXFWebServiceContainer(PortInfo portInfo,
+ Object target,
+ Bus bus,
+ Context context,
+ URL configurationBaseUrl) {
this.bus = bus;
+ this.configurationBaseUrl = configurationBaseUrl;
List ids = new ArrayList();
ids.add("http://schemas.xmlsoap.org/wsdl/soap/http");
- ResourceManager resourceManager = bus.getExtension(ResourceManager.class);
- if (context != null) {
- resourceManager.addResourceResolver(new JNDIResourceResolver(context));
- }
+ bus.setExtension(new JNDIResolver(context), JNDIResolver.class);
+ bus.setExtension(portInfo, PortInfo.class);
- DestinationFactoryManager destinationFactoryManager = bus.getExtension(DestinationFactoryManager.class);
+ DestinationFactoryManager destinationFactoryManager = bus
+ .getExtension(DestinationFactoryManager.class);
GeronimoDestinationFactory factory = new GeronimoDestinationFactory(bus);
factory.setTransportIds(ids);
- destinationFactoryManager.registerDestinationFactory("http://cxf.apache.org/transports/http/configuration", factory);
- destinationFactoryManager.registerDestinationFactory("http://www.w3.org/2003/05/soap/bindings/HTTP/", factory);
- destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", factory);
- destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/", factory);
- destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", factory);
- destinationFactoryManager.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", factory);
- destinationFactoryManager.registerDestinationFactory(XMLConstants.NS_XML_FORMAT, factory);
- EndpointImpl publishedEndpoint = publishEndpoint(target);
- destination = (GeronimoDestination) publishedEndpoint.getServer().getDestination();
+ destinationFactoryManager.registerDestinationFactory(
+ "http://cxf.apache.org/transports/http/configuration", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ "http://www.w3.org/2003/05/soap/bindings/HTTP/", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ "http://schemas.xmlsoap.org/soap/http", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ "http://schemas.xmlsoap.org/wsdl/http/", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ "http://schemas.xmlsoap.org/wsdl/soap/", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ "http://schemas.xmlsoap.org/wsdl/soap/http", factory);
+ destinationFactoryManager.registerDestinationFactory(
+ XMLConstants.NS_XML_FORMAT, factory);
+
+ endpoint = publishEndpoint(target);
+ destination = (GeronimoDestination) endpoint.getServer()
+ .getDestination();
}
public void invoke(Request request, Response response) throws Exception {
destination.invoke(request, response);
}
-
public void getWsdl(Request request, Response response) throws Exception {
WSDLWriter wsdlWriter = WSDLFactory.newInstance().newWSDLWriter();
@@ -79,37 +103,42 @@
EndpointInfo ei = this.destination.getEndpointInfo();
Definition def = new ServiceWSDLBuilder(ei.getService()).build();
-
- /* FIXME: this doesn't quite work yet
- Port port = def.getService(ei.getService().getName()).getPort(ei.getName().getLocalPart());
- List<?> exts = port.getExtensibilityElements();
- if (exts.size() > 0) {
- ExtensibilityElement el = (ExtensibilityElement)exts.get(0);
- if (SOAPBindingUtil.isSOAPAddress(el)) {
- SoapAddress add = SOAPBindingUtil.getSoapAddress(el);
- add.setLocationURI(request.getURI().toString());
- }
- if (el instanceof AddressType) {
- AddressType add = (AddressType)el;
- add.setLocation(request.getURI().toString());
+
+ Service service = def.getService(ei.getService().getName());
+ Port port = service.getPort(ei.getName().getLocalPart());
+ if (port == null) {
+ LOG.warn("No WSDL port found for: " + ei.getName());
+ } else {
+ List<?> exts = port.getExtensibilityElements();
+ if (exts != null && exts.size() > 0) {
+ ExtensibilityElement el = (ExtensibilityElement) exts.get(0);
+ if (SOAPBindingUtil.isSOAPAddress(el)) {
+ SoapAddress add = SOAPBindingUtil.getSoapAddress(el);
+ add.setLocationURI(request.getURI().toString());
+ }
+ if (el instanceof AddressType) {
+ AddressType add = (AddressType) el;
+ add.setLocation(request.getURI().toString());
+ }
}
}
- */
wsdlWriter.writeWSDL(def, response.getOutputStream());
}
public void destroy() {
+ if (this.endpoint != null) {
+ this.endpoint.stop();
+ }
}
- private EndpointImpl publishEndpoint(Object target) {
-
+ private CXFEndpoint publishEndpoint(Object target) {
assert target != null : "null target received";
- EndpointImpl ep = new EndpointImpl(bus, target, (String)null);
+ CXFEndpoint ep = new CXFEndpoint(bus, configurationBaseUrl, target,
+ (String) null);
ep.publish("http://nopath");
return ep;
-
}
}
Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/CXFWebServiceContainerFactoryGBean.java Fri Jan 26 13:10:31 2007
@@ -17,14 +17,15 @@
package org.apache.geronimo.cxf;
+import java.net.URL;
import java.util.Map;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.transaction.TransactionManager;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.cxf.Bus;
import org.apache.cxf.bus.cxf.CXFBusFactory;
import org.apache.geronimo.gbean.GBeanInfo;
@@ -41,42 +42,45 @@
*/
public class CXFWebServiceContainerFactoryGBean implements WebServiceContainerFactory {
- private static final Logger LOG =
- Logger.getLogger(CXFWebServiceContainerFactoryGBean.class.getName());
+ private static final Log LOG = LogFactory.getLog(CXFWebServiceContainerFactoryGBean.class);
private final PortInfo portInfo;
private final Bus bus;
private final Object endpointInstance;
private Context context;
+ private URL configurationBaseUrl;
public CXFWebServiceContainerFactoryGBean(PortInfo portInfo,
String endpointClassName,
ClassLoader classLoader,
Map componentContext,
Kernel kernel,
- TransactionManager transactionManager)
+ TransactionManager transactionManager,
+ URL configurationBaseUrl)
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
-
- GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
+
if (componentContext != null) {
+ GeronimoUserTransaction userTransaction = new GeronimoUserTransaction(transactionManager);
try {
this.context = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext,
userTransaction,
kernel,
classLoader);
} catch (NamingException e) {
- LOG.log(Level.WARNING, "Failed to create naming context", e);
+ LOG.warn("Failed to create naming context", e);
}
}
this.portInfo = portInfo;
this.bus = (new CXFBusFactory()).createBus();
+ this.configurationBaseUrl = configurationBaseUrl;
+
Class endpointClass = classLoader.loadClass(endpointClassName);
endpointInstance = endpointClass.newInstance();
}
public WebServiceContainer getWebServiceContainer() {
- return new CXFWebServiceContainer(portInfo, endpointInstance, bus, context);
+ return new CXFWebServiceContainer(portInfo, endpointInstance, bus, context, configurationBaseUrl);
}
public static final GBeanInfo GBEAN_INFO;
@@ -89,9 +93,10 @@
infoBuilder.addAttribute("componentContext", Map.class, true, true);
infoBuilder.addAttribute("kernel", Kernel.class, false);
infoBuilder.addReference("TransactionManager", TransactionManager.class, NameFactory.TRANSACTION_MANAGER);
+ infoBuilder.addAttribute("configurationBaseUrl", URL.class, true);
infoBuilder.setConstructor(new String[]{"portInfo", "endpointClassName", "classLoader",
- "componentContext", "kernel", "TransactionManager"});
+ "componentContext", "kernel", "TransactionManager", "configurationBaseUrl"});
GBEAN_INFO = infoBuilder.getBeanInfo();
}
Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoDestination.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoDestination.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoDestination.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/GeronimoDestination.java Fri Jan 26 13:10:31 2007
@@ -23,18 +23,15 @@
import java.net.HttpURLConnection;
import java.util.Iterator;
import java.util.ArrayList;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Enumeration;
-import java.util.StringTokenizer;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.handler.MessageContext;
import org.apache.cxf.Bus;
-import org.apache.cxf.message.Exchange;
import org.apache.cxf.message.Message;
import org.apache.cxf.message.MessageImpl;
import org.apache.cxf.service.model.EndpointInfo;
@@ -44,7 +41,6 @@
import org.apache.cxf.transport.MessageObserver;
import org.apache.cxf.transport.http.AbstractHTTPDestination;
import org.apache.cxf.ws.addressing.EndpointReferenceType;
-import org.apache.cxf.wsdl.EndpointReferenceUtils;
import org.apache.geronimo.webservices.WebServiceContainer;
import org.apache.geronimo.webservices.WebServiceContainer.Request;
import org.apache.geronimo.webservices.WebServiceContainer.Response;
Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResourceResolver.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResourceResolver.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResourceResolver.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/JNDIResourceResolver.java Fri Jan 26 13:10:31 2007
@@ -1,73 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.cxf;
-
-import java.io.InputStream;
-import java.util.logging.Logger;
-import java.util.logging.Level;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.cxf.Bus;
-import org.apache.cxf.resource.ResourceResolver;
-
-import org.apache.geronimo.naming.java.RootContext;
-
-public class JNDIResourceResolver implements ResourceResolver {
-
- private static final Logger LOG =
- Logger.getLogger(JNDIResourceResolver.class.getName());
-
- private Context componentContext;
-
- public JNDIResourceResolver(Context context) {
- this.componentContext = context;
- }
-
- public final InputStream getAsStream(final String string) {
- return null;
- }
-
- public final <T> T resolve(final String name, final Class<T> clz) {
- // Ignore those
- if ( ("bus".equals(name) && clz.equals(Bus.class)) ||
- ("mtomEnabled".equals(name) && clz.equals(boolean.class)) ) {
- return null;
- }
-
- Context oldContext = RootContext.getComponentContext();
- try {
- RootContext.setComponentContext(componentContext);
-
- Context ctx = new InitialContext();
- ctx = (Context)ctx.lookup("java:comp/env");
-
- LOG.fine("Looking up '" + name + "'");
-
- Object o = ctx.lookup(name);
-
- return clz.cast(o);
-
- } catch (NamingException e) {
- LOG.log(Level.FINE, "JNDI lookup failed", e);
- return null;
- } finally {
- RootContext.setComponentContext(oldContext);
- }
- }
-}
Modified: geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java (original)
+++ geronimo/server/trunk/modules/geronimo-cxf/src/main/java/org/apache/geronimo/cxf/PortInfo.java Fri Jan 26 13:10:31 2007
@@ -17,70 +17,176 @@
package org.apache.geronimo.cxf;
import java.io.Serializable;
-import java.util.List;
+import java.io.StringReader;
+import java.io.StringWriter;
-import org.apache.cxf.jaxws.javaee.PortComponentHandlerType;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.cxf.jaxws.javaee.HandlerChainsType;
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
public class PortInfo implements Serializable {
private String serviceName;
+
private String portName;
+
private String seiInterfaceName;
+
private String wsdlFile;
+
private String servletLink;
- // TODO: will have to construct handlers when the container becomes active
- //
- private List<PortComponentHandlerType> handlers;
-
+
+ private String handlersAsXML;
+
+ private boolean mtomEnabled;
+
+ private String binding;
+
+ private QName wsdlPort;
+
+ private QName wsdlService;
+
+ private String location;
+
public String getPortName() {
return portName;
}
+
public void setPortName(String pn) {
portName = pn;
}
+
public String getServiceEndpointInterfaceName() {
return seiInterfaceName;
}
+
public void setServiceEndpointInterfaceName(String sei) {
seiInterfaceName = sei;
}
- public String getServletLink() {
+
+ public String getServiceLink() {
return servletLink;
}
- public void setServletLink(String sl) {
+
+ public void setServiceLink(String sl) {
servletLink = sl;
}
+
public String getWsdlFile() {
return wsdlFile;
}
+
public void setWsdlFile(String wf) {
wsdlFile = wf;
}
-
- public void setHandlers(List<PortComponentHandlerType> h) {
- handlers = h;
+
+ public String getServiceName() {
+ return serviceName;
}
-
- public List<PortComponentHandlerType> getHandlers() {
- return handlers;
+
+ public void setServiceName(String sn) {
+ serviceName = sn;
+ }
+
+ public void setEnableMTOM(boolean mtomEnabled) {
+ this.mtomEnabled = mtomEnabled;
+ }
+
+ public boolean isMTOMEnabled() {
+ return this.mtomEnabled;
+ }
+
+ public void setProtocolBinding(String binding) {
+ this.binding = binding;
}
+
+ public String getProtocolBinding() {
+ return binding;
+ }
+
+ /*
+ * This is a bit tricky here since JAXB generated classes are not serializable,
+ * so serialize the handler chain to XML and pass it as a String.
+ */
- public String getServiceName() {
- return serviceName;
+ public void setHandlers(HandlerChainsType handlerChain) throws Exception {
+ if (handlerChain == null) {
+ return;
+ }
+
+ JAXBContext ctx = JAXBContext.newInstance(HandlerChainsType.class);
+ Marshaller m = ctx.createMarshaller();
+ StringWriter writer = new StringWriter();
+ /*
+ * Since HandlerChainsType is a type, have to wrap it into some element
+ */
+ QName rootElement = new QName("", "root");
+ JAXBElement element = new JAXBElement(rootElement,
+ HandlerChainsType.class, handlerChain);
+ m.marshal(element, writer);
+
+ this.handlersAsXML = writer.toString();
+ }
+
+ public HandlerChainsType getHandlers() throws Exception {
+ if (this.handlersAsXML == null) {
+ return null;
+ }
+
+ InputSource is = new InputSource(new StringReader(this.handlersAsXML));
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document doc = db.parse(is);
+
+ JAXBContext ctx = JAXBContext.newInstance(HandlerChainsType.class);
+ Unmarshaller unmarshaller = ctx.createUnmarshaller();
+
+ JAXBElement<HandlerChainsType> handlerElement = unmarshaller.unmarshal(
+ doc.getDocumentElement(), HandlerChainsType.class);
+
+ return handlerElement.getValue();
+ }
+
+ public QName getWsdlPort() {
+ return wsdlPort;
+ }
+
+ public void setWsdlPort(QName wsdlPort) {
+ this.wsdlPort = wsdlPort;
+ }
+
+ public QName getWsdlService() {
+ return wsdlService;
+ }
+
+ public void setWsdlService(QName wsdlService) {
+ this.wsdlService = wsdlService;
}
- public void setServiceName(String sn) {
- serviceName = sn;
+ public String getLocation() {
+ return location;
}
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
/*
- private String serviceName;
- private String portName;
- private String seiInterfaceName;
- private String wsdlFile;
- private String servletLink;
+ * private String serviceName; private String portName; private String
+ * seiInterfaceName; private String wsdlFile; private String servletLink;
*/
public String toString() {
- return "[" + serviceName + ":" + portName + ":" + seiInterfaceName + ":" + wsdlFile + "]";
+ return "[" + serviceName + ":" + portName + ":" + seiInterfaceName
+ + ":" + wsdlFile + "]";
}
}
Modified: geronimo/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/pom.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/pom.xml (original)
+++ geronimo/server/trunk/pom.xml Fri Jan 26 13:10:31 2007
@@ -77,6 +77,8 @@
HACK: Used by uddi-jetty and uddi-tomcat config plans
-->
<tranqlVendorsVersion>1.2</tranqlVendorsVersion>
+
+ <cxfVersion>2.0-incubator-M1</cxfVersion>
</properties>
<dependencyManagement>
@@ -903,7 +905,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -919,7 +921,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-metacode</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -935,7 +937,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-common-utilities</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -951,7 +953,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -967,7 +969,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-xml</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -983,7 +985,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-bindings-soap</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -999,7 +1001,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -1015,7 +1017,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -1031,7 +1033,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-simple</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -1047,7 +1049,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
@@ -1063,7 +1065,7 @@
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-tools-common</artifactId>
- <version>2.0-incubator-M1</version>
+ <version>${cxfVersion}</version>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/pom.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/pom.xml (original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/pom.xml Fri Jan 26 13:10:31 2007
@@ -62,6 +62,12 @@
</dependencies>
<build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ </resource>
+ </resources>
+
<plugins>
<plugin>
<groupId>org.apache.geronimo.plugins</groupId>
Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/Greeter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/Greeter.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/Greeter.java (original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/Greeter.java Fri Jan 26 13:10:31 2007
@@ -36,8 +36,6 @@
@WebService(targetNamespace = "http://apache.org/hello_world_soap_http", name = "Greeter")
public interface Greeter {
- @ResponseWrapper(targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.GreetMeResponse", localName = "greetMeResponse")
- @RequestWrapper(targetNamespace = "http://apache.org/hello_world_soap_http/types", className = "org.apache.hello_world_soap_http.types.GreetMe", localName = "greetMe")
@WebResult(targetNamespace = "http://apache.org/hello_world_soap_http/types", name = "responseType")
@WebMethod(operationName = "greetMe")
public java.lang.String greetMe(
Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java (original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java Fri Jan 26 13:10:31 2007
@@ -19,22 +19,27 @@
package org.apache.hello_world_soap_http;
-
-import java.io.IOException;
-import java.util.concurrent.Future;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.Map;
import java.util.logging.Logger;
import javax.annotation.Resource;
+import javax.annotation.PreDestroy;
+import javax.annotation.PostConstruct;
import javax.jws.WebService;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
+import javax.jws.HandlerChain;
import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+/* serviceName, portName specified in webservices.xml */
@WebService(serviceName = "SOAPService",
portName = "SoapPort",
endpointInterface = "org.apache.hello_world_soap_http.Greeter",
- targetNamespace = "http://apache.org/hello_world_soap_http")
+ targetNamespace = "http://apache.org/greeter_control")
+/* two handlers specified in webservices.xml */
+@HandlerChain(file="handlers.xml")
public class GreeterImpl implements Greeter {
private static final Logger LOG =
@@ -53,9 +58,43 @@
public String greetMe(String me) {
LOG.info("Invoking greetMe " + me);
+ LOG.info("WebServiceContext: " + context);
LOG.info("Principal: " + context.getUserPrincipal());
LOG.info("Context: " + context.getMessageContext());
+
+ MessageContext ctx = context.getMessageContext();
+ Iterator iter = ctx.entrySet().iterator();
+ while(iter.hasNext()) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ System.out.println("Key: "+entry.getKey());
+ System.out.println("Value: " +entry.getValue());
+ }
+
+ // just playing around
+
+ // send foo=BAR header
+ Map responseHeaders =
+ (Map)ctx.get(MessageContext.HTTP_RESPONSE_HEADERS);
+ ArrayList values = new ArrayList();
+ values.add("BAR");
+ responseHeaders.put("foo", values);
+ /*
+ // make return code 201
+ ctx.put(MessageContext.HTTP_RESPONSE_CODE,
+ new Integer(201));
+ */
+
return greeting + " " + me;
+ }
+
+ @PostConstruct
+ public void init() {
+ System.out.println(this + " PostConstruct");
+ }
+
+ @PreDestroy()
+ public void destroy() {
+ System.out.println(this + " PreDestroy");
}
}
Modified: geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/webapp/WEB-INF/webservices.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/webapp/WEB-INF/webservices.xml?view=diff&rev=500348&r1=500347&r2=500348
==============================================================================
--- geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/webapp/WEB-INF/webservices.xml (original)
+++ geronimo/server/trunk/testsuite/webservices-testsuite/jaxws-tests/jaxws-war/src/main/webapp/WEB-INF/webservices.xml Fri Jan 26 13:10:31 2007
@@ -22,20 +22,35 @@
<webservices xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:greeter="http://apache.org/greeter_control"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/javaee_web_services_1_2.xsd"
version="1.2">
<webservice-description>
<webservice-description-name>POJO WS</webservice-description-name>
- <wsdl-file>WEB-INF/wsdl/greeter_control.wsdl</wsdl-file>
+ <!--<wsdl-file>WEB-INF/wsdl/greeter_control.wsdl</wsdl-file>-->
+ <wsdl-file></wsdl-file>
<port-component>
<port-component-name>POJOPort</port-component-name>
- <wsdl-service></wsdl-service>
+ <wsdl-service>greeter:GreeterService</wsdl-service>
+ <wsdl-port>greeter:GreeterPort</wsdl-port>
<enable-mtom>false</enable-mtom>
<service-endpoint-interface>org.apache.hello_world_soap_http.Greeter</service-endpoint-interface>
<service-impl-bean>
<servlet-link>POJOServlet</servlet-link>
</service-impl-bean>
+ <handler-chains>
+ <handler-chain>
+ <handler>
+ <handler-name>GreeterHandler1</handler-name>
+ <handler-class>org.apache.hello_world_soap_http.GreeterHandler</handler-class>
+ </handler>
+ <handler>
+ <handler-name>GreeterHandler2</handler-name>
+ <handler-class>org.apache.hello_world_soap_http.GreeterHandler</handler-class>
+ </handler>
+ </handler-chain>
+ </handler-chains>
</port-component>
</webservice-description>