geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r904674 - in /geronimo/server/trunk/plugins/tomcat: geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/ geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/
Date Fri, 29 Jan 2010 23:36:03 GMT
Author: gawor
Date: Fri Jan 29 23:36:02 2010
New Revision: 904674

URL: http://svn.apache.org/viewvc?rev=904674&view=rev
Log:
make tomcat read the exact descriptor generated by Geronimo

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7-builder/src/main/java/org/apache/geronimo/tomcat/deployment/TomcatModuleBuilder.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/WebContextConfig.java

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=904674&r1=904673&r2=904674&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
Fri Jan 29 23:36:02 2010
@@ -21,8 +21,6 @@
 import static java.lang.Boolean.TRUE;
 
 import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.net.URL;
 import java.util.Collection;
@@ -61,7 +59,6 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.apache.geronimo.kernel.Kernel;
 import org.apache.geronimo.kernel.Naming;
-import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Environment;
 import org.apache.geronimo.kernel.util.JarUtils;
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
@@ -87,24 +84,12 @@
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppDocument;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.TomcatWebAppType;
 import org.apache.geronimo.xbeans.geronimo.web.tomcat.config.GerTomcatDocument;
-import org.apache.geronimo.xbeans.javaee.EjbLocalRefType;
-import org.apache.geronimo.xbeans.javaee.EjbRefType;
-import org.apache.geronimo.xbeans.javaee.EnvEntryType;
-import org.apache.geronimo.xbeans.javaee.LifecycleCallbackType;
-import org.apache.geronimo.xbeans.javaee.MessageDestinationRefType;
-import org.apache.geronimo.xbeans.javaee.MessageDestinationType;
-import org.apache.geronimo.xbeans.javaee.PersistenceContextRefType;
-import org.apache.geronimo.xbeans.javaee.PersistenceUnitRefType;
-import org.apache.geronimo.xbeans.javaee.ResourceEnvRefType;
-import org.apache.geronimo.xbeans.javaee.ResourceRefType;
-import org.apache.geronimo.xbeans.javaee.ServiceRefType;
 import org.apache.geronimo.xbeans.javaee.ServletType;
 import org.apache.geronimo.xbeans.javaee.WebAppDocument;
 import org.apache.geronimo.xbeans.javaee.WebAppType;
 import org.apache.xmlbeans.XmlCursor;
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
 import org.osgi.framework.Bundle;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -583,12 +568,6 @@
                 module.setOriginalSpecDD(module.getSpecDD().toString());
             }
             webModuleData.setAttribute("deploymentDescriptor", module.getOriginalSpecDD());
-
-            /*
-             * Not sure if this is still needed. Disabled for now as it does not work
-             * with Bundle-based deployments.
-             */
-            // rewriteWebXml(webModule);
             
             module.addAsChildConfiguration();
         } catch (DeploymentException de) {
@@ -597,71 +576,6 @@
             throw new DeploymentException("Unable to initialize GBean for web app " + module.getName(),
e);
         }
     }
