Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Standardize WebSocket integration with f:websocket #1396

Closed
glassfishrobot opened this issue Aug 12, 2015 · 22 comments
Closed

Standardize WebSocket integration with f:websocket #1396

glassfishrobot opened this issue Aug 12, 2015 · 22 comments

Comments

@glassfishrobot
Copy link

Standardize WebSocket integration with f:websocket

@glassfishrobot
Copy link
Author

Reported by @edburns

@glassfishrobot
Copy link
Author

@BalusC said:
Attached a git patch with initial commit of a functional f:socket tag.

As discussed, I dropped SSE support as it isn't standardized and has less browser support (no Microsoft IE/Edge), while WS is standardized, even in Java EE (JSR356), and has better browser support and is more efficient (no persistent open connection).

@glassfishrobot
Copy link
Author

@BalusC said:
After testing on various servers I have futher improved the script and logic. Also a new context param is added to explicitly enable the push (lazy initialization turned out to not work on Tyrus WS implementation).

@glassfishrobot
Copy link
Author

@BalusC said:
Proposal for PartialViewContext#getEvalScripts() has been splitted to https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1412

@glassfishrobot
Copy link
Author

@BalusC said:
Replaced git patch with current f:websocket tag.

@glassfishrobot
Copy link
Author

@BalusC said:
Replaced git patch with current f:websocket tag, now with session scope support

@glassfishrobot
Copy link
Author

@BalusC said:
Replaced git patch with current f:websocket tag, now with view scope, user-target and CDI event support.

@glassfishrobot
Copy link
Author

@BalusC said:
Replaced git patch with current f:websocket tag, now with test case.

@glassfishrobot
Copy link
Author

File: JAVASERVERFACES_SPEC_PUBLIC-1396.patch
Attached By: @BalusC

@glassfishrobot
Copy link
Author

@glassfishrobot
Copy link
Author

@BalusC said:
<f:websocket> has been added, along with 2 testcases (one to test context param and another to test three different push channels (app/session/view))

@glassfishrobot
Copy link
Author

@BalusC said:
(reopened accidentally closed issue)

Commited improvement as to handling of jsf.js script (refactored utility from AjaxHandler into RenderKitUtils so it can be reused by WebsocketHandler's WebsocketFacesListener). Initial implementation broke state saving.

https://java.net/projects/mojarra/sources/git/revision/ac4253639ed23eace38451fff3c33c6e9780be2b

@glassfishrobot
Copy link
Author

@BalusC said:
Test case failed on Hudson with development stage enabled; it has now been fixed.

https://java.net/projects/mojarra/sources/git/revision/9c65817db3c9e80421911692e83319ad8c97ac1e

@glassfishrobot
Copy link
Author

@BalusC said:
All tests have passed. Closing out issue.

@glassfishrobot
Copy link
Author

@BalusC said:
Reopening to improve spec further.

1. f:websocket needs to be an UIComponent implementing ClientBehaviorHolder
2. jsf.push.init needs to take clientID + full URL
3. jsf.push.open/close needs to take clientID instead of channel
4. ViewHandler should have a getWebsocketURL() or something like that

@glassfishrobot
Copy link
Author

@BalusC said:
1. 2. 3. are done. TODO: 4.

@glassfishrobot
Copy link
Author

@edburns said:
Update Spec Section "Related Technologies" to include requirement on WebSocket 1.1 <https://www.jcp.org/en/jsr/detail?id=356>.

5ff3e2b

@glassfishrobot
Copy link
Author

@edburns said:
Remove requirement for fake endpoint.

@glassfishrobot
Copy link
Author

@BalusC said:
Another requirement: JSONP 1.0 <https://www.jcp.org/en/jsr/detail?id=353>

@glassfishrobot
Copy link
Author

@BalusC said:
ViewHandler#getWebsocketURL() and ExternalContext#encodeWebsocketURL() have been added

/**
     * <p class="changed_added_2_3">If the value returned from this
     * method is used as the <code>file</code> argument to the
     * four-argument constructor for <code>java.net.URL</code> (assuming
     * appropriate values are used for the first three arguments), then
     * a client making a push handshake request to the <code>toExternalForm()</code> of
     * that <code>URL</code> will select the argument <code>channel</code>
     * for connecting the websocket push channel in the current view.
     * It must match the {@link PushContext#URI_PREFIX} of the endpoint.</p>
     *
     * @param context {@link FacesContext} for the current request.
     * @param channel The channel name of the websocket.
     * 
     * @throws NullPointerException if <code>context</code> or
     *  <code>channel</code> is <code>null</code>.
     * 
     * @return the websocket URL.
     * @see PushContext#URI_PREFIX
     */
    public abstract String getWebsocketURL(FacesContext context, String channel);
/**
     * <p>
     * Return the websocket URL, after performing any rewriting needed to
     * ensure that it will correctly identify an addressable websocket in the
     * current application.
     * </p>
     * 
     * <p>
     * <em>Servlet:</em> This must ensure that the input URL is prefixed 
     * with the correct websocket scheme, domain and port and then
     * encoded by {@link #encodeResourceURL(String)}.
     * </p>
     *
     * @param url The input URL to be encoded.
     * 
     * @return the encoded websocket URL.
     * 
     * @throws NullPointerException if <code>url</code> is <code>null</code>.
     * 
     * @since 2.3
     */
    public abstract String encodeWebsocketURL(String url);

<f:websocket> and jsf.push.init() have been modified to drop port attribute and argument.

@glassfishrobot
Copy link
Author

Marked as fixed on Friday, December 23rd 2016, 10:38:07 am

@glassfishrobot
Copy link
Author

This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-1396

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants