Package 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:
Comparable<BasicScope>
,IEventDispatcher
,IEventHandler
,IEventListener
,IEventObservable
,ICoreObject
,IBasicScope
,IScope
,IServiceHandlerProvider
,IScopeStatistics
,IStatisticsBase
,ScopeMXBean
,WebScopeMXBean
,Aware
,DisposableBean
,InitializingBean
,ResourceLoader
,ResourcePatternResolver
,ServletContextAware
@ManagedResource
public class WebScope
extends Scope
implements ServletContextAware, WebScopeMXBean, InitializingBean, DisposableBean
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
Modifier and TypeFieldDescriptionprotected IApplicationContext
The application context this webscope is running in.protected IApplicationLoader
Loader for new applications.protected String
Context pathprotected String[]
Hostnamesprotected static org.slf4j.Logger
Loggerprotected AtomicBoolean
Has the web scope been registered?protected IServer
Server instanceprotected jakarta.servlet.ServletContext
Servlet contextprotected AtomicBoolean
Is the scope currently shutting down?protected String
Virtual hosts list as stringFields inherited from class org.red5.server.scope.Scope
attributes, connectionStats, oName, subscopeStats
Fields inherited from class org.red5.server.scope.BasicScope
creation, keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, securityHandlers, store, type
Fields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIX
Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
destroy()
Destroys scopeprivate final void
Sets the local app context variable based on host id if available in the servlet context.Return object that can be used to load new applications.Return scope context pathReturn the server instance connected to this scope.boolean
Is the scope currently shutting down?void
register()
Map all vhosts to global scope then initializevoid
setContextPath
(String contextPath) Setter for context pathvoid
setGlobalScope
(IGlobalScope globalScope) Setter for global scope.void
setName()
Web scope has no namevoid
Can't set parent to Web scope.void
Setter for servervoid
setServletContext
(jakarta.servlet.ServletContext servletContext) Servlet contextvoid
setVirtualHosts
(String virtualHosts) Setter for virtual hosts.private void
splitHostNames
(String virtualHosts) void
Uninitialize and remove all vhosts from the global scope.Methods inherited from class org.red5.server.scope.Scope
addChildScope, connect, connect, createChildScope, disconnect, dispatchEvent, dump, equals, from, getActiveClients, getActiveConnections, getActiveSubscopes, getAttribute, getAttributeNames, getAttributes, getBasicScope, getBasicScopeNames, getBroadcastScope, getClassLoader, getClientConnections, 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, hashCode, hasParent, init, isEnabled, isRunning, lookupConnection, 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, compareTo, getEventListeners, getName, getStore, getType, hasEventListeners, isConnectionAllowed, isScopeAllowed, isValid, notifyEvent, removeEventListener, setKeepDelay, setSecurityHandlers
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.red5.server.api.scope.IBasicScope
getName, getStore, getType, isConnectionAllowed, isScopeAllowed, isValid, setKeepDelay, setSecurityHandlers
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
Methods inherited from interface org.red5.server.jmx.mxbeans.ScopeMXBean
createChildScope, 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
-
Field Details
-
log
protected static org.slf4j.Logger logLogger -
server
Server instance -
appContext
The application context this webscope is running in. -
appLoader
Loader for new applications. -
servletContext
protected transient jakarta.servlet.ServletContext servletContextServlet context -
contextPath
Context path -
virtualHosts
Virtual hosts list as string -
hostnames
Hostnames -
registered
Has the web scope been registered? -
shuttingDown
Is the scope currently shutting down?
-
-
Constructor Details
-
WebScope
public WebScope()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceInitializingBean
- Throws:
Exception
-
destroy
Description copied from class:Scope
Destroys scope- Specified by:
destroy
in interfaceDisposableBean
- Specified by:
destroy
in interfaceScopeMXBean
- Overrides:
destroy
in classScope
- Throws:
Exception
- on error
-
setGlobalScope
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
Setter for server- Parameters:
server
- Server instance
-
setServletContext
public void setServletContext(jakarta.servlet.ServletContext servletContext) Servlet context- Specified by:
setServletContext
in interfaceServletContextAware
- Parameters:
servletContext
- Servlet context
-
setContextPath
Setter for context path- Specified by:
setContextPath
in interfaceWebScopeMXBean
- Parameters:
contextPath
- Context path
-
getContextPath
Return scope context path- Specified by:
getContextPath
in interfaceIScope
- Specified by:
getContextPath
in interfaceScopeMXBean
- Overrides:
getContextPath
in classScope
- Returns:
- Scope context path
-
setVirtualHosts
Setter for virtual hosts. Creates array of hostnames.- Specified by:
setVirtualHosts
in interfaceWebScopeMXBean
- Parameters:
virtualHosts
- Virtual hosts list as string
-
splitHostNames
-
register
public void register()Map all vhosts to global scope then initialize- Specified by:
register
in interfaceWebScopeMXBean
-
unregister
public void unregister()Uninitialize and remove all vhosts from the global scope.- Specified by:
unregister
in interfaceWebScopeMXBean
-
getServer
Return the server instance connected to this scope. -
getApplicationLoader
Return object that can be used to load new applications.- Returns:
- the application loader
-
getAppContext
private final void getAppContext()Sets the local app context variable based on host id if available in the servlet context. -
isShuttingDown
public boolean isShuttingDown()Is the scope currently shutting down?- Specified by:
isShuttingDown
in interfaceWebScopeMXBean
- Returns:
- is shutting down
-