frjaeger220 / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
0 stars 0 forks source link

javadoc ServletModule unclear #453

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Question about the javadoc (and internal workgs) for
com.google.inject.servlet.ServletModule.configureServlets().

It says: 

"Dispatch Order - You are free to register as many servlets and filters as
you like this way. They will be compared and dispatched in the order in
which the filter methods are called. (... piece of code ...) This will
traverse down the list of rules in lexical order."

I find this a bit confusing. Are the rules traversed in the order in which
they are defined by the programmer (top-down the mapping code in
.configureServlets()), or in some kind of alphabetical ordering (my
understanding of lexical was that it has something to do with a dictionary
or an alphabet; but I may be wrong...).

An experiment shows the mapping rules are applied in the order in which
they are defined. In our case we had this:

 Map<String, String> params = new HashMap<String, String>();
 params.put("applicationFactoryClassName",
"org.apache.wicket.guice.GuiceWebApplicationFactory");
 params.put("injectorContextAttribute", "com.google.inject.Injector");
 bind(WicketServlet.class).in(Singleton.class);
 serve("/*").with(WicketServlet.class, params);
 serve("/monitor/statusPing").with(MonitorServlet.class);

that is, one specific mapping followed by a /* mapping to the
WicketServlet. With the above code, the /monitor/statusPing is never
applied. When I put the /monitor/statusPing above the /* mapping it does
work. So there's nothing lexical about it?

I think it's also worth stating clearly in the Javadoc that the mapping
rules are different from what the Servlet specs say (I think the Servlet
specs say the container will first look for an exact match; followed by
some more complex rules that aren't mentioned in guice-servlet.)

Original issue reported on code.google.com by guido.he...@gmail.com on 11 Dec 2009 at 9:44

GoogleCodeExporter commented 9 years ago

Original comment by sberlin on 22 Feb 2011 at 1:43