Hi Group,
I am using SiteMesh 3.0-alpha-2 in an application which also provides some REST endpoints using JAX-RS and it is running on GlassFish 3.1.2. In the application I defined a JAX-RS ApplicationConfig and mapped the endpoint to "/api":
@ApplicationPath("/api")
public class RestApp extends Application {
}
I also defined a REST endpoint under "/test" (method = GET)
@Path("/test")
@Stateless
public class RestEndpoint {
@GET
public String test() {
return "blah";
}
}
So I can access my RestEndpoint via http://host:port/MyApplication/api/test - works fine so far.
Now I added SiteMesh and defined an excludePath in my configuration. I also added a default decorator:
@WebFilter("/*")
public class SitemeshFilter extends org.sitemesh.config.ConfigurableSiteMeshFilter{
@Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
builder
.addExcludedPath("/api/*")
.addDecoratorPath("/*", "/decorators/baseDecorator.html");
}
}
If I am accessing my API as described above, the result is also decorated and that was not my intention.
So I downloaded the sources and tried to figure out how the excludes are mapped. As far as I understand SiteMesh the class BasicSelector and BaseSiteMeshFilterBuilder which overrides shouldBufferForRequest handles the exclusions. It uses the requestPath and does a lookup in the excludesmapper. So i did some debugging and found out, that the requestPath is not the same I entered in the browser... My expectation was, that when I enter http://host:port/MyApplication/api/test, the requestPath would be /api/test. But it's not. It is only /api.... so I changed my WebFilter the following way:
@WebFilter("/*")
public class SitemeshFilter extends org.sitemesh.config.ConfigurableSiteMeshFilter{
@Override
protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {
builder
.addExcludedPath("/api/*")
.addExcludedPath("/api")
.addDecoratorPath("/*", "/decorators/baseDecorator.html");
}
}
That works...
The method getRequestPath in the class WebAppContext calculates the path and for http://host:port/MyApplication/api/test it only returns /api. I am not sure if I am wrong, but shouldn't SiteMesh also evaluate the pathInfo? Right now in my case only the servletPath is evaluated.
Well... that mapping is quite complex - to me it would be useful to have more logging :)