{#========================================== Spincast Undertow plugin ==========================================#} {% extends "../../layout.html" %} {% block sectionClasses %}plugins plugins-spincast-undertow{% endblock %} {% block meta_title %}Plugins - Spincast Undertow{% endblock %} {% block meta_description %}Spincast Undertow plugin provides the default HTTP server for a Spincast application.{% endblock %} {% block scripts %} {% endblock %} {% block body %}
The Spincast Undertow plugin provides an implementation
of the IServer interface using the Undertow server.
If you use the spincast-default artifact, this plugin is already installed so
you have nothing more to do!
If you start from scratch using the spincast-core artifact, you can use the
plugin by adding this artifact to your project:
<dependency>
<groupId>org.spincast</groupId>
<artifactId>spincast-plugins-undertow</artifactId>
<version>{{spincastCurrrentVersion}}</version>
</dependency>
You then install the plugin's Guice module, by passing it to the Guice.createInjector(...) method:
Injector guice = Guice.createInjector(
new SpincastCoreGuiceModule(args),
new SpincastUndertowPluginGuiceModule(IAppRequestContext.class, IAppWebsocketContext.class)
// other modules...
);
... or by using the install(...) method from your custom Guice module:
public class AppModule extends SpincastCoreGuiceModule {
@Override
protected void configure() {
super.configure();
install(new SpincastUndertowPluginGuiceModule(getRequestContextType(),
getWebsocketContextType()));
// other modules...
}
// ...
}
Few of the IServer's methods are made to be used directly.
We are only going to list those here, so have a look at the IServer's
Javadoc
for a listing of all the available methods.
void start()
void stop()
void createHttpAuthenticationRealm(String pathPrefix, String realmName)
Map<String, String> getHttpAuthenticationRealms()
The map is immutable.
void addHttpAuthentication(String realmName, String username, String password)
void removeHttpAuthentication(String username, String realmName)
void removeHttpAuthentication(String username)
IWebsocketEndpointManager websocketCreateEndpoint(String endpointId, IWebsocketEndpointHandler endpointHandler)
void websocketCloseEndpoint(String endpointId)
void websocketCloseEndpoint(String endpointId, int closingCode, String closingReason)
void websocketConnection(Object exchange, String endpointId, String peerId)
List<IWebsocketEndpointManager> getWebsocketEndpointManagers()
IWebsocketEndpointManager getWebsocketEndpointManager(String endpointId)
You can bind the ISpincastUndertowConfig interface
if you want to change some default configurations.
The default implementation class for those configurations
is SpincastUndertowConfigDefault.
Here are the available configurations:
boolean isWebsocketAutomaticPing()
true, pings will automatically
be sent to peers of a WebSocket endpoint as an
heartbeat.
int getWebsocketAutomaticPingIntervalSeconds()
20 seconds.
String getWebsocketPingMessageString()
< 125 characters.
"__ping"
int getWebsocketDefaultClosingCode()
1000, a normal closure.
String getWebsocketDefaultClosingReason()
int getWebsocketThreadExecutorForAppEventsThreadNumber()
100.
int getWebsocketThreadExecutorForAppEventsTimeoutAmount()
amount before cancelling a task when
sending WebSocket events to the application.
60.
TimeUnit getWebsocketThreadExecutorForAppEventsTimeoutTimeUnit()
TimeUnit before cancelling a task when
sending WebSocket events to the application.
SECONDS.
ThreadFactory getWebsocketThreadExecutorForAppEventsThreadFactory()
ThreadFactory to use to create threads when
sending WebSocket events to the application.
null.