Commit Graph

575 Commits

Author SHA1 Message Date
Rossen Stoyanchev d1cc8bac5c Add config option for StompSubProtocolErrorHandler
Issue: SPR-13142
2015-06-22 22:30:44 -04:00
Juergen Hoeller 92bf32b9be Polishing 2015-05-23 20:04:48 +02:00
Juergen Hoeller e0a11f2ae7 SockJsTransportFailureException provides constructor variant without session id 2015-05-23 20:02:42 +02:00
Juergen Hoeller 05d475a275 Polishing 2015-05-22 23:50:47 +02:00
Rossen Stoyanchev c48e8708a7 Fix NPE in DefaultSimpUserRegistry 2015-05-22 13:44:09 -04:00
Rossen Stoyanchev 92bd7bba50 Restore userSessionRegistry field in StompSubProtocolHandler
This change ensures that the deprecated UserSessionRegistry is still
used if configured.
2015-05-22 13:44:09 -04:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Stephane Nicoll cf391f5ce1 polish
Remove unused imports
2015-05-19 08:49:01 +02:00
Rossen Stoyanchev 696a010e81 Add SubProtocolErrorHandler
Issue: SPR-12732
2015-05-15 18:18:05 -04:00
Juergen Hoeller 02d28ae9ee Actual hasText assertion in SockJsFrame
Issue: SPR-13019
2015-05-13 14:54:36 +02:00
Juergen Hoeller 49c600b234 Resolved cyclic dependency between handler.invocation and handler.annotation
Issue: SPR-12696
2015-05-12 22:04:59 +02:00
Rossen Stoyanchev 281588d7bb Add SimpUserRegistry with multi-server support
This change introduces SimpUserRegistry exposing an API to access
information about connected users, their sessions, and subscriptions
with STOMP/WebSocket messaging. Provides are methods to access users
as well as a method to find subscriptions given a Matcher strategy.

The DefaultSimpUserRegistry implementation is also a
SmartApplicationListener which listesn for ApplicationContext events
when users connect, disconnect, subscribe, and unsubscribe to
destinations.

The MultiServerUserRegistry implementation is a composite that
aggregates user information from the local SimpUserRegistry as well
as snapshots of user  on remote application servers.

UserRegistryMessageHandler is used with MultiServerUserRegistry. It
broadcats user registry information through the broker and listens
for similar broadcasts from other servers. This must be enabled
explicitly when configuring the STOMP broker relay.

The existing UserSessionRegistry which was primiarly used internally
to resolve a user name to session id's has been deprecated and is no
longer used. If an application configures a custom UserSessionRegistr
still, it will be adapted accordingly to SimpUserRegistry but the
effect is rather limited (comparable to pre-existing functionality)
and will not work in multi-server scenarios.

Issue: SPR-12029
2015-05-12 15:29:12 -04:00
Brian Clozel 4b07bc39da Always set heart-beat header in STOMP CONNECTED frames
Since SPR-10954, the SimpleBrokerMessageHandler supports `heart-beats`.

Even if the STOMP spec states that the `heart-beat` header is OPTIONAL,
and if absent considered as `heart-beat: 0,0`,
some clients rely on this to be set in CONNECTED frames.

This commit adds this header information even if no task
scheduler/heart-beat have been configured.

See: https://stomp.github.io/stomp-specification-1.2.html#Heart-beating

Issue: SPR-10954
2015-05-05 16:09:42 +02:00
Sam Brannen 572cbb0821 Consistently supply test name to @Parameters 2015-05-05 14:07:00 +02:00
Sebastien Deleuze 83f269b512 Make DefaultCorsProcessor Servlet 2.5 compliant
This commit adds CORS related headers to HttpHeaders
and update DefaultCorsProcessor implementation to
use ServerHttpRequest and ServerHttpResponse instead
of HttpServletRequest and HttpServletResponse. Usage
of ServerHttpResponse allows to avoid using Servlet 3.0
specific methods in order keep CORS support Servlet 2.5
compliant.

Issue: SPR-12885
2015-05-05 09:31:41 +02:00
Rossen Stoyanchev 49e90575e9 Disable ShallowEtagHeaderFilter for HTTP streaming
Issue: SPR-12960
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev 68ecb92d1f Allow "ws" and "wss" for isValidCorsOrigin checks
Issue: SPR-12956
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev 222f6998e4 Add userProperties to StandardWebSocketClient
Issue: SPR-12955
2015-05-04 06:08:25 -04:00
Rossen Stoyanchev c29eae3307 Support user destinations with multiple app servers
This change adds support for broadcasting messages with unresolved
user destinations so that other servers can try to resolve it.
That enables sending messages to users who may be connected to a
different server.

