org.atmosphere.nettosphere
Class Config.Builder

java.lang.Object
  extended by org.atmosphere.nettosphere.Config.Builder
Enclosing class:
Config

public static final class Config.Builder
extends Object


Constructor Summary
Config.Builder()
           
 
Method Summary
 Config.Builder aggregateRequestBodyInMemory(boolean aggregateRequestBodyInMemory)
          By default, Nettosphere aggregate the HTTP request's body in memory an invoke an Atmosphere's components with a single AtmosphereResource.
 Config.Builder broadcaster(Class<? extends org.atmosphere.cpr.Broadcaster> broadcasterClass)
          Configure the default Broadcaster
 Config.Builder broadcasterCache(Class<? extends org.atmosphere.cpr.BroadcasterCache> broadcasterCache)
          Configure the default BroadcasterCache
 Config.Builder broadcasterFactory(org.atmosphere.cpr.BroadcasterFactory broadcasterFactory)
          Configure the default BroadcasterFactory
 Config build()
          Build an instance of this class.
 Config.Builder channelUpstreamHandler(org.jboss.netty.channel.ChannelUpstreamHandler h)
          Add a ChannelUpstreamHandler.
 Config.Builder configFile(String atmosphereDotXmlPath)
          The path location of the atmosphere.xml file.
 Config.Builder enablePong(boolean enablePong)
          Enable WebSokcet Pong message.
 Config.Builder excludeInterceptor(String interceptor)
          Exclude an AtmosphereInterceptor from being added, at startup, by Atmosphere.
 Config.Builder host(String host)
          The server's host
 Config.Builder initParam(String name, String value)
          Add some init param
 Config.Builder interceptor(org.atmosphere.cpr.AtmosphereInterceptor interceptor)
          Add an AtmosphereInterceptor
 Config.Builder mappingPath(String mappingPath)
          Set the mapping path.
 Config.Builder maxChunkContentLength(int maxChunkContentLength)
          When aggregateRequestBodyInMemory is true,the maximum length of the aggregated content.
 Config.Builder port(int port)
          The server's port
 Config.Builder resource(Class<?> c)
          Add an annotated class.
 Config.Builder resource(Handler handler)
          Add an Handler mapped to the default, which is '/*'
 Config.Builder resource(String path)
          Add a path to scan when looking for static resources like javascript file, html, etc.
 Config.Builder resource(String path, org.atmosphere.cpr.AtmosphereHandler c)
          Add an AtmosphereHandler that will be mapped to the specified path
 Config.Builder resource(String path, Class<?> c)
          Add an AtmosphereHandler or Servlet class
 Config.Builder resource(String path, Handler handler)
          Add an Handler that will be mapped to the specified path
 Config.Builder resource(String path, javax.servlet.Servlet c)
          Add an Servlet that will be mapped to the specified path
 Config.Builder scanLibrary(String librariesPath)
          Set the path to the library when annotation scanning is enabled.
 Config.Builder socketKeepAlive(boolean socketKeepAlive)
          Set Netty's Bootstrap 'child.keepAlive'
 Config.Builder socketNoTcpDelay(boolean socketNoTcpDelay)
          Set Netty's Bootstrap 'child.tcpDelay'
 Config.Builder sslContext(SSLContext context)
          Set an SSLContext in order enable SSL
 Config.Builder sslContextListener(SSLContextListener listener)
          Add a SSLContextListener
 Config.Builder supportChunking(boolean supportChunking)
          Set to false to override the default behavior when writing bytes, which is use chunking.
 Config.Builder webSocketProtocol(Class<? extends org.atmosphere.websocket.WebSocketProtocol> webSocketProtocol)
          Configure the default WebSocketProtocol
 Config.Builder writeBufferPoolCleanupFrequency(long writeBufferPoolCleanupFrequency)
          The frequency the ChannelBufferPool is resized and garbaged.
 Config.Builder writeBufferPoolSize(int writeBufferPoolSize)
          The internal size of the underlying ChannelBufferPool size for I/O operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Config.Builder

public Config.Builder()
Method Detail

sslContext

public Config.Builder sslContext(SSLContext context)
Set an SSLContext in order enable SSL

Parameters:
context -
Returns:
this

sslContextListener

public Config.Builder sslContextListener(SSLContextListener listener)
Add a SSLContextListener

Parameters:
listener -
Returns:
this

mappingPath

public Config.Builder mappingPath(String mappingPath)
Set the mapping path. If you have worked with Servlet, the mapping path is equivalent to the servlet path.

Parameters:
mappingPath - the path under which the application will be mapped.
Returns:
this

enablePong

public Config.Builder enablePong(boolean enablePong)
Enable WebSokcet Pong message. Disabled by default.

Parameters:
enablePong - Enable WebSokcet Pong message
Returns:
this

maxChunkContentLength

public Config.Builder maxChunkContentLength(int maxChunkContentLength)
When aggregateRequestBodyInMemory is true,the maximum length of the aggregated content. If the length of the aggregated content exceeds this value, a TooLongFrameException will be raised.

Returns:
this

scanLibrary

public Config.Builder scanLibrary(String librariesPath)
Set the path to the library when annotation scanning is enabled. Default is "./". Use this method when your annotated resource is packaged inside the jar/zip.

Parameters:
librariesPath - the path to the library when annotation scanning is enabled.
Returns:
this

configFile

public Config.Builder configFile(String atmosphereDotXmlPath)
The path location of the atmosphere.xml file.

Parameters:
atmosphereDotXmlPath - path location of the atmosphere.xml file.
Returns:
this

host

public Config.Builder host(String host)
The server's host

Parameters:
host - server's host
Returns:
this

port

public Config.Builder port(int port)
The server's port

