spring-websocket-test icon indicating copy to clipboard operation
spring-websocket-test copied to clipboard

Make SnakeTimer a bean, rather than a class with static fields methods

Open Glamdring opened this issue 12 years ago • 1 comments

Wouldn't it be better if https://github.com/rstoyanchev/spring-websocket-test/blob/master/src/main/java/org/springframework/samples/websocket/snake/SnakeTimer.java is a bean, injected into the handler, rather than a class with static fields and methods?

In reality, one may need to inject other beans into that one, make use of proxies, etc. so it would be nice for an example to present it as a spring bean.

Glamdring avatar Nov 22 '13 15:11 Glamdring

I haven't thought about it very much. The example was copied from the Tomcat samples with only minor modifications. It was never the my goal to revise it very thoroughly. What I do like is having an example where a new WebSocketHandler is created per client session. Whether it is the best example for that or not is another question, you may be right. If you want to take it further and rework the example a bit, feel free to submit a PR.

I did see some sample changes in Tomcat trunk flying by recently but did not look closely. It might be worth taking a look there if you decide to spend any time. Thanks.

rstoyanchev avatar Nov 25 '13 19:11 rstoyanchev