Skip to content

Commit 9706e5c

Browse files
committed
Update Javadoc on SockJS client library URL
Issue: SPR-11766
1 parent 5cb3f8e commit 9706e5c

File tree

3 files changed

+44
-17
lines changed

3 files changed

+44
-17
lines changed

spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,22 @@ public SockJsServiceRegistration setTaskScheduler(TaskScheduler taskScheduler) {
7373
}
7474

7575
/**
76-
* Transports which don't support cross-domain communication natively (e.g.
77-
* "eventsource", "htmlfile") rely on serving a simple page (using the
78-
* "foreign" domain) from an invisible iframe. Code run from this iframe
79-
* doesn't need to worry about cross-domain issues since it is running from
80-
* a domain local to the SockJS server. The iframe does need to load the
81-
* SockJS javascript client library and this option allows configuring its url.
82-
* See the reference documentation for more details on this.
76+
* Transports with no native cross-domain communication (e.g. "eventsource",
77+
* "htmlfile") must get a simple page from the "foreign" domain in an invisible
78+
* iframe so that code in the iframe can run from a domain local to the SockJS
79+
* server. Since the iframe needs to load the SockJS javascript client library,
80+
* this property allows specifying where to load it from.
8381
*
8482
* <p>By default this is set to point to
85-
* "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js".
83+
* "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js". However it can
84+
* also be set to point to a URL served by the application.
85+
*
86+
* <p>Note that it's possible to specify a relative URL in which case the URL
87+
* must be relative to the iframe URL. For example assuming a SockJS endpoint
88+
* mapped to "/sockjs", and resulting iframe URL "/sockjs/iframe.html", then the
89+
* the relative URL must start with "../../" to traverse up to the location
90+
* above the SockJS mapping. In case of a prefix-based Servlet mapping one more
91+
* traversal may be needed.
8692
*/
8793
public SockJsServiceRegistration setClientLibraryUrl(String clientLibraryUrl) {
8894
this.clientLibraryUrl = clientLibraryUrl;

spring-websocket/src/main/java/org/springframework/web/socket/sockjs/support/AbstractSockJsService.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,22 @@ public String getName() {
101101
}
102102

103103
/**
104-
* Transports which don't support cross-domain communication natively (e.g.
105-
* "eventsource", "htmlfile") rely on serving a simple page (using the
106-
* "foreign" domain) from an invisible iframe. Code run from this iframe
107-
* doesn't need to worry about cross-domain issues since it is running from
108-
* a domain local to the SockJS server. The iframe does need to load the
109-
* SockJS javascript client library and this option allows configuring that url.
110-
* For more details see the reference documentation.
104+
* Transports with no native cross-domain communication (e.g. "eventsource",
105+
* "htmlfile") must get a simple page from the "foreign" domain in an invisible
106+
* iframe so that code in the iframe can run from a domain local to the SockJS
107+
* server. Since the iframe needs to load the SockJS javascript client library,
108+
* this property allows specifying where to load it from.
111109
*
112110
* <p>By default this is set to point to
113-
* "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js".
111+
* "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js". However it can
112+
* also be set to point to a URL served by the application.
113+
*
114+
* <p>Note that it's possible to specify a relative URL in which case the URL
115+
* must be relative to the iframe URL. For example assuming a SockJS endpoint
116+
* mapped to "/sockjs", and resulting iframe URL "/sockjs/iframe.html", then the
117+
* the relative URL must start with "../../" to traverse up to the location
118+
* above the SockJS mapping. In case of a prefix-based Servlet mapping one more
119+
* traversal may be needed.
114120
*/
115121
public void setSockJsClientLibraryUrl(String clientLibraryUrl) {
116122
this.clientLibraryUrl = clientLibraryUrl;

spring-websocket/src/main/resources/org/springframework/web/socket/config/spring-websocket-4.0.xsd

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,22 @@
144144
<xsd:attribute name="client-library-url" type="xsd:string">
145145
<xsd:annotation>
146146
<xsd:documentation source="java:org.springframework.web.socket.sockjs.support.AbstractSockJsService"><![CDATA[
147-
URL of the JavaScript client library. Defaults to "https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js".
147+
Transports with no native cross-domain communication (e.g. "eventsource",
148+
"htmlfile") must get a simple page from the "foreign" domain in an invisible
149+
iframe so that code in the iframe can run from a domain local to the SockJS
150+
server. Since the iframe needs to load the SockJS javascript client library,
151+
this property allows specifying where to load it from.
152+
153+
By default this is set to point to
154+
"https://d1fxtkz8shb9d2.cloudfront.net/sockjs-0.3.4.min.js". However it can
155+
also be set to point to a URL served by the application.
156+
157+
Note that it's possible to specify a relative URL in which case the URL
158+
must be relative to the iframe URL. For example assuming a SockJS endpoint
159+
mapped to "/sockjs", and resulting iframe URL "/sockjs/iframe.html", then the
160+
The relative URL must start with "../../" to traverse up to the location
161+
above the SockJS mapping. In case of a prefix-based Servlet mapping one more
162+
traversal may be needed.
148163
]]></xsd:documentation>
149164
</xsd:annotation>
150165
</xsd:attribute>

0 commit comments

Comments
 (0)