You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2011/05/06 08:10:55 UTC
svn commit: r1100081 - in /geronimo/server/trunk/plugins:
cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/
myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/
Author: xuhaihong
Date: Fri May 6 06:10:54 2011
New Revision: 1100081
URL: http://svn.apache.org/viewvc?rev=1100081&view=rev
Log:
GERONIMO-5839 Also add module prefix for EJB webservice when the EJB is embedded in the web application
GERONIMO-5839 Workaround for WSDL path in EAR package
Modified:
geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoWebXml.java
Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java?rev=1100081&r1=1100080&r2=1100081&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java (original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFBuilder.java Fri May 6 06:10:54 2011
@@ -52,6 +52,7 @@ import org.apache.geronimo.jaxws.builder
import org.apache.geronimo.jaxws.builder.WARWebServiceFinder;
import org.apache.geronimo.jaxws.builder.wsdl.WsdlGenerator;
import org.apache.geronimo.jaxws.builder.wsdl.WsdlGeneratorOptions;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.repository.Environment;
import org.osgi.framework.Bundle;
import org.slf4j.Logger;
@@ -60,6 +61,8 @@ import org.slf4j.LoggerFactory;
public class CXFBuilder extends JAXWSServiceBuilder {
private static final Logger LOG = LoggerFactory.getLogger(CXFBuilder.class);
+ private static final boolean ignoreEmptyWebServiceProviderWSDL = Boolean.getBoolean("org.apache.geronimo.webservice.provider.wsdl.ignore");
+
/**
* This property if enabled will cause the Sun wsgen tool to be used to
* generate the WSDL for servies without WSDL. By default CXF tooling
@@ -88,10 +91,12 @@ public class CXFBuilder extends JAXWSSer
URL wsDDUrl,
Deployable deployable,
boolean isEJB,
- Map correctedPortLocations)
+ Map<String, String> correctedPortLocations)
throws DeploymentException {
- LOG.debug("Parsing descriptor " + wsDDUrl);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parsing descriptor " + wsDDUrl);
+ }
Map<String, PortInfo> map = null;
@@ -156,7 +161,7 @@ public class CXFBuilder extends JAXWSSer
portInfo.setWsdlService(port.getWsdlService().getValue());
}
- String location = (String) correctedPortLocations.get(serviceLink);
+ String location = correctedPortLocations.get(serviceLink);
portInfo.setLocation(location);
if (map == null) {
@@ -194,6 +199,21 @@ public class CXFBuilder extends JAXWSSer
return in;
}
+ private boolean isURL(String name) {
+ try {
+ new URL(name);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private boolean isWSDLNormalizedRequired(Module module, String wsdlLocation) {
+ return (module.getType().equals(ConfigurationModuleType.WAR) || (module.getType().equals(ConfigurationModuleType.EJB) && module.getParentModule() != null && module.getParentModule().getType()
+ .equals(ConfigurationModuleType.WAR)))
+ && !isURL(wsdlLocation);
+ }
+
@Override
protected void initialize(GBeanData targetGBean, Class serviceClass, PortInfo portInfo, Module module, Bundle bundle) throws DeploymentException {
if (Boolean.getBoolean(USE_WSGEN_PROPERTY)) {
@@ -212,21 +232,37 @@ public class CXFBuilder extends JAXWSSer
private void generateWSDL(Class serviceClass, PortInfo portInfo, Module module, Bundle bundle)
throws DeploymentException {
String serviceName = (portInfo.getServiceName() == null ? serviceClass.getName() : portInfo.getServiceName());
+ String wsdlFile = portInfo.getWsdlFile();
if (isWsdlSet(portInfo, serviceClass, bundle)) {
- LOG.debug("Service " + serviceName + " has WSDL.");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Service " + serviceName + " has WSDL.");
+ }
+ if (isWSDLNormalizedRequired(module, wsdlFile)) {
+ portInfo.setWsdlFile(module.getTargetPathURI().resolve(wsdlFile).toString());
+ }
return;
}
if (isHTTPBinding(portInfo, serviceClass)) {
- LOG.debug("Service " + serviceName + " has HTTPBinding.");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Service " + serviceName + " has HTTPBinding.");
+ }
return;
}
if (JAXWSUtils.isWebServiceProvider(serviceClass)) {
- throw new DeploymentException("WSDL must be specified for @WebServiceProvider service " + serviceName);
+ if (ignoreEmptyWebServiceProviderWSDL) {
+ LOG.warn("WSDL is not specified for @WebServiceProvider service " + serviceName);
+ //TODO Generate a dummy WSDL for it ?
+ return;
+ } else {
+ throw new DeploymentException("WSDL must be specified for @WebServiceProvider service " + serviceName);
+ }
}
- LOG.debug("Service " + serviceName + " does not have WSDL. Generating WSDL...");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Service " + serviceName + " does not have WSDL. Generating WSDL...");
+ }
WsdlGenerator wsdlGenerator = getWsdlGenerator();
@@ -247,10 +283,11 @@ public class CXFBuilder extends JAXWSSer
options.setWsdlPort(portInfo.getWsdlPort());
}
- String wsdlFile = wsdlGenerator.generateWsdl(module, serviceClass.getName(), module.getEarContext(), options);
+ wsdlFile = wsdlGenerator.generateWsdl(module, serviceClass.getName(), module.getEarContext(), options);
portInfo.setWsdlFile(wsdlFile);
-
- LOG.debug("Generated " + wsdlFile + " for service " + serviceName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Generated " + wsdlFile + " for service " + serviceName);
+ }
}
public static final GBeanInfo GBEAN_INFO;
Modified: geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java?rev=1100081&r1=1100080&r2=1100081&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java (original)
+++ geronimo/server/trunk/plugins/cxf/geronimo-cxf-builder/src/main/java/org/apache/geronimo/cxf/builder/CXFServiceRefBuilder.java Fri May 6 06:10:54 2011
@@ -22,6 +22,7 @@ import java.util.Map;
import javax.xml.bind.JAXBException;
import javax.xml.namespace.QName;
+
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.cxf.client.CXFServiceReference;
import org.apache.geronimo.gbean.GBeanInfo;
@@ -31,6 +32,7 @@ import org.apache.geronimo.j2ee.j2eeobje
import org.apache.geronimo.jaxws.builder.EndpointInfoBuilder;
import org.apache.geronimo.jaxws.builder.JAXWSServiceRefBuilder;
import org.apache.geronimo.jaxws.client.EndpointInfo;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.repository.Environment;
import org.apache.geronimo.naming.deployment.ServiceRefBuilder;
import org.apache.geronimo.xbeans.geronimo.naming.GerServiceRefType;
@@ -58,8 +60,12 @@ public class CXFServiceRefBuilder extend
gerServiceRef, portComponentRefMap, module, bundle,
wsdlURI, serviceQName);
builder.build();
-
wsdlURI = builder.getWsdlURI();
+
+ //TODO For non standalone web application, it is embbed of directory style in the EAR package
+ if (isWSDLNormalizedRequired(module, wsdlURI)) {
+ wsdlURI = module.getTargetPathURI().resolve(wsdlURI);
+ }
serviceQName = builder.getServiceQName();
Map<Object, EndpointInfo> seiInfoMap = builder.getEndpointInfo();
@@ -76,6 +82,21 @@ public class CXFServiceRefBuilder extend
return new CXFServiceReference(serviceInterface.getName(), serviceReferenceName, wsdlURI, serviceQName, module.getModuleName(), handlerChainsXML, seiInfoMap);
}
+ private boolean isURL(URI name) {
+ try {
+ name.toURL();
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ private boolean isWSDLNormalizedRequired(Module module, URI wsdlLocation) {
+ return (module.getType().equals(ConfigurationModuleType.WAR) || (module.getType().equals(ConfigurationModuleType.EJB) && module.getParentModule() != null && module.getParentModule().getType()
+ .equals(ConfigurationModuleType.WAR)))
+ && !isURL(wsdlLocation);
+ }
+
public static final GBeanInfo GBEAN_INFO;
static {
Modified: geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoWebXml.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoWebXml.java?rev=1100081&r1=1100080&r2=1100081&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoWebXml.java (original)
+++ geronimo/server/trunk/plugins/myfaces/geronimo-myfaces/src/main/java/org/apache/geronimo/myfaces/webapp/GeronimoWebXml.java Fri May 6 06:10:54 2011
@@ -42,7 +42,7 @@ public class GeronimoWebXml extends WebX
private List<FilterMapping> facesExtensionsFilterMapppings;
private boolean errorPagePresent;
-
+
//TODO remove once upgrade to MyFaces 2.0.3
private String delegateFacesServlet;
@@ -50,13 +50,14 @@ public class GeronimoWebXml extends WebX
errorPagePresent = webAppInfo.errorPages != null && webAppInfo.errorPages.size() > 0;
this.delegateFacesServlet = delegateFacesServlet;
facesServletMappings = new ArrayList<ServletMapping>();
+ ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
for (ServletInfo servletInfo : webAppInfo.servlets) {
if (servletInfo.servletClass == null) {
continue;
}
Class<?> servletClass;
try {
- servletClass = bundle.loadClass(servletInfo.servletClass);
+ servletClass = contextClassLoader.loadClass(servletInfo.servletClass);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not load the servlet class " + servletInfo.servletClass, e);
}
@@ -69,7 +70,7 @@ public class GeronimoWebXml extends WebX
for (FilterInfo filterInfo : webAppInfo.filters) {
Class<?> filterClass;
try {
- filterClass = bundle.loadClass(filterInfo.filterClass);
+ filterClass = contextClassLoader.loadClass(filterInfo.filterClass);
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not load the filter class " + filterInfo.filterClass, e);
}
@@ -97,8 +98,8 @@ public class GeronimoWebXml extends WebX
@Override
public boolean isErrorPagePresent() {
return errorPagePresent;
- }
-
+ }
+
//TODO remove once upgrade to MyFaces 2.0.3
protected boolean isFacesServlet(Class<?> servletClass) {
return FacesServlet.class.isAssignableFrom(servletClass) || DelegatedFacesServlet.class.isAssignableFrom(servletClass) || servletClass.getName().equals(delegateFacesServlet);