現在、このように main() メソッドに雰囲気を実装しています
public static void main(String[] args) throws IOException {
final HttpServer server = HttpServer.createSimpleServer(".", 8181);
WebappContext ctx = new WebappContext("Socket", "/");
//allow spring to do all of it's stuff
ctx.addListener("org.springframework.web.context.ContextLoaderListener");
//enable web socket support
final WebSocketAddOn addon = new WebSocketAddOn();
for (NetworkListener listener : server.getListeners()) {
listener.registerAddOn(addon);
//if false, local files (html, etc.) can be modified without restarting the server
//@todo experiment with this setting in production vs development
listener.getFileCache().setEnabled(false);
}
//add jersey servlet support
ServletRegistration jerseyServletRegistration = ctx.addServlet("JerseyServlet", new ServletContainer());
//jerseyServletRegistration.setInitParameter("com.sun.jersey.config.property.packages", "come.fettergroup.production.queue.resources");
jerseyServletRegistration.setLoadOnStartup(1);
jerseyServletRegistration.addMapping("/api/*");
//add atmosphere servlet support
ServletRegistration atmosphereServletRegistration = ctx.addServlet("AtmosphereServlet", new AtmosphereServlet());
atmosphereServletRegistration.setInitParameter("org.atmosphere.websocket.messageContentType", "application/json");
atmosphereServletRegistration.setInitParameter("com.sun.jersey.api.json.POJOMappingFeature", "true");
atmosphereServletRegistration.setLoadOnStartup(1);
この XML ファイルを取得して同じことを達成するにはどうすればよいでしょうか。ただし、上記のコードでは?
<atmosphere-handlers>
<atmosphere-handler context-root="/api" class-name="org.atmosphere.handler.ReflectorServletProcessor">
<property name="servletClassName"
value="com.sun.jersey.spi.spring.container.servlet.SpringServlet" />
</atmosphere-handler>
</atmosphere-handlers>
Atmosphere にハンドラーを割り当てることを検討しましたが、 AtmosphereFramework
取得できないインスタンスが必要です。