Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize WebSocket integration with f:websocket #1396

Closed
eclipse-faces-bot opened this issue Aug 12, 2015 · 23 comments
Closed

Standardize WebSocket integration with f:websocket #1396

eclipse-faces-bot opened this issue Aug 12, 2015 · 23 comments

Comments

@eclipse-faces-bot
Copy link

Standardize WebSocket integration with f:websocket

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
Reported by @edburns

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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).

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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).

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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))

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

5ff3e2b

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@edburns said:
Remove requirement for fake endpoint.

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

@glassfishrobot Commented
@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.

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

@eclipse-faces-bot
Copy link
Author

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

No branches or pull requests

1 participant