pl.bristleback.server.bristle
Class BristlebackServerPlugin

java.lang.Object
  extended by org.jwebsocket.plugins.BasePlugIn
      extended by org.jwebsocket.plugins.TokenPlugIn
          extended by pl.bristleback.server.bristle.BristlebackServerPlugin
All Implemented Interfaces:
org.jwebsocket.api.WebSocketPlugIn

public class BristlebackServerPlugin
extends org.jwebsocket.plugins.TokenPlugIn

Bristleback Server plugin (also called Bristle plugin) is a helpful framework overlay, which simplifies process of creating applications using jWebsocket library. Bristleback plugin consists of five main elements:

If you need to perform some operations before server is up or after server is down, you might be interested in using server state listeners chain. The only thing to do is to add your own ServerStateListener implementation. You can add as many ServerStateListener as you want.

Almost every element of plugin is configurable, user can specify how actions or message will be looked. Yet, default implementation of those elements allow user to create "Hello world" application in just five minutes. Plugin settings in jwebsocket.xml file are used to configure Bristle plugin. Please note that this is early version of plugin, so nothing is tested as good as we would like it to be.

BristleConstants class and BristleConfiguration have fields which can be helpful in creating your first application.

Current version of Bristle plugin contains two default message senders and one message dispatcher. To make use of message senders, users must add them into their jwebsocket configuration file. Example configuration is shown in this project, in "xml/jwebsocket.xml" file.

Created on: 2010-09-03 16:01:30

Version:
0.1.0
Author:
Wojciech Niemiec
See Also:
Bristleback plugin website, Bristleback configuration, Bristleback configuration elements

Constructor Summary
BristlebackServerPlugin()
          Creates a new Bristleback plugin instance and instantiating core elements of plugin.
BristlebackServerPlugin(org.jwebsocket.api.PluginConfiguration configuration)
          Constructor required by TokenPlugIn class.
 
Method Summary
 void connectorStarted(org.jwebsocket.api.WebSocketConnector connector)
          When connector is started, new empty rights set is created and assigned to that connector.
 void connectorStopped(org.jwebsocket.api.WebSocketConnector connector, org.jwebsocket.kit.CloseReason closeReason)
          Additional operations performed when connector is stopped.
 void engineStarted(org.jwebsocket.api.WebSocketEngine engine)
          Loading of all core elements from configuration and annotations.
 void engineStopped(org.jwebsocket.api.WebSocketEngine engine)
          In this method closing operations are performed.
 ActionsDispatcher getActionsDispatcher()
          Gets action dispatcher with actions and handlers inside.
 void processToken(org.jwebsocket.kit.PlugInResponse response, org.jwebsocket.api.WebSocketConnector connector, org.jwebsocket.token.Token token)
          Process token sent by user.
 
Methods inherited from class org.jwebsocket.plugins.TokenPlugIn
broadcastToken, broadcastToken, createAccessDenied, createResponse, getNamespace, getServer, processPacket, sendToken, setNamespace
 
Methods inherited from class org.jwebsocket.plugins.BasePlugIn
addAllSettings, addSetting, clearSettings, getConnector, getConnectorCount, getNode, getNodeId, getPlugInChain, getPluginConfiguration, getSetting, getSetting, getSettings, getUsername, removeNodeId, removeSetting, removeUsername, setNodeId, setPlugInChain, setPluginConfiguration, setUsername
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BristlebackServerPlugin

public BristlebackServerPlugin()
Creates a new Bristleback plugin instance and instantiating core elements of plugin.


BristlebackServerPlugin

public BristlebackServerPlugin(org.jwebsocket.api.PluginConfiguration configuration)
Constructor required by TokenPlugIn class.

Parameters:
configuration - plugin configuration.
Method Detail

engineStarted

public void engineStarted(org.jwebsocket.api.WebSocketEngine engine)
Loading of all core elements from configuration and annotations. Firstly, plugin loads actions and exception handlers. Next step is to load message controller (dispatcher and senders) and to export senders. After that, server state inspector is loaded and invokes server state listeners chain. As soon as every element is ready, message controller starts dispatching messages to connectors.

Specified by:
engineStarted in interface org.jwebsocket.api.WebSocketPlugIn
Overrides:
engineStarted in class org.jwebsocket.plugins.TokenPlugIn
Parameters:
engine - websocket engine.

engineStopped

public void engineStopped(org.jwebsocket.api.WebSocketEngine engine)
In this method closing operations are performed. Dispatcher is stopped, server state inspector is notified about server shutdown.

Specified by:
engineStopped in interface org.jwebsocket.api.WebSocketPlugIn
Overrides:
engineStopped in class org.jwebsocket.plugins.TokenPlugIn
Parameters:
engine - websocket engine.

connectorStarted

public void connectorStarted(org.jwebsocket.api.WebSocketConnector connector)
When connector is started, new empty rights set is created and assigned to that connector. Moreover, it's possible to have a special action class with reserved name ReservedActionName.CONNECTION_STARTED_ACTION_NAME.

Specified by:
connectorStarted in interface org.jwebsocket.api.WebSocketPlugIn
Overrides:
connectorStarted in class org.jwebsocket.plugins.TokenPlugIn
Parameters:
connector - websocket connector.

connectorStopped

public void connectorStopped(org.jwebsocket.api.WebSocketConnector connector,
                             org.jwebsocket.kit.CloseReason closeReason)
Additional operations performed when connector is stopped. It's possible to have a special action class with reserved name ReservedActionName.CONNECTION_STOPPED_ACTION_NAME. Reason of closed connection is given in variable named closeReason.

Specified by:
connectorStopped in interface org.jwebsocket.api.WebSocketPlugIn
Overrides:
connectorStopped in class org.jwebsocket.plugins.TokenPlugIn
Parameters:
connector - websocket connector.
closeReason - connection close reason.

processToken

public void processToken(org.jwebsocket.kit.PlugInResponse response,
                         org.jwebsocket.api.WebSocketConnector connector,
                         org.jwebsocket.token.Token token)
Process token sent by user. If token namespace is equals to BristleConstants.BRISTLE_PLUGIN_NAMESPACE, then plugin chain is aborted and dedicated dispatcher performs action. This is one of the core elements in Bristle plugin. More about dispatching actions can be found in ActionsDispatcher documentation.

Overrides:
processToken in class org.jwebsocket.plugins.TokenPlugIn
Parameters:
response - wrapper object containing information about plugin chain state.
connector - websocket connector.
token - content of the message.

getActionsDispatcher

public ActionsDispatcher getActionsDispatcher()
Gets action dispatcher with actions and handlers inside.

Returns:
actions dispatcher.


Copyright © 2011. All Rights Reserved.