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
FieldsModifier and TypeFieldDescriptionprotected IApplicationContextThe application context this webscope is running in.protected IApplicationLoaderLoader for new applications.protected StringContext pathprotected String[]Hostnamesprotected static org.slf4j.LoggerLoggerprotected AtomicBooleanHas the web scope been registered?protected IServerServer instanceprotected jakarta.servlet.ServletContextServlet contextprotected AtomicBooleanIs the scope currently shutting down?protected StringVirtual hosts list as stringFields inherited from class org.red5.server.scope.Scope
attributes, connectionStats, oName, subscopeStatsFields inherited from class org.red5.server.scope.BasicScope
creation, keepDelay, keepOnDisconnect, listeners, name, parent, persistenceClass, persistent, securityHandlers, store, typeFields inherited from interface org.springframework.core.io.ResourceLoader
CLASSPATH_URL_PREFIXFields inherited from interface org.springframework.core.io.support.ResourcePatternResolver
CLASSPATH_ALL_URL_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoiddestroy()Destroys scopeprivate final voidSets 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.booleanIs the scope currently shutting down?voidregister()Map all vhosts to global scope then initializevoidsetContextPath(String contextPath) Setter for context pathvoidsetGlobalScope(IGlobalScope globalScope) Setter for global scope.voidsetName()Web scope has no namevoidCan't set parent to Web scope.voidSetter for servervoidsetServletContext(jakarta.servlet.ServletContext servletContext) Servlet contextvoidsetVirtualHosts(String virtualHosts) Setter for virtual hosts.private voidsplitHostNames(String virtualHosts) voidUninitialize 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, unregisterServiceHandlerMethods inherited from class org.red5.server.scope.BasicScope
addEventListener, compareTo, getEventListeners, getName, getStore, getType, hasEventListeners, isConnectionAllowed, isScopeAllowed, isValid, notifyEvent, removeEventListener, setKeepDelay, setSecurityHandlersMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.red5.server.api.scope.IBasicScope
getName, getStore, getType, isConnectionAllowed, isScopeAllowed, isValid, setKeepDelay, setSecurityHandlersMethods inherited from interface org.red5.server.api.event.IEventListener
notifyEventMethods inherited from interface org.red5.server.api.event.IEventObservable
addEventListener, getEventListeners, removeEventListenerMethods inherited from interface org.red5.server.api.statistics.IScopeStatistics
getNameMethods 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:
afterPropertiesSetin interfaceInitializingBean- Throws:
Exception
-
destroy
Description copied from class:ScopeDestroys scope- Specified by:
destroyin interfaceDisposableBean- Specified by:
destroyin interfaceScopeMXBean- Overrides:
destroyin 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:
setServletContextin interfaceServletContextAware- Parameters:
servletContext- Servlet context
-
setContextPath
Setter for context path- Specified by:
setContextPathin interfaceWebScopeMXBean- Parameters:
contextPath- Context path
-
getContextPath
Return scope context path- Specified by:
getContextPathin interfaceIScope- Specified by:
getContextPathin interfaceScopeMXBean- Overrides:
getContextPathin classScope- Returns:
- Scope context path
-
setVirtualHosts
Setter for virtual hosts. Creates array of hostnames.- Specified by:
setVirtualHostsin interfaceWebScopeMXBean- Parameters:
virtualHosts- Virtual hosts list as string
-
splitHostNames
-
register
public void register()Map all vhosts to global scope then initialize- Specified by:
registerin interfaceWebScopeMXBean
-
unregister
public void unregister()Uninitialize and remove all vhosts from the global scope.- Specified by:
unregisterin 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:
isShuttingDownin interfaceWebScopeMXBean- Returns:
- is shutting down
-