List of usage examples for javax.servlet ServletConfig getServletName
public String getServletName();
From source file:org.springframework.faces.mvc.servlet.FacesHandlerAdapterTests.java
public void testDelegatingServletConfig() throws Exception { Properties initParameters = new Properties(); initParameters.setProperty("testkey", "testvalue"); ServletContext servletContext = (ServletContext) EasyMock.createMock(ServletContext.class); adapter.setInitParameters(initParameters); adapter.setServletContext(servletContext); adapter.setOverrideInitParameters(false); adapter.setFacesServletClass(MockServlet.class); adapter.afterPropertiesSet();/* ww w . ja v a 2s. c o m*/ MockServlet servlet = (MockServlet) adapter.getFacesServlet(); ServletConfig config = servlet.getServletConfig(); assertTrue(EnumerationUtils.toList(config.getInitParameterNames()).contains("testkey")); assertEquals("testvalue", config.getInitParameter("testkey")); assertEquals("testAdapterBean", config.getServletName()); assertSame(servletContext, config.getServletContext()); }
From source file:org.springframework.http.server.reactive.ServletHttpHandlerAdapter.java
private String getServletPath(ServletConfig config) { String name = config.getServletName(); ServletRegistration registration = config.getServletContext().getServletRegistration(name); if (registration == null) { throw new IllegalStateException("ServletRegistration not found for Servlet '" + name + "'"); }//from www . j a va2 s.c om Collection<String> mappings = registration.getMappings(); if (mappings.size() == 1) { String mapping = mappings.iterator().next(); if (mapping.equals("/")) { return ""; } if (mapping.endsWith("/*")) { String path = mapping.substring(0, mapping.length() - 2); if (!path.isEmpty()) { logger.info("Found Servlet mapping '" + path + "' for Servlet '" + name + "'"); } return path; } } throw new IllegalArgumentException( "Expected a single Servlet mapping: " + "either the default Servlet mapping (i.e. '/'), " + "or a path based mapping (e.g. '/*', '/foo/*'). " + "Actual mappings: " + mappings + " for Servlet '" + name + "'"); }