org.red5.server
Class Server

java.lang.Object
  extended by org.red5.server.Server
All Implemented Interfaces:
IServer, Aware, DisposableBean, InitializingBean, ApplicationContextAware

public class Server
extends Object
implements IServer, ApplicationContextAware, InitializingBean, DisposableBean

Red5 server core class implementation.


Field Summary
protected  ApplicationContext applicationContext
          Spring application context
 Set<IConnectionListener> connectionListeners
           
protected static String EMPTY
          Constant for empty string
protected  ConcurrentMap<String,IGlobalScope> globals
          List of global scopes
protected static Logger log
           
protected  ConcurrentMap<String,String> mapping
          Mappings
 Set<IScopeListener> scopeListeners
           
protected static String SLASH
          Constant for slash
 
Fields inherited from interface org.red5.server.api.IServer
ID
 
Constructor Summary
Server()
           
 
Method Summary
 void addListener(IConnectionListener listener)
          Add listener to get notified about connection events.
 void addListener(IScopeListener listener)
          Add listener to get notified about scope events.
 boolean addMapping(String hostName, String contextPath, String globalName)
          Map key (host + / + context path) and global scope name
 void afterPropertiesSet()
          Initialization section.
 void destroy()
          Destruction section.
 IGlobalScope getGlobal(String name)
          Return global scope by name
 Iterator<String> getGlobalNames()
          Return global scope names set iterator
 Iterator<IGlobalScope> getGlobalScopes()
          Return global scopes set iterator
protected  String getKey(String hostName, String contextPath)
          Return scope key.
 Map<String,String> getMappingTable()
          Return mapping
 int getNotifierThreadPoolSize()
           
 IGlobalScope lookupGlobal(String hostName, String contextPath)
          Does global scope lookup for host name and context path
 void notifyConnected(IConnection conn)
          Notify listeners that a new connection was established.
 void notifyDisconnected(IConnection conn)
          Notify listeners that a connection was disconnected.
 void notifyScopeCreated(IScope scope)
          Notify listeners about a newly created scope.
 void notifyScopeRemoved(IScope scope)
          Notify listeners that a scope was removed.
 void registerGlobal(IGlobalScope scope)
          Register global scope
 void removeListener(IConnectionListener listener)
          Remove listener that got notified about connection events.
 void removeListener(IScopeListener listener)
          Remove listener that got notified about scope events.
 boolean removeMapping(String contextPath)
          Remove all mappings with given context path
 boolean removeMapping(String hostName, String contextPath)
          Remove mapping with given key
 void setApplicationContext(ApplicationContext applicationContext)
          Setter for Spring application context
 void setNotifierThreadPoolSize(int notifierThreadPoolSize)
           
 String toString()
          String representation of server
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

protected static Logger log

globals

protected ConcurrentMap<String,IGlobalScope> globals
List of global scopes


mapping

protected ConcurrentMap<String,String> mapping
Mappings


applicationContext

protected ApplicationContext applicationContext
Spring application context


SLASH

protected static final String SLASH
Constant for slash

See Also:
Constant Field Values

EMPTY

protected static final String EMPTY
Constant for empty string

See Also:
Constant Field Values

scopeListeners

public Set<IScopeListener> scopeListeners

connectionListeners

public Set<IConnectionListener> connectionListeners
Constructor Detail

Server

public Server()
Method Detail

setApplicationContext

public void setApplicationContext(ApplicationContext applicationContext)
Setter for Spring application context

Specified by:
setApplicationContext in interface ApplicationContextAware
Parameters:
applicationContext - Application context

afterPropertiesSet

public void afterPropertiesSet()
                        throws Exception
Initialization section.

Specified by:
afterPropertiesSet in interface InitializingBean
Throws:
Exception

destroy

public void destroy()
             throws Exception
Destruction section.

Specified by:
destroy in interface DisposableBean
Throws:
Exception

getKey

protected String getKey(String hostName,
                        String contextPath)
Return scope key. Scope key consists of host name concatenated with context path by slash symbol

Parameters:
hostName - Host name
contextPath - Context path
Returns:
Scope key as string

lookupGlobal

public IGlobalScope lookupGlobal(String hostName,
                                 String contextPath)
Does global scope lookup for host name and context path

Specified by:
lookupGlobal in interface IServer
Parameters:
hostName - Host name
contextPath - Context path
Returns:
Global scope

getGlobal

public IGlobalScope getGlobal(String name)
Return global scope by name

Specified by:
getGlobal in interface IServer
Parameters:
name - Global scope name
Returns:
Global scope

registerGlobal

public void registerGlobal(IGlobalScope scope)
Register global scope

Specified by:
registerGlobal in interface IServer
Parameters:
scope - Global scope to register

addMapping

public boolean addMapping(String hostName,
                          String contextPath,
                          String globalName)
Map key (host + / + context path) and global scope name

Specified by:
addMapping in interface IServer
Parameters:
hostName - Host name
contextPath - Context path
globalName - Global scope name
Returns:
true if mapping was added, false if already exist

removeMapping

public boolean removeMapping(String hostName,
                             String contextPath)
Remove mapping with given key

Specified by:
removeMapping in interface IServer
Parameters:
hostName - Host name
contextPath - Context path
Returns:
true if mapping was removed, false if key doesn't exist

removeMapping

public boolean removeMapping(String contextPath)
Remove all mappings with given context path

Parameters:
contextPath - Context path
Returns:
true if mapping was removed, false if key doesn't exist

getMappingTable

public Map<String,String> getMappingTable()
Return mapping

Specified by:
getMappingTable in interface IServer
Returns:
Map of "scope key / scope name" pairs

getGlobalNames

public Iterator<String> getGlobalNames()
Return global scope names set iterator

Specified by:
getGlobalNames in interface IServer
Returns:
Iterator

getGlobalScopes

public Iterator<IGlobalScope> getGlobalScopes()
Return global scopes set iterator

Specified by:
getGlobalScopes in interface IServer
Returns:
Iterator

toString

public String toString()
String representation of server

Overrides:
toString in class Object
Returns:
String representation of server

addListener

public void addListener(IScopeListener listener)
Add listener to get notified about scope events.

Specified by:
addListener in interface IServer
Parameters:
listener - the listener to add

addListener

public void addListener(IConnectionListener listener)
Add listener to get notified about connection events.

Specified by:
addListener in interface IServer
Parameters:
listener - the listener to add

removeListener

public void removeListener(IScopeListener listener)
Remove listener that got notified about scope events.

Specified by:
removeListener in interface IServer
Parameters:
listener - the listener to remove

removeListener

public void removeListener(IConnectionListener listener)
Remove listener that got notified about connection events.

Specified by:
removeListener in interface IServer
Parameters:
listener - the listener to remove

notifyScopeCreated

public void notifyScopeCreated(IScope scope)
Notify listeners about a newly created scope.

Parameters:
scope - the scope that was created

notifyScopeRemoved

public void notifyScopeRemoved(IScope scope)
Notify listeners that a scope was removed.

Parameters:
scope - the scope that was removed

notifyConnected

public void notifyConnected(IConnection conn)
Notify listeners that a new connection was established.

Parameters:
conn - the new connection

notifyDisconnected

public void notifyDisconnected(IConnection conn)
Notify listeners that a connection was disconnected.

Parameters:
conn - the disconnected connection

getNotifierThreadPoolSize

public int getNotifierThreadPoolSize()

setNotifierThreadPoolSize

public void setNotifierThreadPoolSize(int notifierThreadPoolSize)


Copyright © 2006-2012 The Red5 Project