Wicket 6930 websocket improvements#479
Conversation
|
@martin-g Not very sure about the pageCLass I have introduced. Maybe call this "context"? i.e. page class is just a. context? |
There was a problem hiding this comment.
About the new pageClass attribute:
- PageIdKey is no more accurate name, since it is not just the
idanymore. But renaming it would be an API break - What if someone wants to do the same with a resource based WebSocket behavior ?
IMO we should move this logic at IKey level.
And if we can avoid class loading it would be better, but I am not sure how exactly to do it yet!
| progressUpdateTask.cancel(); | ||
| } | ||
|
|
||
| public static JSR356Session getInstance() { |
| return; | ||
| } | ||
| ScheduledExecutorService service = JSR356Application.get().getScheduledExecutorService(); | ||
| progressUpdateTask = ProgressUpdater.start(getApplication(), getId(), service); |
There was a problem hiding this comment.
You can cache the value of JSR356Application.get() and reuse it instead of calling getApplication()
| add(new WebSocketBehavior() | ||
| { | ||
| @Override | ||
| protected void onConnect(ConnectedMessage message) { |
There was a problem hiding this comment.
this override is not really needed here
| progressUpdateTask = ProgressUpdater.start(getApplication(), getId(), service); | ||
| } | ||
|
|
||
| public synchronized void cancel() { |
| ProgressUpdater.ProgressUpdateTask progressUpdateTask = JSR356Session.getInstance().getProgressUpdateTask(); | ||
| if (progressUpdateTask != null && progressUpdateTask.isRunning() && !progressUpdateTask.isCanceled()) | ||
| { | ||
| progressUpdateTask.cancel(); |
There was a problem hiding this comment.
You can simplify it to JSR356Session.getInstance().cancelTask();
| interface IConnectionsFilter | ||
| { | ||
|
|
||
| boolean acceptConnection(String sessionId, IKey key); |
| this.pageId = Args.notNull(pageId, "pageId"); | ||
| Args.notNull(pageClass, "pageClass"); | ||
| try { | ||
| this.pageClass = (Class<IManageablePage>)Thread.currentThread().getContextClassLoader().loadClass(pageClass); |
| try { | ||
| this.pageClass = (Class<IManageablePage>)Thread.currentThread().getContextClassLoader().loadClass(pageClass); | ||
| } catch (ClassNotFoundException e) { | ||
| //throw new WicketRuntimeException(e); |
There was a problem hiding this comment.
This does not look good! Most probably we should not ignore the problem.
There was a problem hiding this comment.
Yes. No longer pertinent.
| * The name of the request parameter that holds the application name | ||
| */ | ||
| private static final String WICKET_APP_PARAM_NAME = "wicket-app-name"; | ||
| private static final String WICKET_SESSION_ID = "jsessionid"; |
| public void onOpen(Session session, EndpointConfig endpointConfig) | ||
| { | ||
| String appName = getApplicationName(session); | ||
| session.getId(); |
There was a problem hiding this comment.
Hum... Got rid of this
|
@martin-g many thanks for your comments! I will go through them right now |
Good point. This is why I thought about context. Maybe call this context and move this to a common Ikey?
Ok. I will give it a try. |
| import org.apache.wicket.protocol.http.WebSession; | ||
| import org.apache.wicket.request.Request; | ||
|
|
||
| public class JSR356Session extends WebSession { |
There was a problem hiding this comment.
The opening curly bracket should be on a new line.
|
@martin-g Many thanks for review and useful comments! I will squash commits and merge to wicket 9.x. |
|
And cherry-pick the final commit to |
…ages 2) pass page class as a kind of context that can be used to send a web socket to different pages + example of updating a component in a given page (not dependent on page ID)
dd443bc to
04aaa7f
Compare
Done! Thanks again for your help! |


This PR adds some extra functionality to WS implementation. Not sure if this can be done in a cleaner way or a more general one. This adds.