Revision: 15713
Author: gvagenas
Date: Fri Dec 10 10:22:49 2010
Log: Fixes Issue 2149

Upgrade to Tomcat 7.0.5
http://code.google.com/p/mobicents/source/detail?r=15713

Modified:
 /branches/servers/sip-servlets/2.0/pom.xml
 /branches/servers/sip-servlets/2.0/sip-servlets-bootstrap/release/build.xml
/branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipHostConfig.java /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/main/java/org/mobicents/servlet/sip/SipEmbedded.java /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/security/ShootmeSipServletAuthTest.java /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipContextConfig.java

=======================================
--- /branches/servers/sip-servlets/2.0/pom.xml  Fri Dec  3 12:53:54 2010
+++ /branches/servers/sip-servlets/2.0/pom.xml  Fri Dec 10 10:22:49 2010
@@ -89,7 +89,7 @@
                
<mobicents.balancer.version>1.1-SNAPSHOT</mobicents.balancer.version>
<mobicents.jain.sip.ha.version>0.14-SNAPSHOT</mobicents.jain.sip.ha.version> <mobicents.jain.sip.ext.version>1.0.BETA1</mobicents.jain.sip.ext.version>
-               <tomcat.version>7.0.4</tomcat.version>
+               <tomcat.version>7.0.5</tomcat.version>
        </properties>

        <dependencies>
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-bootstrap/release/build.xml Thu Nov 25 03:11:08 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-bootstrap/release/build.xml Fri Dec 10 10:22:49 2010
@@ -15,7 +15,7 @@
<property name="jboss-5.download.url" value="http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-${jboss-5.version}/jboss-${jboss-5.version}.zip"; /> <property name="jboss-5-jdk6.download.url" value="http://downloads.sourceforge.net/project/jboss/JBoss/JBoss-${jboss-5.version}/jboss-${jboss-5.version}-jdk6.zip"; />

-       <property name="tomcat.version" value="7.0.4" />
+       <property name="tomcat.version" value="7.0.5" />
<property name="tomcat.download.url" value="http://archive.apache.org/dist/tomcat/tomcat-7/v${tomcat.version}-beta/bin/apache-tomcat-${tomcat.version}.zip"; />

        <property name="mms.version" value="2.0.0.GA" />
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipHostConfig.java Sun Nov 21 09:21:23 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-impl/src/main/java/org/mobicents/servlet/sip/startup/SipHostConfig.java Fri Dec 10 10:22:49 2010
@@ -23,6 +23,7 @@

 import org.apache.catalina.Context;
 import org.apache.catalina.startup.HostConfig;
+import org.apache.catalina.util.ContextName;
 import org.apache.log4j.Logger;
 import org.mobicents.servlet.sip.annotations.SipApplicationAnnotationUtils;

@@ -51,49 +52,54 @@

//completely overwritten since jboss web in jboss as5 and as 4.2.3 are not based on tomcat 6.0.20 //tc 7.0.4 changed this method to getBaseName(String path). also this replace the getConfigFile(String path) method
-       @Override
-    protected String getBaseName(String path) {
-        String basename = null;
-        if (path.equals("")) {
-            basename = "ROOT";
-        } else {
-            basename = path.substring(1).replace('/', '#');
-        }
-        return (basename);
-    }
+//     @Override
+//    protected String getBaseName(String path) {
+//        String basename = null;
+//        if (path.equals("")) {
+//            basename = "ROOT";
+//        } else {
+//            basename = path.substring(1).replace('/', '#');
+//        }
+//        return (basename);
+//    }


        @Override
        protected void deployApps(String name) {
                File appBase = appBase();
         File configBase = configBase();
-        String baseName = getBaseName(name);
+
+//        String baseName = getBaseName(name);
+
+        ContextName cn = new ContextName(name, null);
+        String baseName = cn.getBaseName();
+
         //No need for docBase, replace by baseName
         //String docBase = getBaseName(name);

         // Deploy XML descriptors from configBase
         File xml = new File(configBase, baseName + ".xml");
         if (xml.exists())
-            deployDescriptor(name, xml, baseName + ".xml");
+            deployDescriptor(cn, xml, baseName + ".xml");
         // Deploy WARs, and loop if additional descriptors are found
         File war = new File(appBase, baseName + ".war");
         if (war.exists()) {
                boolean isSipServletApplication = isSipServletArchive(war);
             if(isSipServletApplication) {
-               deploySAR(name, war, baseName + ".war");
+               deploySAR(cn, war, baseName + ".war");
             } else {
-               deployWAR(name, war, baseName + ".war");
+               deployWAR(cn, war, baseName + ".war");
             }
         }
         // Deploy expanded folders
         File dir = new File(appBase, baseName);
         if (dir.exists()) {
-            deployDirectory(name, dir, baseName);
+            deployDirectory(cn, dir, baseName);
         }
                // Deploy SARs, and loop if additional descriptors are found
         File sar = new File(appBase, baseName + SAR_EXTENSION);
         if (sar.exists()) {
-            deploySAR(name, sar, baseName + SAR_EXTENSION);
+            deploySAR(cn, sar, baseName + SAR_EXTENSION);
         }
        }

