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/04/14 15:11:34 UTC
svn commit: r1092215 - in /geronimo/server/trunk/plugins:
j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/
jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/
jaxws/geronimo-jaxws-ejb-builder/s...
Author: xuhaihong
Date: Thu Apr 14 13:11:33 2011
New Revision: 1092215
URL: http://svn.apache.org/viewvc?rev=1092215&view=rev
Log:
GERONIMO-5902 Ignore web service from web application side if it is also an EJB web service
Added:
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWARWebServiceFinder.java
- copied, changed from r1084826, geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java
Removed:
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java
Modified:
geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java
geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java
geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
Modified: geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-web-2.5-builder/src/main/java/org/apache/geronimo/web25/deployment/AbstractWebModuleBuilder.java Thu Apr 14 13:11:33 2011
@@ -410,29 +410,29 @@ public abstract class AbstractWebModuleB
}
}
- protected abstract void preInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException;
+ protected abstract void preInitContext(EARContext earContext, WebModule module, Bundle bundle) throws DeploymentException;
- protected abstract void postInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException;
+ protected abstract void postInitContext(EARContext earContext, WebModule module, Bundle bundle) throws DeploymentException;
@Override
public void initContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
- preInitContext(earContext, module, bundle);
- basicInitContext(earContext, module, bundle, (XmlObject) module.getVendorDD());
- postInitContext(earContext, module, bundle);
+ WebModule webModule = (WebModule)module;
+ preInitContext(earContext, webModule, bundle);
+ basicInitContext(earContext, webModule, bundle, (XmlObject) module.getVendorDD());
+ postInitContext(earContext, webModule, bundle);
}
- protected void basicInitContext(EARContext earContext, Module module, Bundle bundle, XmlObject gerWebApp) throws DeploymentException {
- WebModule webModule = (WebModule) module;
+ protected void basicInitContext(EARContext earContext, WebModule webModule, Bundle bundle, XmlObject gerWebApp) throws DeploymentException {
//complete manifest classpath
EARContext moduleContext = webModule.getEarContext();
- Collection<String> manifestcp = module.getClassPath();
+ Collection<String> manifestcp = webModule.getClassPath();
Collection<String> moduleLocations = EARContext.MODULE_LIST_KEY.get(webModule.getRootEarContext().getGeneralData());
URI baseUri = URI.create(webModule.getTargetPath());
URI resolutionUri = invertURI(baseUri);
earContext.getCompleteManifestClassPath(webModule.getDeployable(), baseUri, resolutionUri, manifestcp, moduleLocations);
//Security Configuration Validation
WebApp webApp = webModule.getSpecDD();
- boolean hasSecurityRealmName = (Boolean) module.getEarContext().getGeneralData().get(WEB_MODULE_HAS_SECURITY_REALM);
+ boolean hasSecurityRealmName = (Boolean) webModule.getEarContext().getGeneralData().get(WEB_MODULE_HAS_SECURITY_REALM);
if ((!webApp.getSecurityConstraint().isEmpty() || !webApp.getSecurityRole().isEmpty())) {
if (!hasSecurityRealmName) {
throw new DeploymentException("web.xml for web app " + webModule.getName()
@@ -453,7 +453,7 @@ public abstract class AbstractWebModuleB
getNamingBuilders().initContext(webApp, gerWebApp, webModule);
float originalSpecDDVersion;
- String originalSpecDD = module.getOriginalSpecDD();
+ String originalSpecDD = webModule.getOriginalSpecDD();
if (originalSpecDD == null) {
originalSpecDDVersion = 3.0f;
} else {
@@ -464,17 +464,7 @@ public abstract class AbstractWebModuleB
if (INITIAL_WEB_XML_SCHEMA_VERSION.get(earContext.getGeneralData()) >= 2.5f && !webApp.isMetadataComplete()) {
MergeHelper.processWebFragmentsAndAnnotations(earContext, webModule, bundle, webApp);
}
- //TODO From my understanding, whether we scan ServletContainerInitializer has nothing to do with meta-complete/web.xml schema version
- //Might need double-check !
MergeHelper.processServletContainerInitializer(earContext, webModule, bundle);
-
- //web.xml should now list all the classes we need to create instances of.
- //Process Web Service
- Map<String, String> servletNameToPathMap = buildServletNameToPathMap(webModule.getSpecDD(), webModule.getContextRoot());
- Map sharedContext = webModule.getSharedContext();
- for (WebServiceBuilder serviceBuilder : webServiceBuilder) {
- serviceBuilder.findWebServices(webModule, false, servletNameToPathMap, webModule.getEnvironment(), sharedContext);
- }
serviceBuilders.build(gerWebApp, earContext, webModule.getEarContext());
}
Copied: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWARWebServiceFinder.java (from r1084826, geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWARWebServiceFinder.java?p2=geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWARWebServiceFinder.java&p1=geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java&r1=1084826&r2=1092215&rev=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AbstractWARWebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -24,7 +24,10 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
@@ -36,6 +39,8 @@ import org.apache.geronimo.deployment.De
import org.apache.geronimo.deployment.DeployableBundle;
import org.apache.geronimo.deployment.DeployableJarFile;
import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.WebModule;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.geronimo.kernel.util.FileUtils;
import org.apache.geronimo.kernel.util.JarUtils;
import org.apache.geronimo.kernel.util.NestedJarFile;
@@ -52,20 +57,36 @@ import org.slf4j.LoggerFactory;
/**
* @version $Rev$ $Date$
*/
-public abstract class AbstractWebServiceFinder implements WebServiceFinder {
+public abstract class AbstractWARWebServiceFinder implements WebServiceFinder<WebModule> {
- private static final Logger logger = LoggerFactory.getLogger(AbstractWebServiceFinder.class);
+ private static final Logger logger = LoggerFactory.getLogger(AbstractWARWebServiceFinder.class);
+
+ protected Set<String> getEJBWebServiceClassNames(Module module) {
+ if (module.getModules().size() == 0) {
+ return Collections.<String> emptySet();
+ }
+ Set<String> ejbWebServiceClassNames = new HashSet<String>();
+ for (Module subModule : (LinkedHashSet<Module<?, ?>>) module.getModules()) {
+ if (subModule.getType() == ConfigurationModuleType.EJB) {
+ Set<String> currentEJBWebServiceClassNames = (Set<String>) subModule.getSharedContext().get(EJB_WEB_SERVICE_CLASS_NAMES);
+ if (ejbWebServiceClassNames != null) {
+ ejbWebServiceClassNames.addAll(currentEJBWebServiceClassNames);
+ }
+ }
+ }
+ return ejbWebServiceClassNames;
+ }
/**
* Returns a list of any classes annotated with @WebService or
* @WebServiceProvider annotation.
*/
- protected List<Class<?>> discoverWebServices(Module module, boolean isEJB) throws DeploymentException {
+ protected List<Class<?>> discoverWebServices(WebModule module) throws DeploymentException {
Deployable deployable = module.getDeployable();
if (deployable instanceof DeployableJarFile) {
- return discoverWebServices(((DeployableJarFile) deployable).getJarFile(), isEJB, AbstractWebServiceFinder.class.getClassLoader());
+ return discoverWebServices(((DeployableJarFile) deployable).getJarFile(), AbstractWARWebServiceFinder.class.getClassLoader());
} else if (deployable instanceof DeployableBundle) {
- return discoverWebServices(((DeployableBundle) deployable).getBundle(), isEJB);
+ return discoverWebServices(((DeployableBundle) deployable).getBundle());
} else {
throw new DeploymentException("Unsupported deployable: " + deployable.getClass());
}
@@ -75,7 +96,7 @@ public abstract class AbstractWebService
* Returns a list of any classes annotated with @WebService or
* @WebServiceProvider annotation.
*/
- private List<Class<?>> discoverWebServices(Bundle bundle, boolean isEJB) throws DeploymentException {
+ private List<Class<?>> discoverWebServices(Bundle bundle) throws DeploymentException {
logger.debug("Discovering web service classes");
ServiceReference sr = bundle.getBundleContext().getServiceReference(PackageAdmin.class.getName());
@@ -98,73 +119,64 @@ public abstract class AbstractWebService
* @WebServiceProvider annotation.
*/
@Deprecated
- private List<Class<?>> discoverWebServices(JarFile moduleFile, boolean isEJB, ClassLoader parentClassLoader) throws DeploymentException {
+ private List<Class<?>> discoverWebServices(JarFile moduleFile, ClassLoader parentClassLoader) throws DeploymentException {
logger.debug("Discovering web service classes");
File tmpDir = null;
List<URL> urlList = new ArrayList<URL>();
- if (isEJB) {
- File jarFile = new File(moduleFile.getName());
- try {
- urlList.add(jarFile.toURI().toURL());
- } catch (MalformedURLException e) {
- // this should not happen
- throw new DeploymentException(e);
- }
- } else {
- File baseDir;
- if (moduleFile instanceof UnpackedJarFile) {
- // war directory is being deployed (--inPlace)
- baseDir = ((UnpackedJarFile) moduleFile).getBaseDir();
- } else if (moduleFile instanceof NestedJarFile && ((NestedJarFile) moduleFile).isUnpacked()) {
- // ear directory is being deployed (--inPlace)
- baseDir = new File(moduleFile.getName());
- } else {
- // war file or ear file is being deployed
+ File baseDir;
+
+ if (moduleFile instanceof UnpackedJarFile) {
+ // war directory is being deployed (--inPlace)
+ baseDir = ((UnpackedJarFile) moduleFile).getBaseDir();
+ } else if (moduleFile instanceof NestedJarFile && ((NestedJarFile) moduleFile).isUnpacked()) {
+ // ear directory is being deployed (--inPlace)
+ baseDir = new File(moduleFile.getName());
+ } else {
+ // war file or ear file is being deployed
+ /*
+ * Can't get ClassLoader to load nested Jar files, so
+ * unpack the module Jar file and discover all nested Jar files
+ * within it and the classes/ directory.
+ */
+ try {
+ tmpDir = FileUtils.createTempDir();
/*
- * Can't get ClassLoader to load nested Jar files, so
- * unpack the module Jar file and discover all nested Jar files
- * within it and the classes/ directory.
+ * This is needed becuase JarUtils.unzipToDirectory()
+ * always closes the passed JarFile.
*/
- try {
- tmpDir = FileUtils.createTempDir();
- /*
- * This is needed becuase JarUtils.unzipToDirectory()
- * always closes the passed JarFile.
- */
- JarFile module = new JarFile(moduleFile.getName());
- JarUtils.unzipToDirectory(module, tmpDir);
- } catch (IOException e) {
- if (tmpDir != null) {
- FileUtils.recursiveDelete(tmpDir);
- }
- throw new DeploymentException("Failed to expand the module archive", e);
+ JarFile module = new JarFile(moduleFile.getName());
+ JarUtils.unzipToDirectory(module, tmpDir);
+ } catch (IOException e) {
+ if (tmpDir != null) {
+ FileUtils.recursiveDelete(tmpDir);
}
-
- baseDir = tmpDir;
+ throw new DeploymentException("Failed to expand the module archive", e);
}
- // create URL list
- Enumeration<JarEntry> jarEnum = moduleFile.entries();
- while (jarEnum.hasMoreElements()) {
- JarEntry entry = jarEnum.nextElement();
- String name = entry.getName();
- if (name.equals("WEB-INF/classes/")) {
- // ensure it is first
- File classesDir = new File(baseDir, "WEB-INF/classes/");
- try {
- urlList.add(0, classesDir.toURI().toURL());
- } catch (MalformedURLException e) {
- // this should not happen, ignore
- }
- } else if (name.startsWith("WEB-INF/lib/") && name.endsWith(".jar")) {
- File jarFile = new File(baseDir, name);
- try {
- urlList.add(jarFile.toURI().toURL());
- } catch (MalformedURLException e) {
- // this should not happen, ignore
- }
+ baseDir = tmpDir;
+ }
+
+ // create URL list
+ Enumeration<JarEntry> jarEnum = moduleFile.entries();
+ while (jarEnum.hasMoreElements()) {
+ JarEntry entry = jarEnum.nextElement();
+ String name = entry.getName();
+ if (name.equals("WEB-INF/classes/")) {
+ // ensure it is first
+ File classesDir = new File(baseDir, "WEB-INF/classes/");
+ try {
+ urlList.add(0, classesDir.toURI().toURL());
+ } catch (MalformedURLException e) {
+ // this should not happen, ignore
+ }
+ } else if (name.startsWith("WEB-INF/lib/") && name.endsWith(".jar")) {
+ File jarFile = new File(baseDir, name);
+ try {
+ urlList.add(jarFile.toURI().toURL());
+ } catch (MalformedURLException e) {
+ // this should not happen, ignore
}
}
}
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/AdvancedWARWebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -18,15 +18,20 @@
package org.apache.geronimo.jaxws.builder;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.geronimo.common.DeploymentException;
import org.apache.geronimo.j2ee.deployment.Module;
import org.apache.geronimo.j2ee.deployment.WebModule;
import org.apache.geronimo.jaxws.JAXWSUtils;
import org.apache.geronimo.jaxws.PortInfo;
+import org.apache.geronimo.kernel.config.ConfigurationModuleType;
import org.apache.openejb.jee.Servlet;
import org.apache.openejb.jee.ServletMapping;
import org.apache.openejb.jee.WebApp;
@@ -34,25 +39,23 @@ import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class AdvancedWARWebServiceFinder extends AbstractWebServiceFinder {
+public class AdvancedWARWebServiceFinder extends AbstractWARWebServiceFinder {
private static final Logger LOG = LoggerFactory.getLogger(AdvancedWARWebServiceFinder.class);
@Override
- public Map<String, PortInfo> discoverWebServices(Module module, Map<String, String> correctedPortLocations)
- throws DeploymentException {
+ public Map<String, PortInfo> discoverWebServices(WebModule module, Map<String, String> correctedPortLocations) throws DeploymentException {
Map<String, PortInfo> servletNamePortInfoMap = new HashMap<String, PortInfo>();
discoverPOJOWebServices(module, correctedPortLocations, servletNamePortInfoMap);
return servletNamePortInfoMap;
}
- private void discoverPOJOWebServices(Module module,
- Map<String, String> portLocations,
- Map<String, PortInfo> servletNamePortInfoMap)
- throws DeploymentException {
+ private void discoverPOJOWebServices(WebModule module, Map<String, String> portLocations, Map<String, PortInfo> servletNamePortInfoMap) throws DeploymentException {
Bundle bundle = module.getEarContext().getDeploymentBundle();
- WebApp webApp = (WebApp) module.getSpecDD();
+ WebApp webApp = module.getSpecDD();
+
+ Set<String> ignoredEJBWebServiceClassNames = getEJBWebServiceClassNames(module);
if (webApp.isMetadataComplete()) {
// full web.xml, just examine all servlet entries for web services
@@ -73,14 +76,21 @@ public class AdvancedWARWebServiceFinder
// partial web.xml, discover all web service classes
Map<String, List<String>> classServletMap = createClassServetMap(webApp);
- List<Class<?>> services = discoverWebServices(module, false);
- String contextRoot = ((WebModule) module).getContextRoot();
+ List<Class<?>> services = discoverWebServices(module);
+ String contextRoot = (module).getContextRoot();
for (Class<?> service : services) {
// skip interfaces and such
if (!JAXWSUtils.isWebService(service)) {
continue;
}
+ if (ignoredEJBWebServiceClassNames.contains(service.getName())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Web service " + service.getClass().getName() + " is ignored as it is also an EJB, it will exposed as an EJB Web Service ");
+ }
+ continue;
+ }
+
if (LOG.isDebugEnabled()) {
LOG.debug("Discovered POJO Web Service class: {}", service.getName());
}
@@ -142,9 +152,7 @@ public class AdvancedWARWebServiceFinder
}
}
- private PortInfo getPortInfo(Servlet servletType,
- Bundle bundle,
- Map<String, String> portLocations) throws DeploymentException {
+ private PortInfo getPortInfo(Servlet servletType, Bundle bundle, Map<String, String> portLocations) throws DeploymentException {
PortInfo portInfo = null;
if (servletType.getServletClass() != null) {
String servletClassName = servletType.getServletClass().trim();
@@ -155,8 +163,7 @@ public class AdvancedWARWebServiceFinder
portInfo = createPortInfo(servletName, portLocations);
}
} catch (ClassNotFoundException e) {
- throw new DeploymentException("Failed to load servlet class "
- + servletClassName, e);
+ throw new DeploymentException("Failed to load servlet class " + servletClassName, e);
}
}
return portInfo;
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/JAXWSServiceBuilder.java Thu Apr 14 13:11:33 2011
@@ -21,7 +21,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map;
-
import javax.xml.ws.http.HTTPBinding;
import org.apache.geronimo.common.DeploymentException;
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/SimpleWARWebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -20,9 +20,9 @@ package org.apache.geronimo.jaxws.builde
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.j2ee.deployment.Module;
import org.apache.geronimo.j2ee.deployment.WebModule;
import org.apache.geronimo.jaxws.JAXWSUtils;
import org.apache.geronimo.jaxws.PortInfo;
@@ -33,32 +33,40 @@ import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class SimpleWARWebServiceFinder extends AbstractWebServiceFinder {
+public class SimpleWARWebServiceFinder extends AbstractWARWebServiceFinder {
private static final Logger LOG = LoggerFactory.getLogger(SimpleWARWebServiceFinder.class);
@Override
- public Map<String, PortInfo> discoverWebServices(Module module, Map<String, String> correctedPortLocations) throws DeploymentException {
+ public Map<String, PortInfo> discoverWebServices(WebModule module, Map<String, String> correctedPortLocations) throws DeploymentException {
Map<String, PortInfo> servletNamePortInfoMap = new HashMap<String, PortInfo>();
Bundle bundle = module.getEarContext().getDeploymentBundle();
- WebApp webApp = (WebApp) module.getSpecDD();
+ WebApp webApp = module.getSpecDD();
// find web services
List<Servlet> servletTypes = webApp.getServlet();
+ Set<String> ignoredEJBWebServiceClassNames = getEJBWebServiceClassNames(module);
if (webApp.getServlet().size() == 0) {
// web.xml not present (empty really), discover annotated
// classes and update DD
- List<Class<?>> services = discoverWebServices(module, false);
- String contextRoot = ((WebModule) module).getContextRoot();
+ List<Class<?>> services = discoverWebServices(module);
+ String contextRoot = (module).getContextRoot();
for (Class<?> service : services) {
// skip interfaces and such
if (!JAXWSUtils.isWebService(service)) {
continue;
}
+ if (ignoredEJBWebServiceClassNames.contains(service.getName())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Web service " + service.getClass().getName() + " is ignored as it is also an EJB, it will exposed as an EJB Web Service ");
+ }
+ continue;
+ }
+
if (LOG.isDebugEnabled()) {
LOG.debug("Discovered POJO Web Service: " + service.getName());
}
@@ -95,8 +103,7 @@ public class SimpleWARWebServiceFinder e
servletNamePortInfoMap.put(servletName, portInfo);
}
} catch (Exception e) {
- throw new DeploymentException("Failed to load servlet class "
- + servletClassName + " from bundle " + bundle, e);
+ throw new DeploymentException("Failed to load servlet class " + servletClassName + " from bundle " + bundle, e);
}
}
}
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WARWebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -18,13 +18,14 @@
package org.apache.geronimo.jaxws.builder;
import java.util.Map;
+
import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.j2ee.deployment.WebModule;
import org.apache.geronimo.jaxws.PortInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class WARWebServiceFinder implements WebServiceFinder {
+public class WARWebServiceFinder implements WebServiceFinder<WebModule> {
private static final Logger LOG = LoggerFactory.getLogger(WARWebServiceFinder.class);
@@ -46,7 +47,7 @@ public class WARWebServiceFinder impleme
}
@Override
- public Map<String, PortInfo> discoverWebServices(Module module, Map<String, String> correctedPortLocations) throws DeploymentException {
+ public Map<String, PortInfo> discoverWebServices(WebModule module, Map<String, String> correctedPortLocations) throws DeploymentException {
return webServiceFinder.discoverWebServices(module, correctedPortLocations);
}
}
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-builder/src/main/java/org/apache/geronimo/jaxws/builder/WebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -23,8 +23,10 @@ import org.apache.geronimo.common.Deploy
import org.apache.geronimo.j2ee.deployment.Module;
import org.apache.geronimo.jaxws.PortInfo;
-public interface WebServiceFinder {
+public interface WebServiceFinder<T extends Module> {
- Map<String, PortInfo> discoverWebServices(Module module, Map<String, String> correctedPortLocations) throws DeploymentException;
+ public static final String EJB_WEB_SERVICE_CLASS_NAMES = "EJB_WEB_SERVICE_CLASS_NAMES";
+
+ Map<String, PortInfo> discoverWebServices(T module, Map<String, String> correctedPortLocations) throws DeploymentException;
}
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/EJBWebServiceFinder.java Thu Apr 14 13:11:33 2011
@@ -18,10 +18,11 @@
package org.apache.geronimo.jaxws.ejb.builder;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.j2ee.deployment.Module;
import org.apache.geronimo.jaxws.JAXWSUtils;
import org.apache.geronimo.jaxws.PortInfo;
import org.apache.geronimo.jaxws.builder.WebServiceFinder;
@@ -31,22 +32,22 @@ import org.osgi.framework.Bundle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class EJBWebServiceFinder implements WebServiceFinder {
+public class EJBWebServiceFinder implements WebServiceFinder<EjbModule> {
private static final Logger LOG = LoggerFactory.getLogger(EJBWebServiceFinder.class);
- public Map<String, PortInfo> discoverWebServices(Module module, Map<String, String> correctedPortLocations) throws DeploymentException {
+ public Map<String, PortInfo> discoverWebServices(EjbModule module, Map<String, String> correctedPortLocations) throws DeploymentException {
Map<String, PortInfo> map = new HashMap<String, PortInfo>();
discoverEJBWebServices(module, correctedPortLocations, map);
return map;
}
- private void discoverEJBWebServices(Module module,
+ private void discoverEJBWebServices(EjbModule ejbModule,
Map<String, String> correctedPortLocations,
Map<String, PortInfo> map)
throws DeploymentException {
- Bundle bundle = module.getEarContext().getDeploymentBundle();
- EjbModule ejbModule = (EjbModule) module;
+ Bundle bundle = ejbModule.getEarContext().getDeploymentBundle();
+ Set<String> ejbWebServiceClassNames = new HashSet<String>();
for (EnterpriseBeanInfo bean : ejbModule.getEjbInfo().getEjbJarInfo().enterpriseBeans) {
if (bean.type != EnterpriseBeanInfo.STATELESS && bean.type != EnterpriseBeanInfo.SINGLETON) {
continue;
@@ -65,11 +66,13 @@ public class EJBWebServiceFinder impleme
}
portInfo.setLocation(location);
map.put(bean.ejbName, portInfo);
+ ejbWebServiceClassNames.add(bean.ejbClass);
}
} catch (Exception e) {
throw new DeploymentException("Failed to load ejb class "
+ bean.ejbName, e);
}
}
+ ejbModule.getSharedContext().put(EJB_WEB_SERVICE_CLASS_NAMES, ejbWebServiceClassNames);
}
}
Modified: geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/jaxws/geronimo-jaxws-ejb-builder/src/main/java/org/apache/geronimo/jaxws/ejb/builder/JAXWSEJBModuleBuilderExtension.java Thu Apr 14 13:11:33 2011
@@ -61,7 +61,6 @@ import org.apache.openejb.jee.oejb2.Open
import org.apache.openejb.jee.oejb2.SessionBeanType;
import org.apache.openejb.jee.oejb2.WebServiceBindingType;
import org.apache.openejb.jee.oejb2.WebServiceSecurityType;
-
import org.osgi.framework.Bundle;
/**
Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java Thu Apr 14 13:11:33 2011
@@ -105,8 +105,6 @@ import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -144,8 +142,6 @@ public class JettyModuleBuilder extends
private final AbstractNameQuery jettyContainerObjectName;
private final WebAppInfoFactory webAppInfoFactory;
- private final GBeanData pojoWebServiceTemplate;
-
protected final NamespaceDrivenBuilderCollection clusteringBuilders;
private final Integer defaultSessionTimeoutMinutes;
@@ -178,10 +174,7 @@ public class JettyModuleBuilder extends
}
this.webAppInfoFactory = new StandardWebAppInfoFactory(defaultWebApp, jspServletInfo);
- this.pojoWebServiceTemplate = getGBeanData(kernel, pojoWebServiceTemplate);
this.clusteringBuilders = new NamespaceDrivenBuilderCollection(clusteringBuilders);//, GerClusteringDocument.type.getDocumentElementName());
-
- ServiceReference sr = bundleContext.getServiceReference(PackageAdmin.class.getName());
}
public void doStart() throws Exception {
@@ -199,14 +192,6 @@ public class JettyModuleBuilder extends
doStop();
}
- private static GBeanData getGBeanData(Kernel kernel, Object template) throws GBeanNotFoundException {
- if (template == null) {
- return null;
- }
- AbstractName templateName = kernel.getAbstractNameFor(template);
- return new GBeanData(kernel.getGBeanData(templateName));
- }
-
public Module createModule(Bundle bundle, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException {
if (bundle == null) {
throw new NullPointerException("bundle is null");
@@ -425,19 +410,25 @@ public class JettyModuleBuilder extends
}
@Override
- protected void postInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
+ protected void postInitContext(EARContext earContext, WebModule webModule, Bundle bundle) throws DeploymentException {
for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
- mbe.initContext(earContext, module, bundle);
+ mbe.initContext(earContext, webModule, bundle);
+ }
+ //Process Web Service
+ Map<String, String> servletNameToPathMap = buildServletNameToPathMap(webModule.getSpecDD(), webModule.getContextRoot());
+ for (WebServiceBuilder serviceBuilder : webServiceBuilder) {
+ serviceBuilder.findWebServices(webModule, false, servletNameToPathMap, webModule.getEnvironment(), webModule.getSharedContext());
}
}
@Override
- protected void preInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
- JettyWebAppType gerWebApp = (JettyWebAppType) module.getVendorDD();
+ protected void preInitContext(EARContext earContext, WebModule webModule, Bundle bundle) throws DeploymentException {
+ JettyWebAppType gerWebApp = (JettyWebAppType) webModule.getVendorDD();
boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
- module.getEarContext().getGeneralData().put(WEB_MODULE_HAS_SECURITY_REALM, hasSecurityRealmName);
+ webModule.getEarContext().getGeneralData().put(WEB_MODULE_HAS_SECURITY_REALM, hasSecurityRealmName);
}
+ @Override
public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection repository) throws DeploymentException {
EARContext moduleContext = module.getEarContext();
AbstractName moduleName = module.getModuleName();
Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java?rev=1092215&r1=1092214&r2=1092215&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java (original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java Thu Apr 14 13:11:33 2011
@@ -28,7 +28,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.jar.JarFile;
@@ -430,17 +429,22 @@ public class TomcatModuleBuilder extends
}
@Override
- protected void postInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
+ protected void postInitContext(EARContext earContext, WebModule webModule, Bundle bundle) throws DeploymentException {
for (ModuleBuilderExtension mbe : moduleBuilderExtensions) {
- mbe.initContext(earContext, module, bundle);
+ mbe.initContext(earContext, webModule, bundle);
+ }
+ //Process Web Service
+ Map<String, String> servletNameToPathMap = buildServletNameToPathMap(webModule.getSpecDD(), webModule.getContextRoot());
+ for (WebServiceBuilder serviceBuilder : webServiceBuilder) {
+ serviceBuilder.findWebServices(webModule, false, servletNameToPathMap, webModule.getEnvironment(), webModule.getSharedContext());
}
}
@Override
- protected void preInitContext(EARContext earContext, Module module, Bundle bundle) throws DeploymentException {
- TomcatWebAppType gerWebApp = (TomcatWebAppType) module.getVendorDD();
+ protected void preInitContext(EARContext earContext, WebModule webModule, Bundle bundle) throws DeploymentException {
+ TomcatWebAppType gerWebApp = (TomcatWebAppType) webModule.getVendorDD();
boolean hasSecurityRealmName = gerWebApp.isSetSecurityRealmName();
- module.getEarContext().getGeneralData().put(WEB_MODULE_HAS_SECURITY_REALM, hasSecurityRealmName);
+ webModule.getEarContext().getGeneralData().put(WEB_MODULE_HAS_SECURITY_REALM, hasSecurityRealmName);
}
public void addGBeans(EARContext earContext, Module module, Bundle bundle, Collection repository) throws DeploymentException {
@@ -579,7 +583,6 @@ public class TomcatModuleBuilder extends
webModuleData.setAttribute("contextAttributes", contextAttributes);
//Handle the role permissions and webservices on the servlets.
- List<org.apache.openejb.jee.Servlet> servletTypes = webApp.getServlet();
Map<String, AbstractName> webServices = new HashMap<String, AbstractName>();
Class<?> baseServletClass;
try {