Issue: SPR-11620
2015-04-17 11:55:44 -04:00
Rossen Stoyanchev a3df66931f Add path-helper attribute for websocket namespace
Issue: SPR-11771
2015-04-13 22:39:50 -04:00
Rossen Stoyanchev de9675bf5a Support heartbeat in SimpleBrokerMessageHandler
Issue: SPR-10954
2015-04-06 16:57:23 -04:00
Sebastien Deleuze b0e1e66b7f Add CORS support
This commit introduces support for CORS in Spring Framework.

Cross-origin resource sharing (CORS) is a mechanism that allows
many resources (e.g. fonts, JavaScript, etc.) on a web page to
be requested from another domain outside the domain from which
the resource originated. It is defined by the CORS W3C
recommandation (http://www.w3.org/TR/cors/).

A new annotation @CrossOrigin allows to enable CORS support
on Controller type or method level. By default all origins
("*") are allowed.

@RestController
public class SampleController {

	@CrossOrigin
	@RequestMapping("/foo")
	public String foo() {
		// ...
	}
}

Various @CrossOrigin attributes allow to customize the CORS configuration.

@RestController
public class SampleController {

	@CrossOrigin(origin = { "http://site1.com", "http://site2.com" },
				 allowedHeaders = { "header1", "header2" },
				 exposedHeaders = { "header1", "header2" },
				 method = RequestMethod.DELETE,
				 maxAge = 123, allowCredentials = "true")
	@RequestMapping(value = "/foo", method = { RequestMethod.GET, RequestMethod.POST} )
	public String foo() {
		// ...
	}
}

A CorsConfigurationSource interface can be implemented by HTTP request
handlers that want to support CORS by providing a CorsConfiguration
that will be detected at AbstractHandlerMapping level. See for
example ResourceHttpRequestHandler that implements this interface.

Global CORS configuration should be supported through ControllerAdvice
(with type level @CrossOrigin annotated class or class implementing
CorsConfigurationSource), or with XML namespace and JavaConfig
configuration, but this is not implemented yet.

Issue: SPR-9278
2015-04-02 16:12:11 +02:00
Brian Clozel 100d75da26 Fix client-library-url ignored in MVC namespace
Prior to this commit, the `client-library-url` XML attribute was not
effective in the MVC namespace, leaving the default value configured:

```xml
<websocket:sockjs client-library-url="/js/sockjs.js" />
```

This commit fixes the sockjs namespace handler and makes sure that this
attribute is configured on the `SockJsService` Bean to be created.

Issue: SPR-12874
2015-04-01 14:44:12 +02:00
Rossen Stoyanchev 73d6d30951 Add flag whether to create HTTP session
Issue: SPR-12840
2015-03-26 17:28:26 -04:00
Juergen Hoeller d23893fd25 Consistent javadoc param declarations for type variables 2015-03-25 00:44:01 +01:00
Rossen Stoyanchev e81862eed6 Allow modifying HandshakeInterceptor list
The getter in TransportHandlingSockJsService now returns a mutable
List. The immutable wrapper doesn't make sense since it's possible
anyway to modify the list by creating a new list and calling the
setter again. It's also consistent with the same field on
WebSocketHttpRequestHandler.

This is related to work for SPR-12845.
2015-03-24 18:03:15 -04:00
Rossen Stoyanchev 0c9cd4cc32 SubProtocolWebSocketHandler checks if session is open
Issue: SPR-12812
2015-03-20 17:45:27 -04:00
Rossen Stoyanchev 41e437066e Support @MessageExceptionHandler w/ @ControllerAdvice
This change adds support for global @MessageExceptionHandler methods
with STOMP over WebSocket messages. Such methods can be added to
@ControllerAdvice annotated components, much like @ExceptionHandler
methods for Spring MVC.

Issue: SPR-12696
2015-03-19 14:21:24 -04:00
Sam Brannen 8ee0e98540 Ensure WebSocketStompClientTests compiles in Gradle build as well 2015-03-17 18:47:24 +01:00
Sam Brannen 9930a8715f Clean up & suppress warnings in spring-messaging 2015-03-17 17:58:32 +01:00
Sam Brannen 03739c25d3 Ensure WebSocketStompClientTests compiles in STS 3.6.4 2015-03-17 17:46:46 +01:00
Rossen Stoyanchev d30b3eaf55 Add STOMP client
WebSocketStompClient can be used with any implementation of
org.springframework.web.socket.client.WebSocketClient, which includes
org.springframework.web.socket.sockjs.client.SockJsClient.

Reactor11TcpStompClient can be used with reactor-net and provides STOMP
over TCP. It's also possible to adapt other WebSocket and TCP client
libraries (see StompClientSupport for more details).

For example usage see WebSocketStompClientIntegrationTests.

Issue: SPR-11588
2015-03-12 21:48:29 -04:00
Juergen Hoeller 2b3409461f Polishing 2015-02-27 22:29:42 +01:00
Sebastien Deleuze 90e6304b49 Adjust log level for invalid SockJS or Websocket requests 2015-02-19 16:52:19 +01:00
Rossen Stoyanchev 917eb1de0b Ignore Pong messages in StompSubProtocolHandler
Issue: SPR-12728
2015-02-18 11:52:59 -05:00
Rossen Stoyanchev 1f990c3df6 Fix handling of empty payload Pong message on Jetty
Issue: SPR-12727
2015-02-18 11:36:22 -05:00
Sebastien Deleuze 6062e15572 Change SockJS and Websocket default allowedOrigins to same origin
This commit adds support for a same origin check that compares
Origin header to Host header. It also changes the default setting
from all origins allowed to only same origin allowed.

Issues: SPR-12697, SPR-12685
2015-02-18 09:30:15 +01:00
Rossen Stoyanchev b4fa1c24cc Pass SockJS session attributes to HandshakeHandler
Before this change the WebSocketTransportHandler passed
Collections.emptyMap as attributes to the HandshakeHandler because
it didn't matter what attributes the underlying WebSocketSession has
since it is wrapped by the SockJsSession and that's what exposed for
use everywhere.

This change has the WebSocketTransportHandler passing the attributes
from the SockJsSession instead since it's more accurate for the
underlying WebSocketSession to have access to the same map instance
and it allows the HandshakeHandler to change the attributes even if
it doesn't need to do that today.

Issue: SPR-12716
2015-02-16 14:12:12 -05:00
Stephane Nicoll f0fca890bb Annotation-based event listeners
Add support for annotation-based event listeners. Enabled automatically
when using Java configuration or can be enabled explicitly via the
regular <context:annotation-driven/> XML element. Detect methods of
managed beans annotated with @EventListener, either directly or through
a meta-annotation.

Annotated methods must define the event type they listen to as a single
parameter argument. Events are automatically filtered out according to
the method signature. When additional runtime filtering is required, one
can specify the `condition` attribute of the annotation that defines a
SpEL expression that should match to actually invoke the method for a
particular event. The root context exposes the actual `event`
(`#root.event`) and method arguments (`#root.args`). Individual method
arguments are also exposed via either the `a` or `p` alias (`#a0` refers
to the first method argument). Finally, methods arguments are exposed via
their names if that information can be discovered.

Events can be either an ApplicationEvent or any arbitrary payload. Such
payload is wrapped automatically in a PayloadApplicationEvent and managed
explicitly internally. As a result, users can now publish and listen
for arbitrary objects.

If an annotated method has a return value, an non null result is actually
published as a new event, something like:

@EventListener
public FooEvent handle(BarEvent event) { ... }

Events can be handled in an aynchronous manner by adding `@Async` to the
event method declaration and enabling such infrastructure. Events can
also be ordered by adding an `@Order` annotation to the event method.

Issue: SPR-11622
2015-02-10 09:13:02 +01:00
Sebastien Deleuze 9b3319b3b3 Fix SockJS origin check
This commit introduces the following changes:
 - Requests without Origin header are not rejected anymore
 - Disable Iframe when allowedOrigins is not empty and not equals to *
 - The Iframe is not cached anymore in order to have a reliable origin check
 - allowedOrigins must not be null or empty
 - allowedOrigins format is now validated (should be * or start by http(s)://)

Issue: SPR-12660
2015-02-09 11:56:51 +01:00
Ralph Schaer e0d407dad0 Fix javadoc 2015-02-03 10:41:56 -05:00
Rossen Stoyanchev 52b8f34468 Add JdkIdGenerator and use it in SockJS client
Issue: SPR-12658
2015-01-22 21:27:36 -05:00
Rossen Stoyanchev ab629a0e26 Deprecate writePrelude in AbstractHttpSockJsSession
A logical follow-up on commit 43d937, this change also removes (or
rather deprecates for now) writePrelude that is only of concern to
streaming SockJS session implementations.

Issue: SPR-12427
2015-01-13 10:26:59 -05:00
Rossen Stoyanchev 43d93712f1 Remove isStreaming flag from AbstractHttpSockJsSession
This change removes the need for the isStreaming field from the base
class AbstractHttpSockJsSession. This field was used to account for
differences between polling vs streaming SockJS sessions without having
to expose to sub-classes private fields that are otherwise protected
from concurrent access by the base class. The change manages to delegate
to sub-classes without providing direct access to protected fields.

Issue: SPR-12427
2015-01-12 14:48:09 -05:00
Rossen Stoyanchev 8a47c181f7 Assign Jetty SockJS tests to "performance" test group
This change designates Jetty SockJS integration tests to run as part of
the "performance", but not the main "publication", CI build due to
recurring low-level failures suspected to be Jetty issues, e.g.
"java.io.IOException: Cannot append to finished buffer" or
"java.io.IOException: Out of order Continuation frame encountered".

The tests will still run at once a day with the performance build but
should not fail the main build with false negatives. Also note that
an Undertow variant of the exact same tests, which hasn't been failing,
will continue to run as part of the main build.
2015-01-06 09:43:54 -05:00
Rossen Stoyanchev 51367dec05 Refine condition to send WebSocket binary messages
The following two refinements have been added:
1) SockJS doesn't support binary messages so don't even try
2) don't bother if payload.length == 0

