jWebSocket Class Loader

This section describes how the engines, servers, plug-in and filters are loaded at run-time, controlled by the jWebSocket.xml configuration file.

The Class Loader works in two modes:

a) Development Mode (dev)
b) Production Mode (prod)

specified by the <installation> tag in the configuration file.


Specifying jWebSocket development or production mode

* only dev or prod, don't specify both here. Both modes are described below.

Development Mode

The development mode is useful when you compile jWebSocket from the source allowing you to instantiate engines, servers, plug-ins and filters programmatically at run-time. It relieves you from the pain of generating jars to the libs folder etc. It also makes things easier for debugging your new plug-ins and filters. By default it uses the JWebSocketInitializer class which instantiates the jWebSocket default set of engines (TCPEngine, NettyEngine), servers (CustomServer, TokenServer), plug-ins (SystemPlugIn, RPC, FlashBridge...) and filters (SystemFilter).

If you want to add your own plug-in, filters or even your own custom-specific server you can simply extend the JWebSocketInitializer class by instantiating your classes in this existing one and run, test and debug it. In development mode the <initializerClass> element in jWebSocket.xml file specifies which class is used to programmatically initialize the jWebSocket Server.

org.jwebsocket.server .loader.JWebSocketInitializer

Specifying the default jWebSocket initializer class

Hence, if you want to create your initializer class based on JWebSocketInitializer as example you can specify it as follows.


Specifying your own jWebSocket initializer class

All the custom initializer has to implement WebSocketInitializer interface and register via xml configuration <initializerClass> property.

Production Mode

If the installation value is prod then that means the jWebSocket Server will run on folder structure described here. It will use the JWebSocketXmlConfigInitializer class which the client code cannot override so the engine, server, plug-in and filter jars are loaded based on the properties specified in the jWebSocket.xml configuration file.

All the jars are expected to be located in the %JWEBSOCKET_HOME%/libs folder.


If the <installation> tag is not defined, by default it is assumed to be dev. If the <initializerClass> is not defined, by default it is assumed to be org.jwebsocket.server.loader.JWebSocketInitializer.


Learn more about WebSockets in general, get background information and gain deeper insight!

Join jWebSocket

Wether developer, designer or translator – join the jWebSocket team and grow together with our success!

Copyright © 2013 Innotrade GmbH. All rights reserved.