Class Context

  • All Implemented Interfaces:
    org.red5.server.api.IContext, ContextMXBean, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

    public class Context
    extends Object
    implements org.red5.server.api.IContext, org.springframework.context.ApplicationContextAware, ContextMXBean

    This is basic context implementation used by Red5.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static org.slf4j.Logger logger  
      • Fields inherited from interface org.red5.server.api.IContext

        ID
      • 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

      Constructors 
      Constructor Description
      Context()
      Initializes core context bean factory using red5.core bean factory from red5.xml context
      Context​(org.springframework.context.ApplicationContext context, String contextPath)
      Initializes app context and context path from given parameters
    • Field Detail

      • logger

        public static final org.slf4j.Logger logger
    • Constructor Detail

      • Context

        @ConstructorProperties("")
        public Context()
        Initializes core context bean factory using red5.core bean factory from red5.xml context
      • Context

        @ConstructorProperties({"context","contextPath"})
        public Context​(org.springframework.context.ApplicationContext context,
                       String contextPath)
        Initializes app context and context path from given parameters
        Parameters:
        context - Application context
        contextPath - Context path
    • Method Detail

      • getGlobalScope

        public org.red5.server.api.scope.IGlobalScope getGlobalScope()
        Return global scope
        Specified by:
        getGlobalScope in interface ContextMXBean
        Specified by:
        getGlobalScope in interface org.red5.server.api.IContext
        Returns:
        Global scope
      • getScopeResolver

        public IScopeResolver getScopeResolver()
        Return scope resolver
        Returns:
        scope resolver
      • resolveScope

        public org.red5.server.api.scope.IScope resolveScope​(String path)
        Resolves scope using scope resolver collaborator
        Specified by:
        resolveScope in interface ContextMXBean
        Specified by:
        resolveScope in interface org.red5.server.api.IContext
        Parameters:
        path - Path to resolve
        Returns:
        Scope resolution result
      • resolveScope

        public org.red5.server.api.scope.IScope resolveScope​(org.red5.server.api.scope.IScope root,
                                                             String path)
        Resolves scope from given root using scope resolver.
        Specified by:
        resolveScope in interface ContextMXBean
        Specified by:
        resolveScope in interface org.red5.server.api.IContext
        Parameters:
        root - Scope to start from.
        path - Path to resolve.
        Returns:
        Scope resolution result.
      • setClientRegistry

        public void setClientRegistry​(org.red5.server.api.IClientRegistry clientRegistry)
        Setter for client registry
        Parameters:
        clientRegistry - Client registry
      • setMappingStrategy

        public void setMappingStrategy​(org.red5.server.api.IMappingStrategy mappingStrategy)
        Setter for mapping strategy
        Parameters:
        mappingStrategy - Mapping strategy
      • setScopeResolver

        public void setScopeResolver​(IScopeResolver scopeResolver)
        Setter for scope resolver
        Parameters:
        scopeResolver - Scope resolver used to resolve scopes
      • setServiceInvoker

        public void setServiceInvoker​(org.red5.server.api.service.IServiceInvoker serviceInvoker)
        Setter for service invoker
        Parameters:
        serviceInvoker - Service invoker object
      • getPersistanceStore

        public org.red5.server.api.persistence.IPersistenceStore getPersistanceStore()
        Return persistence store
        Specified by:
        getPersistanceStore in interface ContextMXBean
        Specified by:
        getPersistanceStore in interface org.red5.server.api.IContext
        Returns:
        Persistence store
      • setPersistanceStore

        public void setPersistanceStore​(org.red5.server.api.persistence.IPersistenceStore persistanceStore)
        Setter for persistence store
        Parameters:
        persistanceStore - Persistence store
      • setApplicationContext

        public void setApplicationContext​(org.springframework.context.ApplicationContext context)
        Setter for application context
        Specified by:
        setApplicationContext in interface org.springframework.context.ApplicationContextAware
        Parameters:
        context - App context
      • getApplicationContext

        public org.springframework.context.ApplicationContext getApplicationContext()
        Return application context
        Specified by:
        getApplicationContext in interface ContextMXBean
        Specified by:
        getApplicationContext in interface org.red5.server.api.IContext
        Returns:
        App context
      • setContextPath

        public void setContextPath​(String contextPath)
        Setter for context path. Adds a slash at the end of path if there isn't one
        Specified by:
        setContextPath in interface ContextMXBean
        Parameters:
        contextPath - Context path
      • getClientRegistry

        public org.red5.server.api.IClientRegistry getClientRegistry()
        Return client registry
        Specified by:
        getClientRegistry in interface ContextMXBean
        Specified by:
        getClientRegistry in interface org.red5.server.api.IContext
        Returns:
        Client registry
      • getScope

        public org.red5.server.api.scope.IScope getScope()
        Return scope
        Specified by:
        getScope in interface ContextMXBean
        Returns:
        null
      • getServiceInvoker

        public org.red5.server.api.service.IServiceInvoker getServiceInvoker()
        Return service invoker
        Specified by:
        getServiceInvoker in interface ContextMXBean
        Specified by:
        getServiceInvoker in interface org.red5.server.api.IContext
        Returns:
        Service invoker
      • lookupService

        public Object lookupService​(String serviceName)
        Look up service by name
        Specified by:
        lookupService in interface ContextMXBean
        Specified by:
        lookupService in interface org.red5.server.api.IContext
        Parameters:
        serviceName - Service name
        Returns:
        Service object
        Throws:
        org.red5.server.service.ServiceNotFoundException - When service found but null
        org.springframework.beans.factory.NoSuchBeanDefinitionException - When bean with given name doesn't exist
      • lookupScopeHandler

        public org.red5.server.api.scope.IScopeHandler lookupScopeHandler​(String contextPath)
        Look up scope handler for context path
        Specified by:
        lookupScopeHandler in interface ContextMXBean
        Specified by:
        lookupScopeHandler in interface org.red5.server.api.IContext
        Parameters:
        contextPath - Context path
        Returns:
        Scope handler
        Throws:
        ScopeHandlerNotFoundException - If there's no handler for given context path
      • getMappingStrategy

        public org.red5.server.api.IMappingStrategy getMappingStrategy()
        Return mapping strategy used by this context. Mapping strategy define naming rules (prefixes, postfixes, default application name, etc) for all named objects in context.
        Specified by:
        getMappingStrategy in interface ContextMXBean
        Specified by:
        getMappingStrategy in interface org.red5.server.api.IContext
        Returns:
        Mapping strategy
      • getResources

        public org.springframework.core.io.Resource[] getResources​(String pattern)
                                                            throws IOException
        Return array or resource that match given pattern
        Specified by:
        getResources in interface ContextMXBean
        Specified by:
        getResources in interface org.springframework.core.io.support.ResourcePatternResolver
        Parameters:
        pattern - Pattern to check against
        Returns:
        Array of Resource objects
        Throws:
        IOException - On I/O exception
        See Also:
        Resource
      • getResource

        public org.springframework.core.io.Resource getResource​(String path)
        Return resource by path
        Specified by:
        getResource in interface ContextMXBean
        Specified by:
        getResource in interface org.springframework.core.io.ResourceLoader
        Parameters:
        path - Resource path
        Returns:
        Resource
        See Also:
        Resource
      • resolveScope

        public org.red5.server.api.scope.IScope resolveScope​(String host,
                                                             String path)
        Resolve scope from host and path
        Specified by:
        resolveScope in interface ContextMXBean
        Parameters:
        host - Host
        path - Path
        Returns:
        Scope
        See Also:
        IScope, Scope
      • hasBean

        public boolean hasBean​(String beanId)
        Specified by:
        hasBean in interface org.red5.server.api.IContext
      • getBean

        public Object getBean​(String beanId)
        Return bean instantiated by bean factory
        Specified by:
        getBean in interface ContextMXBean
        Specified by:
        getBean in interface org.red5.server.api.IContext
        Parameters:
        beanId - Bean name
        Returns:
        Instantiated bean
        See Also:
        BeanFactory
      • getCoreService

        public Object getCoreService​(String beanId)
        Return core Red5 service instantiated by core context bean factory
        Specified by:
        getCoreService in interface ContextMXBean
        Specified by:
        getCoreService in interface org.red5.server.api.IContext
        Parameters:
        beanId - Bean name
        Returns:
        Core Red5 service instantiated
        See Also:
        BeanFactory
      • setCoreBeanFactory

        public void setCoreBeanFactory​(org.springframework.beans.factory.BeanFactory core)
      • getClassLoader

        public ClassLoader getClassLoader()
        Return current thread's context classloader
        Specified by:
        getClassLoader in interface org.springframework.core.io.ResourceLoader
        Returns:
        Classloder context of current thread
      • from

        public static Context from​(CompositeData cd)
        Allows for reconstruction via CompositeData.
        Parameters:
        cd - composite data
        Returns:
        Context class instance