392237 more debug

This commit is contained in:
Greg Wilkins 2012-10-26 15:31:19 +11:00
parent 4913c1eb9b
commit 7d93f4b228
5 changed files with 73 additions and 12 deletions

View File

@ -758,12 +758,14 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
/* ------------------------------------------------------------ */
protected void callContextInitialized (ServletContextListener l, ServletContextEvent e)
{
LOG.debug("contextInitialized: {}->{}",e,l);
l.contextInitialized(e);
}
/* ------------------------------------------------------------ */
protected void callContextDestroyed (ServletContextListener l, ServletContextEvent e)
{
LOG.debug("contextDestroyed: {}->{}",e,l);
l.contextDestroyed(e);
}

View File

@ -114,6 +114,7 @@ public class FilterHolder extends Holder<Filter>
}
_config=new Config();
LOG.debug("Filter.init {}",_filter);
_filter.init(_config);
}

View File

@ -367,6 +367,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
}
/* ------------------------------------------------------------ */
@Override
public void destroyInstance (Object o)
throws Exception
{
@ -510,7 +511,8 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
}
initMultiPart();
LOG.debug("Filter.init {}",_servlet);
_servlet.init(_config);
}
catch (UnavailableException e)
@ -591,6 +593,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
/**
* @see org.eclipse.jetty.server.UserIdentity.Scope#getContextPath()
*/
@Override
public String getContextPath()
{
return _config.getServletContext().getContextPath();
@ -600,6 +603,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
/**
* @see org.eclipse.jetty.server.UserIdentity.Scope#getRoleRefMap()
*/
@Override
public Map<String, String> getRoleRefMap()
{
return _roleMap;
@ -719,6 +723,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
protected class Config extends HolderConfig implements ServletConfig
{
/* -------------------------------------------------------- */
@Override
public String getServletName()
{
return getName();
@ -733,6 +738,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
{
protected MultipartConfigElement _multipartConfig;
@Override
public Set<String> addMapping(String... urlPatterns)
{
illegalStateIfContextStarted();
@ -765,6 +771,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
return Collections.emptySet();
}
@Override
public Collection<String> getMappings()
{
ServletMapping[] mappings =_servletHandler.getServletMappings();
@ -839,6 +846,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
{
Stack<Servlet> _stack=new Stack<Servlet>();
@Override
public void destroy()
{
synchronized(this)
@ -848,16 +856,19 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
}
}
@Override
public ServletConfig getServletConfig()
{
return _config;
}
@Override
public String getServletInfo()
{
return null;
}
@Override
public void init(ServletConfig config) throws ServletException
{
synchronized(this)
@ -882,6 +893,7 @@ public class ServletHolder extends Holder<Servlet> implements UserIdentity.Scope
}
}
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException
{
Servlet s;

View File

@ -56,6 +56,7 @@ public class TestFilter implements Filter
/*
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
@Override
public void init(FilterConfig filterConfig) throws ServletException
{
_context= filterConfig.getServletContext();
@ -70,6 +71,7 @@ public class TestFilter implements Filter
/*
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
@ -121,6 +123,7 @@ public class TestFilter implements Filter
/*
* @see javax.servlet.Filter#destroy()
*/
@Override
public void destroy()
{
}

View File

@ -18,6 +18,8 @@
package com.acme;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.servlet.DispatcherType;
import javax.servlet.ServletContextAttributeEvent;
import javax.servlet.ServletContextAttributeListener;
@ -40,96 +42,131 @@ import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class TestListener implements HttpSessionListener, HttpSessionAttributeListener, HttpSessionActivationListener, ServletContextListener, ServletContextAttributeListener, ServletRequestListener, ServletRequestAttributeListener
{
Map<String,Throwable> _called=new HashMap<>();
public TestListener()
{
_called.put("TestListener",new Throwable());
}
@PostConstruct
public void postConstruct()
{
_called.put("postConstruct",new Throwable());
}
@PreDestroy
public void preDestroy()
{
_called.put("preDestroy",new Throwable());
}
@Override
public void attributeAdded(HttpSessionBindingEvent se)
{
// System.err.println("attributedAdded "+se);
_called.put("attributeAdded",new Throwable());
}
@Override
public void attributeRemoved(HttpSessionBindingEvent se)
{
// System.err.println("attributeRemoved "+se);
_called.put("attributeRemoved",new Throwable());
}
@Override
public void attributeReplaced(HttpSessionBindingEvent se)
{
// System.err.println("attributeReplaced "+se);
_called.put("attributeReplaced",new Throwable());
}
@Override
public void sessionWillPassivate(HttpSessionEvent se)
{
// System.err.println("sessionWillPassivate "+se);
_called.put("sessionWillPassivate",new Throwable());
}
@Override
public void sessionDidActivate(HttpSessionEvent se)
{
// System.err.println("sessionDidActivate "+se);
_called.put("sessionDidActivate",new Throwable());
}
@Override
public void contextInitialized(ServletContextEvent sce)
{
// System.err.println("contextInitialized "+sce);
_called.put("contextInitialized",new Throwable());
//configure programmatic security
ServletRegistration.Dynamic rego = sce.getServletContext().addServlet("RegoTest", RegTest.class.getName());
rego.addMapping("/rego/*");
HttpConstraintElement constraintElement = new HttpConstraintElement(ServletSecurity.EmptyRoleSemantic.PERMIT,
ServletSecurity.TransportGuarantee.NONE, new String[]{"admin"});
ServletSecurity.TransportGuarantee.NONE, new String[]{"admin"});
ServletSecurityElement securityElement = new ServletSecurityElement(constraintElement, null);
Set<String> unchanged = rego.setServletSecurity(securityElement);
//System.err.println("Security constraints registered: "+unchanged.isEmpty());
//// System.err.println("Security constraints registered: "+unchanged.isEmpty());
//Test that a security constraint from web.xml can't be overridden programmatically
ServletRegistration.Dynamic rego2 = sce.getServletContext().addServlet("RegoTest2", RegTest.class.getName());
rego2.addMapping("/rego2/*");
securityElement = new ServletSecurityElement(constraintElement, null);
unchanged = rego2.setServletSecurity(securityElement);
//System.err.println("Overridding web.xml constraints not possible:" +!unchanged.isEmpty());
//// System.err.println("Overridding web.xml constraints not possible:" +!unchanged.isEmpty());
/* For servlet 3.0 */
FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());
registration.setInitParameter("remote", "false");
registration.setAsyncSupported(true);
registration.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.ERROR,DispatcherType.ASYNC,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST),
true,
new String[]{"/*"});
/* For servlet 3.0 */
FilterRegistration.Dynamic registration = sce.getServletContext().addFilter("TestFilter",TestFilter.class.getName());
registration.setInitParameter("remote", "false");
registration.setAsyncSupported(true);
registration.addMappingForUrlPatterns(
EnumSet.of(DispatcherType.ERROR,DispatcherType.ASYNC,DispatcherType.FORWARD,DispatcherType.INCLUDE,DispatcherType.REQUEST),
true,
new String[]{"/*"});
}
@Override
public void contextDestroyed(ServletContextEvent sce)
{
_called.put("contextDestroyed",new Throwable());
// System.err.println("contextDestroyed "+sce);
}
@Override
public void attributeAdded(ServletContextAttributeEvent scab)
{
_called.put("attributeAdded",new Throwable());
// System.err.println("attributeAdded "+scab);
}
@Override
public void attributeRemoved(ServletContextAttributeEvent scab)
{
_called.put("attributeRemoved",new Throwable());
// System.err.println("attributeRemoved "+scab);
}
@Override
public void attributeReplaced(ServletContextAttributeEvent scab)
{
_called.put("attributeReplaced",new Throwable());
// System.err.println("attributeReplaced "+scab);
}
@Override
public void requestDestroyed(ServletRequestEvent sre)
{
_called.put("requestDestroyed",new Throwable());
((HttpServletRequest)sre.getServletRequest()).getSession(false);
sre.getServletRequest().setAttribute("requestInitialized",null);
// System.err.println("requestDestroyed "+sre);
@ -138,6 +175,7 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
@Override
public void requestInitialized(ServletRequestEvent sre)
{
_called.put("requestInitialized",new Throwable());
sre.getServletRequest().setAttribute("requestInitialized","'"+sre.getServletContext().getContextPath()+"'");
// System.err.println("requestInitialized "+sre);
}
@ -145,30 +183,35 @@ public class TestListener implements HttpSessionListener, HttpSessionAttributeL
@Override
public void attributeAdded(ServletRequestAttributeEvent srae)
{
_called.put("attributeAdded",new Throwable());
// System.err.println("attributeAdded "+srae);
}
@Override
public void attributeRemoved(ServletRequestAttributeEvent srae)
{
_called.put("attributeRemoved",new Throwable());
// System.err.println("attributeRemoved "+srae);
}
@Override
public void attributeReplaced(ServletRequestAttributeEvent srae)
{
_called.put("attributeReplaced",new Throwable());
// System.err.println("attributeReplaced "+srae);
}
@Override
public void sessionCreated(HttpSessionEvent se)
{
_called.put("sessionCreated",new Throwable());
// System.err.println("sessionCreated "+se);
}
@Override
public void sessionDestroyed(HttpSessionEvent se)
{
_called.put("sessionDestroyed",new Throwable());
// System.err.println("sessionDestroyed "+se);
}