org.red5.server.scope

## Class WebScope

- java.lang.Object
- - org.red5.server.scope.BasicScope
  - - org.red5.server.scope.Scope
    - - org.red5.server.scope.WebScope

All Implemented Interfaces:
  IEventDispatcher, IEventHandler, IEventListener, IEventObservable, ICoreObject, IBasicScope, IScope, IServiceHandlerProvider, IScopeStatistics, IStatisticsBase, ScopeMXBean, WebScopeMXBean, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver, org.springframework.web.context.ServletContextAware

    @ManagedResource
    public class WebScope
    extends Scope
    implements org.springframework.web.context.ServletContextAware, WebScopeMXBean

Web scope is special scope that is aware of servlet context and represents scope of a Red5 application within a servlet container (or application server) such as Tomcat, Jetty or JBoss.

Web scope is aware of virtual hosts configuration for Red5 application and is the first scope that instantiated after Red5 application gets started.

Then it loads virtual hosts configuration, adds mappings of paths to global scope that is injected thru Spring IoC context file and runs initialization process.

Red5 server implementation instance and ServletContext are injected as well.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.red5.server.scope.Scope

`Scope.Builder`

### Field Summary

Fields
`protected IApplicationContext` `appContext` The application context this webscope is running in.
`protected IApplicationLoader` `appLoader` Loader for new applications.
`protected String` `contextPath` Context path
`protected String[]` `hostnames` Hostnames
`protected static org.slf4j.Logger` `log` Logger
`protected AtomicBoolean` `registered` Has the web scope been registered?
`protected IServer` `server` Server instance
`protected javax.servlet.ServletContext` `servletContext` Servlet context
`protected AtomicBoolean` `shuttingDown` Is the scope currently shutting down?
`protected String` `virtualHosts` Virtual hosts list as string

### Fields inherited from class org.red5.server.scope.Scope

`attributes, clientStats, connectionStats, lock, oName, subscopeStats`

### Fields inherited from class org.red5.server.scope.BasicScope

`keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, store, type`

### Fields inherited from interface org.red5.server.api.scope.IScope

`SEPARATOR`

### Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver

`CLASSPATH_ALL_URL_PREFIX`

### Fields inherited from interface org.springframework.core.io.ResourceLoader

`CLASSPATH_URL_PREFIX`

### Constructor Summary

Constructors
Constructor and Description
`WebScope()`

### Method Summary

Methods
`IApplicationLoader` `getApplicationLoader()` Return object that can be used to load new applications.
`String` `getContextPath()` Return scope context path
`IServer` `getServer()` Return the server instance connected to this scope.
`boolean` `isShuttingDown()` Is the scope currently shutting down?
`void` `register()` Map all vhosts to global scope then initialize
`void` `setContextPath(String contextPath)` Setter for context path
`void` `setGlobalScope(IGlobalScope globalScope)` Setter for global scope.
`void` `setName()` Web scope has no name
`void` `setParent()` Can't set parent to Web scope.
`void` `setServer(IServer server)` Setter for server
`void` `setServletContext(javax.servlet.ServletContext servletContext)` Servlet context
`void` `setVirtualHosts(String virtualHosts)` Setter for virtual hosts.
`void` `unregister()` Uninitialize and remove all vhosts from the global scope.

### Methods inherited from class org.red5.server.scope.Scope

`addChildScope, connect, connect, createChildScope, destroy, disconnect, dispatchEvent, dump, from, getActiveClients, getActiveConnections, getActiveSubscopes, getAttribute, getAttributeNames, getAttributes, getBasicScope, getBasicScopeNames, getBroadcastScope, getClassLoader, getClients, getConnections, getContext, getCreationTime, getDepth, getEnabled, getHandler, getMaxClients, getMaxConnections, getMaxSubscopes, getParent, getPath, getResource, getResources, getRunning, getScope, getScopeNames, getServiceHandler, getServiceHandlerNames, getServiceHandlers, getServiceHandlers, getStatistics, getTotalClients, getTotalConnections, getTotalSubscopes, handleEvent, hasAttribute, hasChildScope, hasChildScope, hasContext, hasHandler, hasParent, init, isEnabled, isRunning, lookupConnections, registerJMX, registerServiceHandler, removeAttribute, removeChildren, removeChildScope, setAttribute, setAutoStart, setChildLoadPath, setContext, setDepth, setEnabled, setHandler, setName, setParent, setPersistenceClass, start, stop, toString, uninit, unregisterJMX, unregisterServiceHandler`