Issue: SPR-12475
2014-12-29 15:13:09 -05:00
Rossen Stoyanchev 670974d76a Allow sending binary messages with STOMP
After this change the StompSubProtocolHandler sends STOMP frames
with content-type=octet-stream as a binary WebSocket message.

Issue: SPR-12475
2014-12-23 14:24:43 -05:00
Rossen Stoyanchev b796c1e87e Synchronize message sending
Issue: SPR-12516
2014-12-07 16:10:40 -05:00
Sebastien Deleuze 2fccf3ff44 Add support for autowiring Jackson handlers
This commit introduces the SpringHandlerInstantiator
class, a Jackson HandlerInstantiator that allows to autowire
Jackson handlers (JsonSerializer, JsonDeserializer, KeyDeserializer,
TypeResolverBuilder and TypeIdResolver) if needed.

SpringHandlerInstantiator is automatically used with
@EnableWebMvc and <mvc:annotation-driven />.

Issue: SPR-10768
2014-12-05 17:37:28 +01:00
Sebastien Deleuze fbd85925de Use Jackson improved default configuration everywhere
With this commit, Jackson builder is now used in spring-websocket
to create the ObjectMapper instance.

It is not possible to use the builder for spring-messaging
and spring-jms since these modules don't have a dependency on
spring-web, thus they now just customize the same features:
 - MapperFeature#DEFAULT_VIEW_INCLUSION is disabled
 - DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES is disabled

