Java 类org.apache.catalina.deploy.ServletDef 实例源码

项目:tomcat7    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String,String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String,String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef: webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:tomcat7    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef,
        Map<String,String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning",
                                   jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException
                (sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:tomcat7    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:tomcat7    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:tomcat7    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:tomcat7    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:apache-tomcat-7.0.73-with-comment    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:apache-tomcat-7.0.73-with-comment    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:lazycat    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String, String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String, String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef : webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:lazycat    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef, Map<String, String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if (log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning", jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException(sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam : jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:class-guard    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String,String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String,String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef: webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:class-guard    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef,
        Map<String,String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning",
                                   jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException
                (sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:class-guard    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:class-guard    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:class-guard    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:class-guard    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:apache-tomcat-7.0.57    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String,String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String,String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef: webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:apache-tomcat-7.0.57    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef,
        Map<String,String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning",
                                   jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException
                (sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml, false);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:apache-tomcat-7.0.57    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml, false);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:apache-tomcat-7.0.57    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String,String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String,String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef: webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:apache-tomcat-7.0.57    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef,
        Map<String,String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning",
                                   jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException
                (sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:WBSAirback    文件:ContextConfig.java   
private void convertJsps(WebXml webXml) {
    Map<String,String> jspInitParams;
    ServletDef jspServlet = webXml.getServlets().get("jsp");
    if (jspServlet == null) {
        jspInitParams = new HashMap<String,String>();
        Wrapper w = (Wrapper) context.findChild("jsp");
        if (w != null) {
            String[] params = w.findInitParameters();
            for (String param : params) {
                jspInitParams.put(param, w.findInitParameter(param));
            }
        }
    } else {
        jspInitParams = jspServlet.getParameterMap();
    }
    for (ServletDef servletDef: webXml.getServlets().values()) {
        if (servletDef.getJspFile() != null) {
            convertJsp(servletDef, jspInitParams);
        }
    }
}
项目:WBSAirback    文件:ContextConfig.java   
private void convertJsp(ServletDef servletDef,
        Map<String,String> jspInitParams) {
    servletDef.setServletClass(org.apache.catalina.core.Constants.JSP_SERVLET_CLASS);
    String jspFile = servletDef.getJspFile();
    if ((jspFile != null) && !jspFile.startsWith("/")) {
        if (context.isServlet22()) {
            if(log.isDebugEnabled())
                log.debug(sm.getString("contextConfig.jspFile.warning",
                                   jspFile));
            jspFile = "/" + jspFile;
        } else {
            throw new IllegalArgumentException
                (sm.getString("contextConfig.jspFile.error", jspFile));
        }
    }
    servletDef.getParameterMap().put("jspFile", jspFile);
    servletDef.setJspFile(null);
    for (Map.Entry<String, String> initParam: jspInitParams.entrySet()) {
        servletDef.addInitParameter(initParam.getKey(), initParam.getValue());
    }
}
项目:WBSAirback    文件:TestContextConfigAnnotation.java   
@Test
public void testAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml);
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNotNull(servletDef);
    assertEquals("Hello", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    assertEquals("param", webxml.getServletMappings().get(
            "/annotation/overwrite"));

    assertEquals("param", servletDef.getDescription());
    assertEquals("param", servletDef.getDisplayName());
    assertEquals("paramLarge.png", servletDef.getLargeIcon());
    assertEquals("paramSmall.png", servletDef.getSmallIcon());
    assertEquals(Boolean.FALSE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(0), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());

}
项目:WBSAirback    文件:TestContextConfigAnnotation.java   
@Test
public void testNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml);
    ServletDef servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

    webxml.addServletMapping("/param", "param1");
    config.processAnnotationsFile(pFile, webxml);
    servletDef = webxml.getServlets().get("param1");
    assertNull(servletDef);

}
项目:WBSAirback    文件:TestContextConfigAnnotation.java   
@Test
public void testSetupWebXMLNoMapping() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param1");
    servletDef.setServletClass(
            "org.apache.catalina.startup.NoMappingParamServlet");
    servletDef.addInitParameter("foo", "tomcat");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param1");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/NoMappingParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml);
    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("World!", servletDef.getParameterMap().get("bar"));
    ServletDef servletDef1 = webxml.getServlets().get("param1");
    assertNotNull(servletDef1);
    assertEquals(servletDef, servletDef1);
}
项目:WBSAirback    文件:TestContextConfigAnnotation.java   
@Test
public void testDuplicateMapping() throws Exception {
    WebXml webxml = new WebXml();
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/DuplicateMappingParamServlet");
    assertTrue(pFile.exists());
    try {
        config.processAnnotationsFile(pFile, webxml);
        fail();
    } catch (IllegalArgumentException ex) {
        // ignore
    }
    ServletDef servletDef = webxml.getServlets().get("param");
    assertNull(servletDef);
}
项目:tomcat7    文件:WebRuleSet.java   
@Override
public void begin(String namespace, String name, Attributes attributes)
    throws Exception {
    ServletDef servletDef = new ServletDef();
    digester.push(servletDef);
    if (digester.getLogger().isDebugEnabled())
        digester.getLogger().debug("new " + servletDef.getClass().getName());
}
项目:tomcat7    文件:WebRuleSet.java   
@Override
public void end(String namespace, String name)
    throws Exception {
    ServletDef servletDef = (ServletDef) digester.pop();
    if (digester.getLogger().isDebugEnabled())
        digester.getLogger().debug("pop " + servletDef.getClass().getName());
}
项目:tomcat7    文件:TestContextConfigAnnotation.java   
@Test
public void testOverwriteAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param");
    servletDef.setServletClass("org.apache.catalina.startup.ParamServlet");
    servletDef.addInitParameter("foo", "tomcat");
    servletDef.setDescription("Description");
    servletDef.setDisplayName("DisplayName");
    servletDef.setLargeIcon("LargeIcon");
    servletDef.setSmallIcon("SmallIcon");
    servletDef.setAsyncSupported("true");
    servletDef.setLoadOnStartup("1");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);

    assertEquals(servletDef, webxml.getServlets().get("param"));

    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("param", webxml.getServletMappings().get("/param"));
    // annotation mapping not added s. Servlet Spec 3.0 (Nov 2009)
    // 8.2.3.3.iv page 81
    assertNull(webxml.getServletMappings().get("/annotation/overwrite"));

    assertEquals("Description", servletDef.getDescription());
    assertEquals("DisplayName", servletDef.getDisplayName());
    assertEquals("LargeIcon", servletDef.getLargeIcon());
    assertEquals("SmallIcon", servletDef.getSmallIcon());
    assertEquals(Boolean.TRUE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(1), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());
}
项目:apache-tomcat-7.0.73-with-comment    文件:TestContextConfigAnnotation.java   
@Test
public void testOverwriteAnnotation() throws Exception {
    WebXml webxml = new WebXml();
    ServletDef servletDef = new ServletDef();
    servletDef.setServletName("param");
    servletDef.setServletClass("org.apache.catalina.startup.ParamServlet");
    servletDef.addInitParameter("foo", "tomcat");
    servletDef.setDescription("Description");
    servletDef.setDisplayName("DisplayName");
    servletDef.setLargeIcon("LargeIcon");
    servletDef.setSmallIcon("SmallIcon");
    servletDef.setAsyncSupported("true");
    servletDef.setLoadOnStartup("1");

    webxml.addServlet(servletDef);
    webxml.addServletMapping("/param", "param");
    ContextConfig config = new ContextConfig();
    File pFile = paramClassResource(
            "org/apache/catalina/startup/ParamServlet");
    assertTrue(pFile.exists());
    config.processAnnotationsFile(pFile, webxml, false);

    assertEquals(servletDef, webxml.getServlets().get("param"));

    assertEquals("tomcat", servletDef.getParameterMap().get("foo"));
    assertEquals("param", webxml.getServletMappings().get("/param"));
    // annotation mapping not added s. Servlet Spec 3.0 (Nov 2009)
    // 8.2.3.3.iv page 81
    assertNull(webxml.getServletMappings().get("/annotation/overwrite"));

    assertEquals("Description", servletDef.getDescription());
    assertEquals("DisplayName", servletDef.getDisplayName());
    assertEquals("LargeIcon", servletDef.getLargeIcon());
    assertEquals("SmallIcon", servletDef.getSmallIcon());
    assertEquals(Boolean.TRUE, servletDef.getAsyncSupported());
    assertEquals(Integer.valueOf(1), servletDef.getLoadOnStartup());
    assertNull(servletDef.getEnabled());
    assertNull(servletDef.getJspFile());
}