I think this is a very subtle nuance of documented behavior ServletContainer, if it is not a direct mistake. ServletContainerdocs regarding initialization parameters read as:
ResourceConfig.
. , ResourceConfig ServletContainer, , , . Application, new ServletContainer(application), :
ServletContainer Application:
public ServletContainer(Application app) {
this.app = app;
}
ServletContainer Servlet:
protected void init(WebConfig webConfig) throws ServletException {
webComponent = (app == null)
? new InternalWebComponent()
: new InternalWebComponent(app);
webComponent.init(webConfig);
}
Application InternalWebComponent. InternalWebComponent - WebComponent, :
InternalWebComponent(Application app) {
super(app);
}
:
public WebComponent(Application app) {
if (app == null)
throw new IllegalArgumentException();
if (app instanceof ResourceConfig) {
resourceConfig = (ResourceConfig) app;
} else {
resourceConfig = new ApplicationAdapter(app);
}
}
, Application , if ResourceConfig. WebComponent.init() (. ServletContainer.init() , ). init() " ResourceConfig", , , , , . I.e., ResourceConfig , :
public void init(WebConfig webConfig) throws ServletException {
...
if (resourceConfig == null)
resourceConfig = createResourceConfig(config);
...
}
createResourceConfig() ( WebComponent) :
private ResourceConfig createResourceConfig(WebConfig webConfig)
throws ServletException {
final Map<String, Object> props = getInitParams(webConfig);
final ResourceConfig rc = createResourceConfig(webConfig, props);
rc.setPropertiesAndFeatures(props);
return rc;
}
, setPropertiesAndFeatures() ResourceConfig. , , , , - ServletContainer .
, ServletContainer no-arg , Servlet 3.0, , . .
, : ServletContainer :
Map<String, Object> props = getInitParams(webConfig);
rc.setPropertiesAndFeatures(props);
, , . , Application init, , :
servletHolder.setInitParameter("javax.ws.rs.Application", "org.foo.MyApplication");
, "" , WebComponent ResourceConfig init .