@@ -103,8 +109,8 @@
         * @param sar
         * @param string
         */
-       private void deploySAR(String contextPath, File sar, String file) {
-               if (deploymentExists(contextPath))
+       private void deploySAR(ContextName cn, File sar, String file) {
+               if (deploymentExists(cn.getName()))
             return;
                if(logger.isDebugEnabled()) {
                logger.debug(SipContext.APPLICATION_SIP_XML + " found in "
@@ -115,24 +121,24 @@
                host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                setContextClass(SIP_CONTEXT_CLASS);
-               deployWAR(contextPath, sar, file);
+               deployWAR(cn, sar, file);
                host.setConfigClass(initialConfigClass);
                configClass = initialConfigClass;
         contextClass = initialContextClass;
        }

        @Override
-       protected void deployWAR(String contextPath, File dir, String file) {
+       protected void deployWAR(ContextName cn, File dir, String file) {
                if(logger.isTraceEnabled()) {
logger.trace("Context class used to deploy the WAR : " + contextClass); logger.trace("Context config class used to deploy the WAR : " + configClass);
        }
-               super.deployWAR(contextPath, dir, file);
+               super.deployWAR(cn, dir, file);
        }

        @Override
- protected void deployDirectory(String contextPath, File dir, String file) {
-               if (deploymentExists(contextPath))
+       protected void deployDirectory(ContextName cn, File dir, String file) {
+               if (deploymentExists(cn.getName()))
             return;

                boolean isSipServletApplication = isSipServletDirectory(dir);
@@ -146,18 +152,18 @@
                        host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                        setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                        setContextClass(SIP_CONTEXT_CLASS);
-                       super.deployDirectory(contextPath, dir, file);
+                       super.deployDirectory(cn, dir, file);
                        host.setConfigClass(initialConfigClass);
                        configClass = initialConfigClass;
                contextClass = initialContextClass;
                } else {
-                       super.deployDirectory(contextPath, dir, file);
+                       super.deployDirectory(cn, dir, file);
                }
        }

        @Override
- protected void deployDescriptor(String contextPath, File contextXml, String file) {
-               super.deployDescriptor(contextPath, contextXml, file);
+ protected void deployDescriptor(ContextName cn, File contextXml, String file) {
+               super.deployDescriptor(cn, contextXml, file);
        }

        @Override
@@ -173,16 +179,17 @@
                 continue;
             File dir = new File(appBase, files[i]);
             boolean isSipServletApplication = isSipServletArchive(dir);
-            if(isSipServletApplication) {
+            if(isSipServletApplication) {
+               ContextName cn = new ContextName(files[i]);
                 // Calculate the context path and make sure it is unique
-                String contextPath = "/" + files[i];
-                int period = contextPath.lastIndexOf(".");
-                if (period >= 0)
-                    contextPath = contextPath.substring(0, period);
-                if (contextPath.equals("/ROOT"))
-                    contextPath = "";
-
-                if (isServiced(contextPath))
+//                String contextPath = "/" + files[i];
+//                int period = contextPath.lastIndexOf(".");
+//                if (period >= 0)
+//                    contextPath = contextPath.substring(0, period);
+//                if (contextPath.equals("/ROOT"))
+//                    contextPath = "";
+
+                if (isServiced(cn.getName()))
                     continue;

                 String file = files[i];
@@ -192,7 +199,7 @@
                        host.setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                        setConfigClass(SIP_CONTEXT_CONFIG_CLASS);
                        setContextClass(SIP_CONTEXT_CLASS);
-                deploySAR(contextPath, dir, file);
+                deploySAR(cn, dir, file);
                 host.setConfigClass(initialConfigClass);
                 configClass = initialConfigClass;
                 contextClass = initialContextClass;
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/main/java/org/mobicents/servlet/sip/SipEmbedded.java Thu Dec 2 14:19:59 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/main/java/org/mobicents/servlet/sip/SipEmbedded.java Fri Dec 10 10:22:49 2010
@@ -294,15 +294,15 @@
* Stop connectors so the next test will have no conflict with open ports
                                 */

-                               if(sipService.findConnectors().length>0){
-                                       Connector[] connectors = 
sipService.findConnectors();
-                                       for (int i = 0; i < connectors.length; 
i++) {
-                                               Connector connector = 
connectors[i];
-                                               connector.stop();
-                                               connector.destroy();
-                                               
sipService.removeConnector(connector);
-                                       }
-                               }
+//                             if(sipService.findConnectors().length>0){
+//                                     Connector[] connectors = 
sipService.findConnectors();
+//                                     for (int i = 0; i < connectors.length; 
i++) {
+//                                             Connector connector = 
connectors[i];
+//                                             connector.stop();
+//                                             connector.destroy();
+//                                             
sipService.removeConnector(connector);
+//                                     }
+//                             }

                                sipService.stop();
                                host.stop();
@@ -320,7 +320,7 @@
        public boolean deployContext(String docBase, String name, String path) {
                SipStandardContext context = new SipStandardContext();
                context.setDocBase(docBase);
-               context.setName(name);
+//             context.setName(name);
                if (!path.startsWith(File.separator)){
                        path = File.separator+path;
                }
@@ -334,7 +334,7 @@
public boolean deployContext(String docBase, String name, String path, int appSessionTimeout) {
                SipStandardContext context = new SipStandardContext();
                context.setDocBase(docBase);
-               context.setName(name);
+//             context.setName(name);
                if (!path.startsWith(File.separator)){
                        path = File.separator+path;
                }
=======================================
--- /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/security/ShootmeSipServletAuthTest.java Fri Dec 3 12:59:37 2010 +++ /branches/servers/sip-servlets/2.0/sip-servlets-test-suite/testsuite/src/test/java/org/mobicents/servlet/sip/testsuite/security/ShootmeSipServletAuthTest.java Fri Dec 10 10:22:49 2010
@@ -16,6 +16,7 @@
  */
 package org.mobicents.servlet.sip.testsuite.security;

+import java.io.File;
 import java.text.ParseException;

 import javax.sip.InvalidArgumentException;
@@ -56,8 +57,9 @@
                context
                                .setDocBase(projectHome
+ "/sip-servlets-test-suite/applications/shootme-sip-servlet-auth/src/main/sipapp");
-               context.setName("sip-test-context");
-               context.setPath("sip-test");
+//             context.setName("sip-test-context");
+//             super.setName("sip-standard-context");
+               context.setPath(File.separator+"sip-test");
                context.addLifecycleListener(new SipContextConfig());
                context.setManager(new SipStandardManager());
                ApplicationParameter applicationParameter = new 
ApplicationParameter();
=======================================
--- /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipContextConfig.java Mon Nov 15 12:08:51 2010 +++ /branches/servers/sip-servlets/2.0/tomcat-7/src/main/java/org/mobicents/servlet/sip/startup/SipContextConfig.java Fri Dec 10 10:22:49 2010
@@ -33,6 +33,7 @@
 import org.apache.catalina.startup.ContextConfig;
 import org.apache.catalina.startup.DigesterFactory;
 import org.apache.catalina.startup.ExpandWar;
+import org.apache.catalina.util.ContextName;
 import org.apache.log4j.Logger;
 import org.apache.naming.resources.FileDirContext;
 import org.apache.tomcat.util.digester.Digester;
@@ -216,15 +217,19 @@
                                if (path == null) {
                                        return;
                                }
-                               if (path.equals("")) {
-                                       docBase = "ROOT";
-                               } else {
-                                       if (path.startsWith("/")) {
-                           docBase = path.substring(1).replace('/', '#');
-                       } else {
-                           docBase = path.replace('/', '#');
-                       }
-                               }
+
+                               ContextName cn = new ContextName(path, 
context.getWebappVersion());
+                               docBase = cn.getBaseName();
+
+//                             if (path.equals("")) {
+//                                     docBase = "ROOT";
+//                             } else {
+//                                     if (path.startsWith("/")) {
+//                         docBase = path.substring(1).replace('/', '#');
+//                     } else {
+//                         docBase = path.replace('/', '#');
+//                     }
+//                             }
                        }
                        File file = new File(docBase);
                        if (!file.isAbsolute()) {
@@ -239,13 +244,14 @@
                                        && !file.isDirectory() && unpackWARs) {
                                URL war = new URL("jar:" + (new 
File(docBase)).toURI().toURL() + "!/");
                                String contextPath = context.getPath();
-                               if (contextPath.equals("")) {
-                                       contextPath = "ROOT";
-                               } else {
-                           if (contextPath.lastIndexOf('/') > 0) {
- contextPath = "/" + contextPath.substring(1).replace('/','#');
-                           }
-                       }
+
+//                             if (contextPath.equals("")) {
+//                                     contextPath = "ROOT";
+//                             } else {
+//                         if (contextPath.lastIndexOf('/') > 0) {
+// contextPath = "/" + contextPath.substring(1).replace('/','#');
+//                         }
+//                     }

                                docBase = ExpandWar.expand(host, war, 
contextPath);
                                file = new File(docBase);

Reply via email to