dropwizard-websocket-jee7-bundle

Dropwizard bundle to enable the use of Java Websockets.

License

License

Categories

Categories

DropWizard Container Microservices
GroupId

GroupId

be.tomcools
ArtifactId

ArtifactId

dropwizard-websocket-jee7-bundle
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

dropwizard-websocket-jee7-bundle
Dropwizard bundle to enable the use of Java Websockets.
Project URL

Project URL

https://github.com/TomCools/dropwizard-websocket-jee7-bundle
Source Code Management

Source Code Management

https://github.com/TomCools/dropwizard-websocket-jee7-bundle

Download dropwizard-websocket-jee7-bundle

How to add to project

<!-- https://jarcasting.com/artifacts/be.tomcools/dropwizard-websocket-jee7-bundle/ -->
<dependency>
    <groupId>be.tomcools</groupId>
    <artifactId>dropwizard-websocket-jee7-bundle</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/be.tomcools/dropwizard-websocket-jee7-bundle/
implementation 'be.tomcools:dropwizard-websocket-jee7-bundle:2.0.0'
// https://jarcasting.com/artifacts/be.tomcools/dropwizard-websocket-jee7-bundle/
implementation ("be.tomcools:dropwizard-websocket-jee7-bundle:2.0.0")
'be.tomcools:dropwizard-websocket-jee7-bundle:jar:2.0.0'
<dependency org="be.tomcools" name="dropwizard-websocket-jee7-bundle" rev="2.0.0">
  <artifact name="dropwizard-websocket-jee7-bundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='be.tomcools', module='dropwizard-websocket-jee7-bundle', version='2.0.0')
)
libraryDependencies += "be.tomcools" % "dropwizard-websocket-jee7-bundle" % "2.0.0"
[be.tomcools/dropwizard-websocket-jee7-bundle "2.0.0"]

Dependencies

compile (4)

Group / Artifact Type Version
javax.websocket : javax.websocket-api jar 1.1
io.dropwizard : dropwizard-core jar 1.0.0
org.eclipse.jetty.websocket : javax-websocket-server-impl jar 9.3.9.v20160517
org.eclipse.jetty.websocket : javax-websocket-client-impl jar 9.3.9.v20160517

provided (1)

Group / Artifact Type Version
org.projectlombok : lombok jar 1.16.4

test (3)

Group / Artifact Type Version
io.dropwizard : dropwizard-testing jar 1.0.0
junit : junit jar 4.11
nl.jqno.equalsverifier : equalsverifier jar 1.7.3

Project Modules

There are no modules declared in this project.

Websocket (JSR 356) bundle for Dropwizard

Build Status Latest Release License

Adding some Websocket-magic to Dropwizard.

This repository contains a Bundle to be used with Dropwizard. For more information about Dropwizard, please visit: dropwizard.io.

The goal of the bundle was to add support for the JSR 356 Websocket specification. (Lookup since when Jetty supports this functionality).

How does the bundle work?

Add the maven dependency:

<dependency>
  <groupId>be.tomcools</groupId>
  <artifactId>dropwizard-websocket-jee7-bundle</artifactId>
  <version>2.0.0</version>
</dependency>

The version 2.0.0 does no longer support Java 7. Please use the older dependency or upgrade to Java 8 be.tomcools dropwizard-websocket-jee7-bundle 1.1.0

Add the WebsocketBundle object to the Application.class and add the Endpoint classes you want to load:

public class IntegrationTestApplication extends Application<IntegrationTestConfiguration> {
    private WebsocketBundle websocket = new WebsocketBundle();

    @Override
    public void initialize(Bootstrap<IntegrationTestConfiguration> bootstrap) {
        super.initialize(bootstrap);
        bootstrap.addBundle(websocket);
    }

    @Override
    public void run(IntegrationTestConfiguration configuration, Environment environment) throws Exception {
        //Annotated endpoint
        websocket.addEndpoint(PingPongServerEndpoint.class);

        //programmatic endpoint
        ServerEndpointConfig serverEndpointConfig = ServerEndpointConfig.Builder.create(ProgrammaticServerEndpoint.class, "/programmatic").build();
        websocket.addEndpoint(serverEndpointConfig);
    }
}

Start your server. During startup, all registered Websocket-endpoints will be logged in the same way other resources are logged.

INFO  [2017-05-16 18:18:04,230] be.tomcools.dropwizard.websocket.handling.WebsocketContainer: Registered websocket endpoints: 

	GET		/programmatic (be.tomcools.dropwizard.websocket.integrationtest.programmaticjavaee.ProgrammaticServerEndpoint)
	GET		/pingpong (be.tomcools.dropwizard.websocket.integrationtest.annotatedjavaee.PingPongServerEndpoint)

Configuration

Websocket default configuration can be overriden using the WebsocketBundleConfiguration Interface on the Configuration class. When the interface is not used, the configuration will not be overridden.

public class IntegrationConfiguration extends Configuration implements WebsocketBundleConfiguration {

@Valid
@NotNull
@JsonProperty
private final WebsocketConfiguration websocketConfiguration = new WebsocketConfiguration();

@Override
public WebsocketConfiguration getWebsocketConfiguration() {
    return websocketConfiguration;
}

}

WebsocketConfiguration: public class WebsocketConfiguration {

@JsonProperty
private Integer maxTextMessageBufferSize;
@JsonProperty
private Long asyncSendTimeout;
@JsonProperty
private Long maxSessionIdleTimeout;
@JsonProperty
private Integer maxBinaryMessageBufferSize;

}

Need help? Found an issue? Want extra functionality?

Please report any issues you find. I will frequently check and update if required. Please use following guidelines when posting:

  • Check existing issues to see if it has been addressed already;
  • In issues include the Bundle-version as well as the version of Dropwizard you are using;
  • Add a description of how someone else can reproduce the problem and add the stacktrace if possible.

Versions

Version
2.0.0
2.0.0-snapshot
1.1.0
1.0.1
1.0.0
0.0.105