Issue: SPR-12293
2014-12-03 09:49:41 +01:00
Rossen Stoyanchev dc5b5ca8ee Check the user of a SockJS request
Issue: SPR-12497
2014-12-02 12:13:35 -05:00
Juergen Hoeller e6d7af4ea8 Polishing 2014-11-28 17:36:58 +01:00
Juergen Hoeller 0caeffcd54 Polishing
(cherry picked from commit 7e07f3d)
2014-11-27 18:57:57 +01:00
Brian Clozel bb150c47cf Add undertow 1.1.0.Final support
Upgrade undertow dependency to 1.1.0.Final.
Add support for undertow 1.1.0.Final in the
UndertowRequestUpgradeStrategy, after a breaking change in the
`io.undertow.websockets.jsr.ConfiguredServerEndpoint` constructor.

Issue: SPR-12302
2014-11-24 14:22:10 +01:00
Juergen Hoeller 05bdc2cf77 Consistent declaration and use of UTF-8 Charset constants, plus related polishing 2014-11-11 02:38:30 +01:00
Juergen Hoeller 9ff8a01f29 Polishing 2014-11-07 17:14:50 +01:00
Brian Clozel 1fff631daa Fix SubProtocolHandler duplicate registration
Prior to this change, duplicate SubProtocolHandlers could be registered
when configuring STOMP with several registrations:

    public void registerStompEndpoints
          (final StompEndpointRegistry registry) {
      this.endpointRegistry.addEndpoint("/stompOverWebSocket");
      this.endpointRegistry.addEndpoint("/stompOverSockJS").withSockJS();
    }

This commit registers sub-protocols in a Set instead of a list (see
SubProtocolWebSocketHandler), thus fixing the issue.

Issue: SPR-12403
2014-11-03 14:25:27 +01:00
Sam Brannen 14f4d34fdb Clean up warnings in spring-websocket 2014-11-01 16:11:57 +01:00
Juergen Hoeller 1146d5ba1d Polishing 2014-10-29 22:44:59 +01:00
Rossen Stoyanchev 38ef6dec50 Fix test issue with Set iteration order 2014-10-29 17:23:04 -04:00
Rossen Stoyanchev 8f21c85511 Explicitly close Spring context in WS integration test 2014-10-28 22:10:49 -04:00
Rossen Stoyanchev 8c727be4e1 Close Spring context in SockJS integration test setup 2014-10-28 17:51:15 -04:00
Rossen Stoyanchev 70e6e3bb39 Fix condition check in SockJsClient lifecycle method 2014-10-28 17:51:15 -04:00
Rossen Stoyanchev da612d079f Replace "if(" with "if (" 2014-10-27 09:04:23 -04:00
Sebastien Deleuze 6592784ef4 Fix a package tangle between SockJS support and transport packages
Issue: SPR-12379
2014-10-27 13:28:01 +01:00
Sebastien Deleuze 58f4014b17 Add an option to disable automatic addition of CORS header
Issues: SPR-12283
2014-10-26 21:20:53 +01:00
Sebastien Deleuze 743356fa21 Add an option to set an Origin whitelist for Websocket and SockJS
This commit introduces a new OriginHandshakeInterceptor. It filters
Origin header value against a list of allowed origins.