-
-    /**
-     * This next bit of code is kind of a kludge to get Tomcat to get a default
-     * web.xml if one does not exist.  This is primarily for jaxws.  This code is
-     * necessary because Tomcat either has a bug or there is a problem dynamically
-     * adding a wrapper to an already running context.  Although the wrapper
-     * can be added, the url mappings do not get picked up at the proper level
-     * and therefore Tomcat cannot dispatch the request.  Hence, creating and
-     * writing out a web.xml to the deployed location is the only way around this
-     * until Tomcat fixes that bug.
-     *
-     * For myfaces/jsf, the spec dd may have been updated with a listener.  So, we need to
write it out again whether or not
-     * there originally was one. This might not work on windows due to file locking problems.
-     */
-    private void rewriteWebXml(WebModule webModule) throws DeploymentException {
-        EARContext moduleContext = webModule.getEarContext();
-        WebAppType webApp = (WebAppType) webModule.getSpecDD();
-        if ((Boolean)webModule.getSharedContext().get(IS_JAVAEE)) {            
-            WebAppType shortWebApp = (WebAppType) webApp.copy();
-            shortWebApp.setEjbLocalRefArray(new EjbLocalRefType[0]);
-            shortWebApp.setEjbRefArray(new EjbRefType[0]);
-            shortWebApp.setEnvEntryArray(new EnvEntryType[0]);
-            shortWebApp.setMessageDestinationArray(new MessageDestinationType[0]);
-            shortWebApp.setMessageDestinationRefArray(new MessageDestinationRefType[0]);
-            shortWebApp.setPersistenceContextRefArray(new PersistenceContextRefType[0]);
-            shortWebApp.setPersistenceUnitRefArray(new PersistenceUnitRefType[0]);
-            shortWebApp.setPostConstructArray(new LifecycleCallbackType[0]);
-            shortWebApp.setPreDestroyArray(new LifecycleCallbackType[0]);
-            shortWebApp.setResourceEnvRefArray(new ResourceEnvRefType[0]);
-            shortWebApp.setResourceRefArray(new ResourceRefType[0]);
-            shortWebApp.setServiceRefArray(new ServiceRefType[0]);
-            // TODO Tomcat will fail web services tck tests if the following security settings
are set in shortWebApp
-            // need to figure out why...
-            //One clue is that without this stuff tomcat does not install an authenticator....
so there's no security
-//             shortWebApp.setSecurityConstraintArray(new SecurityConstraintType[0]);
-//             shortWebApp.setSecurityRoleArray(new SecurityRoleType[0]);
-            File webXml = new File(moduleContext.getBaseDir(), "/WEB-INF/web.xml");
-            File inPlaceDir = moduleContext.getInPlaceConfigurationDir();
-            if (inPlaceDir != null) {
-                webXml = new File(inPlaceDir, "/WEB-INF/web.xml");
-            }
-//    boolean webXmlExists = (inPlaceDir != null && new File(inPlaceDir,"/WEB-INF/web.xml").exists())
|| webXml.exists();
-//    if (!webXmlExists) {
-            webXml.getParentFile().mkdirs();
-            try {
-                FileWriter outFile = new FileWriter(webXml);
-
-                XmlOptions opts = new XmlOptions();
-                opts.setSaveAggressiveNamespaces();
-                opts.setSaveSyntheticDocumentElement(WebAppDocument.type.getDocumentElementName());
-                opts.setUseDefaultNamespace();
-                opts.setSavePrettyPrint();
-
-//                WebAppDocument doc = WebAppDocument.Factory.newInstance();
-//                doc.setWebApp(webApp);
-
-                outFile.write(shortWebApp.xmlText(opts));
-                outFile.flush();
-                outFile.close();
-            } catch (Exception e) {
-                throw new DeploymentException(e);
-            }
-//    }
-        }
-    }
     
     public String getSchemaNamespace() {
         return TOMCAT_NAMESPACE;

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java?rev=904674&r1=904673&r2=904674&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContainer.java
Fri Jan 29 23:36:02 2010
@@ -168,7 +168,7 @@
             Context defaultContext;
             ObjectName objName = objectName == null ? null : ObjectName.getInstance(objectName);
             for (Container host : hosts) {
-                defaultContext = createContext("", classLoader);
+                defaultContext = createContext("", classLoader, null);
                 if (objName != null) {
                     defaultContext.setName(objName.getKeyProperty(NameFactory.J2EE_NAME));
                 }
@@ -272,7 +272,7 @@
      * @see org.apache.catalina.Host
      */
     public void addContext(TomcatContext contextInfo) throws Exception {
-        Context context = createContext(contextInfo.getContextPath(), contextInfo.getClassLoader());
+        Context context = createContext(contextInfo.getContextPath(), contextInfo.getClassLoader(),
contextInfo.getDeploymentDescriptor());
         //Was a virtual server defined?
         String virtualServer = contextInfo.getVirtualServer();
         if (virtualServer == null) {
@@ -431,7 +431,7 @@
         webServices.remove(contextPath);
     }
 
-    public Context createContext(String path, ClassLoader cl) {
+    public Context createContext(String path, ClassLoader cl, String deploymentDescriptor)
{
 
         if( log.isDebugEnabled() )
             log.debug("Creating context '" + path);
@@ -443,7 +443,7 @@
         if (cl != null)
             context.setParentClassLoader(cl);
 
-        ContextConfig config = new WebContextConfig();
+        ContextConfig config = new WebContextConfig(deploymentDescriptor);
         context.addLifecycleListener(config);
 
         context.setDelegate(true);

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java?rev=904674&r1=904673&r2=904674&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatContext.java
Fri Jan 29 23:36:02 2010
@@ -88,4 +88,6 @@
     Bundle getBundle();
 
     String getModulePath();
+    
+    String getDeploymentDescriptor();
 }

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/WebContextConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/WebContextConfig.java?rev=904674&r1=904673&r2=904674&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/WebContextConfig.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/WebContextConfig.java
Fri Jan 29 23:36:02 2010
@@ -17,16 +17,33 @@
  * under the License.
  */
 
-
 package org.apache.geronimo.tomcat;
 
-import org.apache.catalina.deploy.SecurityConstraint;
+import java.io.StringReader;
+
 import org.apache.catalina.deploy.LoginConfig;
+import org.xml.sax.InputSource;
 
 /**
  * @version $Rev$ $Date$
  */
 public class WebContextConfig extends BaseGeronimoContextConfig {
+    
+    private String deploymentDescriptor;
+    
+    public WebContextConfig(String deploymentDescriptor) {
+        this.deploymentDescriptor = deploymentDescriptor;
+    }
+    
+    @Override
+    protected InputSource getContextWebXmlSource() {
+        if (deploymentDescriptor == null) {
+            return super.getContextWebXmlSource();
+        } else {
+            return new InputSource(new StringReader(deploymentDescriptor));
+        }
+    }
+    
     @Override
     protected void authenticatorConfig() {
         if (!(context instanceof GeronimoStandardContext)) {



Mime
View raw message