Class WebScope

All Implemented Interfaces:
Comparable<BasicScope>, IEventDispatcher, IEventHandler, IEventListener, IEventObservable, ICoreObject, IBasicScope, IScope, IServiceHandlerProvider, IScopeStatistics, IStatisticsBase, ScopeMXBean, WebScopeMXBean, Aware, DisposableBean, InitializingBean, ResourceLoader, ResourcePatternResolver, ServletContextAware

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.
  • Field Details

    • log

      protected static org.slf4j.Logger log
      Logger
    • server

      protected transient IServer server
      Server instance
    • appContext

      protected transient IApplicationContext appContext
      The application context this webscope is running in.
    • appLoader

      protected transient IApplicationLoader appLoader
      Loader for new applications.
    • servletContext

      protected transient jakarta.servlet.ServletContext servletContext
      Servlet context
    • contextPath

      @Value("${webapp.contextPath}") protected String contextPath
      Context path
    • virtualHosts

      @Value("${webapp.virtualHosts}") protected String virtualHosts
      Virtual hosts list as string
    • hostnames

      protected String[] hostnames
      Hostnames
    • registered

      protected AtomicBoolean registered
      Has the web scope been registered?
    • shuttingDown

      protected AtomicBoolean shuttingDown
      Is the scope currently shutting down?
  • Constructor Details

    • WebScope

      public WebScope()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface InitializingBean
      Throws:
      Exception
    • destroy

      public void destroy() throws Exception
      Description copied from class: Scope
      Destroys scope
      Specified by:
      destroy in interface DisposableBean
      Specified by:
      destroy in interface ScopeMXBean
      Overrides:
      destroy in class Scope
      Throws:
      Exception - on error
    • 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(jakarta.servlet.ServletContext servletContext)
      Servlet context
      Specified by:
      setServletContext in interface 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
    • splitHostNames

      private void splitHostNames(String virtualHosts)
    • 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
    • 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 interface WebScopeMXBean
      Returns:
      is shutting down