AbstractSockJsService as been modified to:
 - Reject CORS requests with forbidden origins
 - Disable transport types that does not support CORS when an origin
   check is required
 - Use the Origin request header value instead of "*" for
   Access-Control-Allow-Origin response header value
   (mandatory when  Access-Control-Allow-Credentials=true)
 - Return CORS header only if the request contains an Origin header

It is possible to configure easily this behavior thanks to JavaConfig API
WebSocketHandlerRegistration#addAllowedOrigins(String...) and
StompWebSocketEndpointRegistration#addAllowedOrigins(String...).
It is also possible to configure it using the websocket XML namespace.

Please notice that this commit does not change the default behavior:
cross origin requests are still enabled by default.

Issues: SPR-12226
2014-10-26 21:18:04 +01:00
Rossen Stoyanchev 01aa64c534 Simple broker sends notice after disconnect
Before this change the simple broker simply removed subscriptions
upon receiving a DISCONNECT message assuming it was a result of
a client STOMP WebSocket session ending.

However, if the server-side application sends a DISCONNECT to
the broker in order to terminate a session, the STOMP WebSocket
session could remain unware without any further action. This
change ensures the simple broker sends a DISCONNECT_ACK message
downstream whenever it receives a DISCONNECT.

Issue: SPR-12288
2014-10-24 09:48:18 -04:00
Rossen Stoyanchev 687955a704 Add ImmutableMessageChannelInterceptor
This change adds a ChannelInterceptor that flips the immutable flag on
messages being sent. This allows components sending messages to leave
the message mutable for interceptors to further apply modifications
before the message is sent (and exposed to concurrency).

The interceptor is automatically added with the STOMP/WebSocket Java
and XML config and the StompSubProtocolHandler leaves parsed incoming
messages mutable so they can be further modified before being sent.

Issue: SPR-12321
2014-10-23 15:25:51 -04:00
Juergen Hoeller 3106905877 Polishing 2014-10-22 01:19:14 +02:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller b6fdcffc94 HttpSessionHandshakeInterceptor and related web.socket.server polishing
Issue: SPR-12352
2014-10-20 23:32:46 +02:00
Juergen Hoeller 77a62ec8b8 Polishing 2014-10-20 17:42:18 +02:00
Juergen Hoeller 10328f1c22 Reimplemented ServerEndpointExporter to avoid BeanPostProcessor role
Issue: SPR-12340
2014-10-20 17:41:14 +02:00
Rossen Stoyanchev 3056301015 Improve HttpSessionHandshakeInterceptor
Use explicit flag whether to copy all attributes.
2014-10-14 09:29:06 -04:00
Sam Brannen 2f54b273a5 Delete unused imports in spring-websocket module 2014-10-13 20:37:08 +02:00
Rossen Stoyanchev 97596fb9f6 Allow plugging in a WebSocketHandlerDecorator
The WebSocketMessageBroker config now allows wrapping the
SubProtocolWebSocketHandler to enable advanced use cases that may
require access to the underlying WebSocketSession.

Issue: SPR-12314
2014-10-13 09:35:51 -04:00
Rossen Stoyanchev f0323be786 Add option to copy HTTP session id to handshake attrs
Issue: SPR-12314
2014-10-10 15:21:04 -04:00
Rossen Stoyanchev 4a29e164a8 Allow binary messages in StompSubProtocolHandler
Issue: SPR-12301
2014-10-10 14:31:39 -04:00
Brian Clozel 4cf19df462 SockJs client: add an XhrTransport for Undertow
This change adds a new XhrTransport for the SockJs client
implementation. This transport is based on `UndertowClient`,
Undertow's HTTP client.

