This commit is contained in:
@@ -36,6 +36,7 @@ public final class HttpPrepareServlet extends PrepareServlet<HttpContext, HttpRe
|
|||||||
@Override
|
@Override
|
||||||
public void init(HttpContext context, AnyValue config) {
|
public void init(HttpContext context, AnyValue config) {
|
||||||
this.servlets.stream().forEach(s -> {
|
this.servlets.stream().forEach(s -> {
|
||||||
|
if (s instanceof WebSocketServlet) ((WebSocketServlet) s).preInit(context, s._conf);
|
||||||
s.init(context, s._conf);
|
s.init(context, s._conf);
|
||||||
});
|
});
|
||||||
final WatchFactory watch = context.getWatchFactory();
|
final WatchFactory watch = context.getWatchFactory();
|
||||||
@@ -131,6 +132,7 @@ public final class HttpPrepareServlet extends PrepareServlet<HttpContext, HttpRe
|
|||||||
this.resourceHttpServlet.destroy(context, config);
|
this.resourceHttpServlet.destroy(context, config);
|
||||||
this.servlets.stream().forEach(s -> {
|
this.servlets.stream().forEach(s -> {
|
||||||
s.destroy(context, s._conf);
|
s.destroy(context, s._conf);
|
||||||
|
if (s instanceof WebSocketServlet) ((WebSocketServlet) s).postDestroy(context, s._conf);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ import org.redkale.util.*;
|
|||||||
*
|
*
|
||||||
* </pre></blockquote>
|
* </pre></blockquote>
|
||||||
*
|
*
|
||||||
* <p> 详情见: http://www.redkale.org
|
* <p>
|
||||||
|
* 详情见: http://www.redkale.org
|
||||||
|
*
|
||||||
* @author zhangjx
|
* @author zhangjx
|
||||||
*/
|
*/
|
||||||
public abstract class WebSocketServlet extends HttpServlet {
|
public abstract class WebSocketServlet extends HttpServlet {
|
||||||
@@ -62,8 +64,7 @@ public abstract class WebSocketServlet extends HttpServlet {
|
|||||||
|
|
||||||
protected WebSocketEngine engine;
|
protected WebSocketEngine engine;
|
||||||
|
|
||||||
@Override
|
final void preInit(HttpContext context, AnyValue conf) {
|
||||||
public void init(HttpContext context, AnyValue conf) {
|
|
||||||
InetSocketAddress addr = context.getServerAddress();
|
InetSocketAddress addr = context.getServerAddress();
|
||||||
this.engine = new WebSocketEngine(addr.getHostString() + ":" + addr.getPort() + "-[" + name() + "]", this.node, logger);
|
this.engine = new WebSocketEngine(addr.getHostString() + ":" + addr.getPort() + "-[" + name() + "]", this.node, logger);
|
||||||
this.node.putWebSocketEngine(engine);
|
this.node.putWebSocketEngine(engine);
|
||||||
@@ -71,8 +72,7 @@ public abstract class WebSocketServlet extends HttpServlet {
|
|||||||
this.engine.init(conf);
|
this.engine.init(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
final void postDestroy(HttpContext context, AnyValue conf) {
|
||||||
public void destroy(HttpContext context, AnyValue conf) {
|
|
||||||
this.node.destroy(conf);
|
this.node.destroy(conf);
|
||||||
super.destroy(context, conf);
|
super.destroy(context, conf);
|
||||||
engine.close();
|
engine.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user