【发布时间】:2015-04-11 12:33:23
【问题描述】:
我正在尝试弄清楚如何为我的代码单例绑定一个 servlet:
public class GuiceServletModule extends ServletModule {
@Override
protected void configureServlets() {
Map<String, String> params = new HashMap<String, String>();
params.put("org.restlet.application", "com.mycomp.server.RestletApplication");
serve("/rest/*").with(org.restlet.ext.servlet.ServerServlet.class, params);
serve("/remote_api").with(com.google.apphosting.utils.remoteapi.RemoteApiServlet.class);
}
}
这里的问题是应用程序需要服务的两个servelet 都是第三方库(Restlet 和GAE)。
抛出的异常是:
[INFO] javax.servlet.ServletException: Servlets must be bound as singletons. Key[type=org.restlet.ext.servlet.ServerServlet, annotation=[none]] was not bound in singleton scope.
当 servlet 是至少目前无法修改的第三方库时,我该如何处理。是否有解决方法来完成这项工作?
【问题讨论】:
标签: java google-app-engine servlets guice