Made filtering work properly again.

This commit is contained in:
FrozenCow 2012-01-13 21:56:11 +01:00
parent 58f8a34b49
commit 502fbd5829
2 changed files with 13 additions and 18 deletions

View File

@ -424,21 +424,18 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false); final boolean allow_symlinks = configuration.getBoolean("allow-symlinks", false);
int maxconnections = configuration.getInteger("max-sessions", 30); int maxconnections = configuration.getInteger("max-sessions", 30);
if(maxconnections < 2) maxconnections = 2; if(maxconnections < 2) maxconnections = 2;
final ContextHandler context = new ContextHandler() {{ router = new HandlerRouter() {{
this.setContextPath("/"); this.addHandler("/", new ResourceHandler() {{
this.setClassLoader(Thread.currentThread().getContextClassLoader()); this.setAliases(allow_symlinks);
this.setHandler(router = new HandlerRouter() {{ this.setWelcomeFiles(new String[] { "index.html" });
this.addHandler("/", new ResourceHandler() {{ this.setDirectoriesListed(true);
this.setAliases(allow_symlinks); this.setBaseResource(createFileResource(getFile(getWebPath()).getAbsolutePath()));
this.setWelcomeFiles(new String[] { "index.html" }); }});
this.setDirectoriesListed(true); this.addHandler("/tiles/", new ResourceHandler() {{
this.setBaseResource(createFileResource(getFile(getWebPath()).getAbsolutePath())); this.setAliases(allow_symlinks);
}}); this.setWelcomeFiles(new String[] { });
this.addHandler("/tiles/", new ResourceHandler() {{ this.setDirectoriesListed(true);
this.setAliases(allow_symlinks); this.setBaseResource(createFileResource(tilesDirectory.toString()));
this.setDirectoriesListed(true);
this.setBaseResource(createFileResource(tilesDirectory.toString()));
}});
}}); }});
}}; }};
@ -458,7 +455,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
/* Load customized response headers, if any */ /* Load customized response headers, if any */
filters.add(new CustomHeaderFilter(configuration.getNode("http-response-headers"))); filters.add(new CustomHeaderFilter(configuration.getNode("http-response-headers")));
webServer.setHandler(/*new FilterHandler(*/context/*, filters)*/); webServer.setHandler(new FilterHandler(router, filters));
addServlet("/up/configuration", new org.dynmap.servlet.ClientConfigurationServlet(this)); addServlet("/up/configuration", new org.dynmap.servlet.ClientConfigurationServlet(this));

View File

@ -49,7 +49,6 @@ public class FilterHandler extends AbstractHandler {
public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException { public void handle(final String target, final Request baseRequest, final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException {
final Handler handler = this.getHandler(); final Handler handler = this.getHandler();
final Iterator<FilterHolder> iterator = getFilters().iterator(); final Iterator<FilterHolder> iterator = getFilters().iterator();
Log.info("Filtering..." + request.getPathInfo());
final FilterChain chain = new FilterChain() { final FilterChain chain = new FilterChain() {
@Override @Override
public void doFilter(ServletRequest re, ServletResponse rs) throws IOException, ServletException { public void doFilter(ServletRequest re, ServletResponse rs) throws IOException, ServletException {
@ -57,7 +56,6 @@ public class FilterHandler extends AbstractHandler {
Filter f = iterator.next().getFilter(); Filter f = iterator.next().getFilter();
f.doFilter(request, response, this); f.doFilter(request, response, this);
} else { } else {
Log.info("Handling...");
handler.handle(target, baseRequest, request, response); handler.handle(target, baseRequest, request, response);
} }
} }