Note that this transport can be customized with an OptionMap that is
used by the Xnio worker backing the I/O communications (see
http://xnio.jboss.org).

Implementation tested with undertow 1.0.36, 1.1.0.RC3, 1.2.0.Beta1.

Issue: SPR-12008
2014-10-08 16:52:40 +02:00
Brian Clozel 2a39081819 Add Vary:Origin HTTP header in SockJS responses
This change adds a "Vary: Origin" HTTP response header for /info and
/iframe SockJS endpoints.
This is preventing proxies and browsers from caching a response and
reusing it for an invalid Origin.

Reference: https://groups.google.com/forum/#!topic/sockjs/svsLWRorSis

Issue: SPR-12310
2014-10-08 16:37:50 +02:00
Juergen Hoeller e56559fd4d WebSocketSession extends java.io.Closeable, plus reorganization of AbstractSockJsSession's code
Issue: SPR-12311
2014-10-07 13:45:07 +02:00
Juergen Hoeller da14aeea7a TextMessage.toString() does not throw StringIndexOutOfBoundsException for payload with multibyte characters
Issue: SPR-12307
2014-10-07 13:35:38 +02:00
Juergen Hoeller 3a3c52dbdd Polishing 2014-10-01 01:10:25 +02:00
Juergen Hoeller 7f9baa3a09 Polishing 2014-09-26 22:38:41 +02:00
Brian Clozel a6e1c53f23 Update default SockJS CDN location
This commit updates the default location of the SockJS' client library.
The previous location is being retired by the project maintainers.

The new default location is backed by several CDN providers:
* https://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js

See sockjs/sockjs-client#198

Issue: SPR-12254
2014-09-26 21:42:08 +02:00
Rossen Stoyanchev 371d93b346 Detect unsent DISCONNECT messages
This change uses a ChannelInterceptor (inserted at index 0) to detect
when a DISCONNECT message is precluded from being sent on the
clientInboundChannel. This can happen if another interceptor allows
a runtime exception out from preSend or returns false.

It is crucial for such messages to be processed, so when detected
they're processed still.

Issue: SPR-12218
2014-09-25 23:22:12 -04:00
Juergen Hoeller 070642c148 Introduced addScope convenience method on CustomScopeConfigurer (for use in WebSocket configuration) 2014-09-25 01:31:33 +02:00
Juergen Hoeller 3836aa051f Message broker thread pools should be set up in allowCoreThreadTimeOut mode
Issue: SPR-12249
2014-09-25 01:29:00 +02:00
Rossen Stoyanchev b0e6091cad Lower "no session" message log level in SubProtocolWSH
Issue: SPR-12247
2014-09-24 15:04:57 -04:00
Rossen Stoyanchev 5b1cbf0306 Log WebSocket connection issues at DEBUG level
WebSocket clients going away is an expected and common occurance.
Logging at ERROR level on failure to close a connection or on failures
to write data to a WebSocket sessions has a high potential for false
positives with very little to do. This change lowers the log level for
a number of log messages that fit this category.

This should be helped by the effort already spent for 4.1 to ensure
logging at DEBUG level doesn't produce excessive amounts of logging.

Issue: SPR-12155
2014-09-24 10:07:15 -04:00
Rossen Stoyanchev 237b50a9c8 Allow configuring custom argument types
The WebSocket messaging namespace now exposes configuration options for
custom argument resolvers and return value handlers.

Issue: SPR-12217
2014-09-19 16:47:39 -04:00
Rossen Stoyanchev a99ef6d9b2 Extend websocket scope to event publication
This change extends the "websocket" scope to ApplicationContext events
published from StompSubProtocolHandler. This however will only work
with ApplicationEventMulticaster that multicasts events in the same
thread.

Issue: SPR-12172
2014-09-19 13:46:40 -04:00
Rossen Stoyanchev dc57cb2c9f Update SessionDisconnectEvent
SessionDisconnectEvent now extends AbstractSubProtocolEvent.

Issue: SPR-12156
2014-09-18 15:21:11 -04:00
Rossen Stoyanchev 4af9851585 Add user to DISCONNECT in StompSubProtocolHandler
Issue: SPR-12215
2014-09-18 15:06:08 -04:00
Rossen Stoyanchev 49b872e387 Adjust logging following SockJS client disconnect
Issue: SPR-11870
2014-09-04 00:23:10 -04:00
Juergen Hoeller 86b7118da8 Polishing 2014-09-04 02:30:25 +02:00
Juergen Hoeller 20c2ba35dc Polishing 2014-09-04 00:55:38 +02:00
Rossen Stoyanchev 2a0765e76d Allow setting SockJsMessageCodec in WebSocket config
Issue: SPR-12091
2014-08-25 15:19:50 -04:00
Juergen Hoeller b93dd95475 Polishing 2014-08-22 22:55:57 +02:00
Juergen Hoeller 86c5880888 Polishing 2014-08-21 18:41:23 +02:00
Juergen Hoeller 11805b6a5d ServerEndpointExporter can initialize itself based on a late-provided ServletContext as well (for Boot)
Also allows for direct setting of a ServerContainer and for custom triggering of endpoint registration.

Issue: SPR-12109
2014-08-21 18:40:35 +02:00
Juergen Hoeller 2ef3d66c89 Polishing 2014-08-18 19:27:08 +02:00
Phillip Webb ac8326d2df Polish mockito usage
Consistent use of BDDMockito rather than standard Mockito.
2014-08-11 16:23:11 -07:00
Sebastien Deleuze 3922f6fc53 Update references to RFC 2616
Replace references to the old RFC 2616 (HTTP 1.1) with references
to the new RFCs 7230 to 7235.

This commit also deprecates:
 - HttpStatus.USE_PROXY
 - HttpStatus.REQUEST_ENTITY_TOO_LARGE in favor of HttpStatus.PAYLOAD_TOO_LARGE
 - HttpStatus.REQUEST_URI_TOO_LONG in favor of HttpStatus.URI_TOO_LONG

Issue: SPR-12067
2014-08-07 14:50:45 +02:00
Stephane Nicoll 3da68cfe21 Remove unused imports 2014-08-04 14:13:40 +02:00
Rossen Stoyanchev 8751936b12 Fix issue with sub-protocol negotiation and SockJS
Before this change the SockJsWebSocketHandler precluded determination
of the sub-protocols by wrapping the actual target handler.

After this change SockJsWebSocketHandler implements SubProtocolCapable
and returns the list of sub-protocols from the wrapped handler.
2014-07-31 10:33:11 -04:00
Rossen Stoyanchev 41cdc92fc3 Remove AbstractWebSocketClient from SockJsClient
SockJsClient now implements WebSocketClient directly without extending
AbstractWebSocketClient.

Issue: SPR-12030
2014-07-30 15:39:01 -04:00
Rossen Stoyanchev c68b4c01e1 Polish SockJsClient 2014-07-30 15:29:46 -04:00
Rossen Stoyanchev ba952ca331 Fix test condition 2014-07-30 09:02:23 -04:00
Rossen Stoyanchev c89325b9ca Add WebLogicRequestUpgradeStrategy
This change creates an AbstractTyrusRequestUpgradeStrategy shared
between the WebLogic and GlassFish sub-classes.

The version of Tyrus is lowered to 1.3.5 to match the version used
in WebLogic (12.1.3) and that in turn requires a little extra effort
in the base AbstractTyrusRequestUpgradeStrategy to make up for
changes that have taken place from Tyrus 1.3.5 to 1.7.

Issue: SPR-11293
2014-07-25 17:16:00 -04:00
Rossen Stoyanchev 88d8dff3ac Upgrade to Tyrus 1.7
This change provides WebSocket support for the upcoming Glassfish 4.0.1
release while at the same dropping support for Glassfish 4.0 due to
incompatible changes.

Issue: SPR-11094
2014-07-24 09:58:22 -04:00
Rossen Stoyanchev afb56681ac Fix minor issue in StandardToWebSocketExtensionAdapter
This change ensures proper initialization of a WebSocketExtension
from a JSR-356 Extension.

This is in preparation for SPR-11094
2014-07-24 09:58:22 -04:00
Rossen Stoyanchev e74ac06733 Filter WebSocket extensions
Before this change the DefaultHandshakeHandler by default passed the
list of requested WebSocket extensions as-is relying on the WebSocket
engine to remove those not supported.

This change ensures that WebSocket extensions not supported by the
runtime are proactively removed instead.

This change is preparation for SPR-11094.
2014-07-24 09:58:22 -04:00
Rossen Stoyanchev 73267d7523 Ensure Undertow 1.1 compatibility
Issue: SPR-11914
2014-07-22 15:28:40 -04:00
Rossen Stoyanchev 988499f7dc Remove awaitCloseStatus in SockJS integration tests
A CloseStatus may not be received if the connection is closed while
the client is between XHR polling requests.
2014-07-22 13:40:02 -04:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Rossen Stoyanchev 90f8e4b71f Add @Ignored temporarily to Jetty SockJS tests 2014-07-18 00:45:14 -04:00
Rossen Stoyanchev b18ed6b724 Remove erroneously commited code 2014-07-16 20:49:12 -04:00
Rossen Stoyanchev 89b202029a Fix failing test 2014-07-15 22:59:25 -04:00
Rossen Stoyanchev d86e4cf203 Re-obtain port on every WebSocket integration test
This change adds a WebSocketTestServer setup method that initializes
the server and obtains a new port.

In turn AbstractWebSocketIntegrationTests invokes the new method from
its setup method thus ensuring a new port is used on every test.
2014-07-15 16:53:38 -04:00
Rossen Stoyanchev ea7ae8949e Use regex comparison in WebSocket stats test
The output includes thread pool information which appears to not vary
enough to cause failures locally but does so on the build server.
2014-07-15 16:53:38 -04:00
Rossen Stoyanchev 4dd5c274a0 Add missing HandshakeInterceptor for STOMP endpoints
Issue: SPR-11845
2014-07-15 13:31:30 -04:00
Rossen Stoyanchev 6d6cc0ecec Polish WebSocket Java config 2014-07-15 13:31:30 -04:00
Rossen Stoyanchev 85c175059a Add missing handshake-interceptor namespace support
Issue: SPR-11845
2014-07-15 13:31:29 -04:00
Rossen Stoyanchev 61e77eeb61 Fix white spaces 2014-07-15 13:31:29 -04:00
Rossen Stoyanchev 6557800f97 Polish WebSocket namespace 2014-07-15 13:31:29 -04:00
Rossen Stoyanchev ab2526a586 Update support for using "." as path separator
Issue: SPR-11660
2014-07-14 18:49:25 -04:00
Sebastien Deleuze 928a466b5d Allow to customize separator for messaging destinations
In order to be able to use separators like "." (used by default
by most broker relays) instead of "/" for destination patterns
handling, the PathMatcher used in spring-messaging can now
be customized easily thanks to XML websocket namespace
or JavaConfig.

AntPathMatcher has been updated in order to use the configured path
separator instead of an hardcoded "/" for path concatenation.
Extension handling is now disabled when the "." separator is configured.

Issue: SPR-11660
2014-07-14 18:49:24 -04:00
Rossen Stoyanchev 670c216d38 Change converter ordering in message broker config
Issue: SPR-11961
2014-07-10 12:57:00 -04:00
Rossen Stoyanchev 2ebc921545 Add Lifecycle to SockJsClient and Transport types
Issue: SPR-10797
2014-07-10 12:56:59 -04:00
Rossen Stoyanchev d73c1d5693 Update WebSocket client SmartLifecycle support
Before this change WebSocketConnectionManager delegated SmartLifecycle
methods to the client instance it contained. After this change
WebSocketClient implementations are expected to implement Lifecycle
(rather than SmartLifecycle).

The need for this is even more evident with SockJsClient, which is a
WebSocketClient implementation and contains a WebSocketTransport that
in turn contains the actual WebSocketClient. In this case
WebSocketConnectionManager as the top level container is the obvious
place to configure autostartup while Lifecycle events can be
propagated all the way down to the root WebSocketClient.
2014-07-10 12:56:59 -04:00
Juergen Hoeller 3c726aa6c1 Polishing 2014-07-09 21:24:59 +02:00
Rossen Stoyanchev bc62d63fdd Fix left-over merge issue from previous commit 2014-07-09 00:46:06 -04:00
Rossen Stoyanchev 48236be4a2 STOMP and WebSocket messaging related logging updates
This change removes most logging at INFO level and also ensures the
amount of information logged at DEBUG level is useful, brief, and
not duplicated.

Also added is custom logging for STOMP frames to ensure very readable
and consise output.

Issue: SPR-11934
2014-07-09 00:39:59 -04:00
Rossen Stoyanchev ab4864da2a Add STOMP/WebSocket stats collection
This change adds collection of stats in key infrastructure components
of the WebSocket message broker config setup and exposes the gathered
information for logging and viewing (e.g. via JMX).

WebSocketMessageBrokerStats is a single class that assembles all
gathered information and by default logs it once every 15 minutes.
Application can also easily expose to JMX through an MBeanExporter.

A new section in the reference documentation provides a summary of
the available information.

Issue: SPR-11739
2014-07-09 00:39:47 -04:00
Juergen Hoeller b559f15a00 Polishing 2014-07-07 21:45:40 +02:00
Juergen Hoeller 387da221c3 Polishing
Issue: SPR-11963
2014-07-07 19:41:39 +02:00
Brian Clozel 6bcb48f95d Polish SPR-11963 2014-07-07 17:34:08 +02:00
Brian Clozel e549103ca0 Remove Jackson dependency from TransportHandler hierarchy
Prior to this change, AbstractHttpReceivingTransportHandler had a direct
dependency on a Jacckson Exception (checking that exception in a catch
clause). This can cause issues for applications that don't have that
dependency.

This commit removes that direct dependency, still logging the
appropriate log messages using a parent exception (IOException) and
reflection.

Issue: SPR-11963
2014-07-07 17:29:32 +02:00
Rossen Stoyanchev 6d15fcc4a6 Log name of test for WebSocket integration tests
This makes it easier to trace log output on the CI server where the
output is per class.
2014-07-02 14:26:51 -04:00
Rossen Stoyanchev 59e02e63c4 Synchronize request init in AbstractHttpSockJsSession
Although unlikely in practice (but not impossible), the SockJS
integration tests write a message while the request is initializing.
This change adds synchronization around request intiailization
for the SockJS HTTP sesion.

Issue: SPR-11916
2014-07-02 13:53:23 -04:00
Juergen Hoeller e90143e03b Polishing 2014-07-01 12:52:09 +02:00
Rossen Stoyanchev 06d3e1b94e Fix Javadoc typo 2014-06-30 13:27:54 -04:00
Rossen Stoyanchev 71b942698d Fix sniff task warnings 2014-06-29 22:56:53 -04:00
Rossen Stoyanchev b1aebb2c0c Fix failing test 2014-06-29 22:09:54 -04:00
Rossen Stoyanchev cb40908a7d Fix warnings from the sniff task 2014-06-29 17:35:00 -04:00
Rossen Stoyanchev 2b1ff4c5db Fix condition in SubProtocolWebSocketHandler
Issue: SPR-11884
2014-06-29 17:00:24 -04:00
Rossen Stoyanchev 7441f23012 Add support for removeOnCancelPolicy
This change removes the recently added SockJsThreadPoolTaskScheduler
and instead builds support for the removeOnCancelPolicy property in
ThreadPoolTaskScheduler and ScheduledExecutorFactoryBean.

Issue: SPR-11918
2014-06-29 14:28:52 -04:00
Rossen Stoyanchev 7dc2b2927e Use SESSION_NOT_RELIABLE when no messages received
When a WebSocket session is closed after not having received any
messages, we'll use SESSION_NOT_RELIABLE to indicate to other parts
of the session closing code not to send anything further (e.g.
SockJS "Go Away!" frame).

Issue: SPR-11884
2014-06-29 13:15:21 -04:00