### Methods inherited from class org.red5.server.scope.BasicScope

`addEventListener, equals, getEventListeners, getName, getStore, getType, hasEventListeners, hashCode, isValid, notifyEvent, removeEventListener, setKeepDelay`

### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

### Methods inherited from interface org.red5.server.jmx.mxbeans.ScopeMXBean

`createChildScope, destroy, getActiveClients, getActiveConnections, getActiveSubscopes, getDepth, getEnabled, getMaxClients, getMaxConnections, getMaxSubscopes, getPath, getRunning, getServiceHandlerNames, getTotalClients, getTotalConnections, getTotalSubscopes, hasChildScope, hasChildScope, hasContext, hasHandler, hasParent, init, setAutoStart, setChildLoadPath, setDepth, setEnabled, setName, setPersistenceClass, start, stop, unregisterServiceHandler`

### Methods inherited from interface org.red5.server.api.scope.IBasicScope

`getName, getStore, getType, isValid, setKeepDelay`

### Methods inherited from interface org.red5.server.api.event.IEventListener

`notifyEvent`

### Methods inherited from interface org.red5.server.api.event.IEventObservable

`addEventListener, getEventListeners, removeEventListener`

### Methods inherited from interface org.red5.server.api.statistics.IScopeStatistics

`getName`

### Field Detail

#### log

    protected static org.slf4j.Logger log

Logger

#### server

    protected IServer server

Server instance

#### servletContext

    protected javax.servlet.ServletContext servletContext

Servlet context

#### contextPath

    protected String contextPath

Context path

#### virtualHosts

    protected String virtualHosts

Virtual hosts list as string

#### hostnames

    protected String[] hostnames

Hostnames

#### registered

    protected AtomicBoolean registered

Has the web scope been registered?

#### appContext

    protected IApplicationContext appContext

The application context this webscope is running in.

#### appLoader

    protected IApplicationLoader appLoader

Loader for new applications.

#### shuttingDown

    protected AtomicBoolean shuttingDown

Is the scope currently shutting down?

### Constructor Detail

#### WebScope

    public WebScope()

### Method Detail

#### setGlobalScope

    public void setGlobalScope(IGlobalScope globalScope)

Setter for global scope. Sets persistence class.

Parameters:
  `globalScope` - Red5 global scope

#### setName

    public void setName()

Web scope has no name

#### setParent

    public void setParent()

Can't set parent to Web scope. Web scope is top level.

#### setServer

    public void setServer(IServer server)

Setter for server

Parameters:
  `server` - Server instance

#### setServletContext

    public void setServletContext(javax.servlet.ServletContext servletContext)

Servlet context

Specified by:
  `setServletContext` in interface `org.springframework.web.context.ServletContextAware`
Parameters:
  `servletContext` - Servlet context

#### setContextPath

    public void setContextPath(String contextPath)

Setter for context path

Specified by:
  `setContextPath` in interface `WebScopeMXBean`
Parameters:
  `contextPath` - Context path

#### getContextPath

    public String getContextPath()

Return scope context path

Specified by:
  `getContextPath` in interface `IScope`
Specified by:
  `getContextPath` in interface `ScopeMXBean`
Overrides:
  `getContextPath` in class `Scope`
Returns:
  Scope context path

#### setVirtualHosts

    public void setVirtualHosts(String virtualHosts)

Setter for virtual hosts. Creates array of hostnames.

Specified by:
  `setVirtualHosts` in interface `WebScopeMXBean`
Parameters:
  `virtualHosts` - Virtual hosts list as string

#### register

    public void register()

Map all vhosts to global scope then initialize

Specified by:
  `register` in interface `WebScopeMXBean`

#### unregister

    public void unregister()

Uninitialize and remove all vhosts from the global scope.

Specified by:
  `unregister` in interface `WebScopeMXBean`

#### getServer

    public IServer getServer()

Return the server instance connected to this scope.

Overrides:
  `getServer` in class `Scope`
Returns:
  the server instance

#### getApplicationLoader

    public IApplicationLoader getApplicationLoader()

Return object that can be used to load new applications.

Returns:
  the application loader

#### isShuttingDown

    public boolean isShuttingDown()

Is the scope currently shutting down?

Specified by:
  `isShuttingDown` in interface `WebScopeMXBean`
Returns:
  is shutting down