Parameters:
port - server's port
Returns:
this

initParam

public Config.Builder initParam(String name,
                                String value)
Add some init param

Parameters:
name - the name
value - the value
Returns:
this

resource

public Config.Builder resource(String path)
Add a path to scan when looking for static resources like javascript file, html, etc.

Parameters:
path -
Returns:
this

resource

public Config.Builder resource(String path,
                               org.atmosphere.cpr.AtmosphereHandler c)
Add an AtmosphereHandler that will be mapped to the specified path

Parameters:
path - a mapping path
c - an AtmosphereHandler
Returns:
this

resource

public Config.Builder resource(String path,
                               javax.servlet.Servlet c)
Add an Servlet that will be mapped to the specified path

Parameters:
path - a mapping path
c - an Servlet
Returns:
this

resource

public Config.Builder resource(Handler handler)
Add an Handler mapped to the default, which is '/*'

Parameters:
handler - Handler
Returns:
this

resource

public Config.Builder resource(String path,
                               Handler handler)
Add an Handler that will be mapped to the specified path

Parameters:
handler - Handler
Returns:
this

resource

public Config.Builder resource(Class<?> c)
Add an annotated class. The annotation can be from Atmosphere or Jersey.

Parameters:
c - an annotated class. The annotation can be from Atmosphere or Jersey.
Returns:
this

resource

public Config.Builder resource(String path,
                               Class<?> c)
Add an AtmosphereHandler or Servlet class

Parameters:
path - a mapping path
c - an AtmosphereHandler or Servlet class
Returns:
this

broadcaster

public Config.Builder broadcaster(Class<? extends org.atmosphere.cpr.Broadcaster> broadcasterClass)
Configure the default Broadcaster

Parameters:
broadcasterClass - a Broadcaster
Returns:
this

broadcasterFactory

public Config.Builder broadcasterFactory(org.atmosphere.cpr.BroadcasterFactory broadcasterFactory)
Configure the default BroadcasterFactory

Parameters:
broadcasterFactory - a BroadcasterFactory's class
Returns:
this

broadcasterCache

public Config.Builder broadcasterCache(Class<? extends org.atmosphere.cpr.BroadcasterCache> broadcasterCache)
Configure the default BroadcasterCache

Parameters:
broadcasterCache - a BroadcasterCache's class
Returns:
this

webSocketProtocol

public Config.Builder webSocketProtocol(Class<? extends org.atmosphere.websocket.WebSocketProtocol> webSocketProtocol)
Configure the default WebSocketProtocol

Parameters:
webSocketProtocol - a WebSocketProtocol's class
Returns:
this

interceptor

public Config.Builder interceptor(org.atmosphere.cpr.AtmosphereInterceptor interceptor)
Add an AtmosphereInterceptor

Parameters:
interceptor - an AtmosphereInterceptor
Returns:
this

excludeInterceptor

public Config.Builder excludeInterceptor(String interceptor)
Exclude an AtmosphereInterceptor from being added, at startup, by Atmosphere. The default's AtmosphereInterceptor are candidates for being excluded

Parameters:
interceptor - an AtmosphereInterceptor
Returns:
this

channelUpstreamHandler

public Config.Builder channelUpstreamHandler(org.jboss.netty.channel.ChannelUpstreamHandler h)
Add a ChannelUpstreamHandler. All will be executed before BridgeRuntime

Parameters:
h - ChannelUpstreamHandler
Returns:
this;

supportChunking

public Config.Builder supportChunking(boolean supportChunking)
Set to false to override the default behavior when writing bytes, which is use chunking. When set to false the ChunkedWriteHandler will not be added to the Netty's ChannelPipeline

This is strongly recommended to turn chunking to false if you are using websocket to get better performance.

Parameters:
supportChunking - false to disable.
Returns:
this

aggregateRequestBodyInMemory

public Config.Builder aggregateRequestBodyInMemory(boolean aggregateRequestBodyInMemory)
By default, Nettosphere aggregate the HTTP request's body in memory an invoke an Atmosphere's components with a single AtmosphereResource. Setting supportChunkAggregator to false will instead invoke Atmosphere's component with a new AtmosphereResource each time the request's body is read in memory. Setting to false may significantly increase the performance and reduce memory footprint. Note that setting this value to false may deliver to your Atmosphere's component partial body, so your application must make sure to aggregate the body before parsing the data if needed. For example, if you are using JSON as format, make sure you parse the data incrementally.

Parameters:
aggregateRequestBodyInMemory - false to disable.
Returns:
this

socketNoTcpDelay

public Config.Builder socketNoTcpDelay(boolean socketNoTcpDelay)
Set Netty's Bootstrap 'child.tcpDelay'

Parameters:
socketNoTcpDelay -
Returns:
this

socketKeepAlive

public Config.Builder socketKeepAlive(boolean socketKeepAlive)
Set Netty's Bootstrap 'child.keepAlive'

Parameters:
socketKeepAlive -
Returns:
this

writeBufferPoolSize

public Config.Builder writeBufferPoolSize(int writeBufferPoolSize)
The internal size of the underlying ChannelBufferPool size for I/O operation. Default is 50. If set to -1, a new ChannelBuffer will be created and never pooled.

Parameters:
writeBufferPoolSize - the max size of the pool.
Returns:
this;

writeBufferPoolCleanupFrequency

public Config.Builder writeBufferPoolCleanupFrequency(long writeBufferPoolCleanupFrequency)
The frequency the ChannelBufferPool is resized and garbaged. Default is 30000.

Parameters:
writeBufferPoolCleanupFrequency - the frequency
Returns:
this

build

public Config build()
Build an instance of this class.

Returns:


Copyright © 2014. All Rights Reserved.