Package org.red5.server
Class Context
- java.lang.Object
-
- org.red5.server.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
-
Constructor Summary
Constructors Constructor Description Context()
Initializes core context bean factory using red5.core bean factory from red5.xml contextContext(org.springframework.context.ApplicationContext context, String contextPath)
Initializes app context and context path from given parameters
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Context
from(CompositeData cd)
Allows for reconstruction via CompositeData.org.springframework.context.ApplicationContext
getApplicationContext()
Return application contextObject
getBean(String beanId)
Return bean instantiated by bean factoryClassLoader
getClassLoader()
Return current thread's context classloaderorg.red5.server.api.IClientRegistry
getClientRegistry()
Return client registryObject
getCoreService(String beanId)
Return core Red5 service instantiated by core context bean factoryorg.red5.server.api.scope.IGlobalScope
getGlobalScope()
Return global scopeorg.red5.server.api.IMappingStrategy
getMappingStrategy()
Return mapping strategy used by this context.org.red5.server.api.persistence.IPersistenceStore
getPersistanceStore()
Return persistence storeorg.springframework.core.io.Resource
getResource(String path)
Return resource by pathorg.springframework.core.io.Resource[]
getResources(String pattern)
Return array or resource that match given patternorg.red5.server.api.scope.IScope
getScope()
Return scopeIScopeResolver
getScopeResolver()
Return scope resolverorg.red5.server.api.service.IServiceInvoker
getServiceInvoker()
Return service invokerboolean
hasBean(String beanId)
org.red5.server.api.scope.IScopeHandler
lookupScopeHandler(String contextPath)
Look up scope handler for context pathObject
lookupService(String serviceName)
Look up service by nameorg.red5.server.api.scope.IScope
resolveScope(String path)
Resolves scope using scope resolver collaboratororg.red5.server.api.scope.IScope
resolveScope(String host, String path)
Resolve scope from host and pathorg.red5.server.api.scope.IScope
resolveScope(org.red5.server.api.scope.IScope root, String path)
Resolves scope from given root using scope resolver.void
setApplicationContext(org.springframework.context.ApplicationContext context)
Setter for application contextvoid
setClientRegistry(org.red5.server.api.IClientRegistry clientRegistry)
Setter for client registryvoid
setContextPath(String contextPath)
Setter for context path.void
setCoreBeanFactory(org.springframework.beans.factory.BeanFactory core)
void
setMappingStrategy(org.red5.server.api.IMappingStrategy mappingStrategy)
Setter for mapping strategyvoid
setPersistanceStore(org.red5.server.api.persistence.IPersistenceStore persistanceStore)
Setter for persistence storevoid
setScopeResolver(IScopeResolver scopeResolver)
Setter for scope resolvervoid
setServiceInvoker(org.red5.server.api.service.IServiceInvoker serviceInvoker)
Setter for service invoker
-
-
-
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 contextcontextPath
- Context path
-
-
Method Detail
-
getGlobalScope
public org.red5.server.api.scope.IGlobalScope getGlobalScope()
Return global scope- Specified by:
getGlobalScope
in interfaceContextMXBean
- Specified by:
getGlobalScope
in interfaceorg.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 interfaceContextMXBean
- Specified by:
resolveScope
in interfaceorg.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 interfaceContextMXBean
- Specified by:
resolveScope
in interfaceorg.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 interfaceContextMXBean
- Specified by:
getPersistanceStore
in interfaceorg.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 interfaceorg.springframework.context.ApplicationContextAware
- Parameters:
context
- App context
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()
Return application context- Specified by:
getApplicationContext
in interfaceContextMXBean
- Specified by:
getApplicationContext
in interfaceorg.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 interfaceContextMXBean
- Parameters:
contextPath
- Context path
-
getClientRegistry
public org.red5.server.api.IClientRegistry getClientRegistry()
Return client registry- Specified by:
getClientRegistry
in interfaceContextMXBean
- Specified by:
getClientRegistry
in interfaceorg.red5.server.api.IContext
- Returns:
- Client registry
-
getScope
public org.red5.server.api.scope.IScope getScope()
Return scope- Specified by:
getScope
in interfaceContextMXBean
- Returns:
- null
-
getServiceInvoker
public org.red5.server.api.service.IServiceInvoker getServiceInvoker()
Return service invoker- Specified by:
getServiceInvoker
in interfaceContextMXBean
- Specified by:
getServiceInvoker
in interfaceorg.red5.server.api.IContext
- Returns:
- Service invoker
-
lookupService
public Object lookupService(String serviceName)
Look up service by name- Specified by:
lookupService
in interfaceContextMXBean
- Specified by:
lookupService
in interfaceorg.red5.server.api.IContext
- Parameters:
serviceName
- Service name- Returns:
- Service object
- Throws:
org.red5.server.service.ServiceNotFoundException
- When service found but nullorg.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 interfaceContextMXBean
- Specified by:
lookupScopeHandler
in interfaceorg.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 interfaceContextMXBean
- Specified by:
getMappingStrategy
in interfaceorg.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 interfaceContextMXBean
- Specified by:
getResources
in interfaceorg.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 interfaceContextMXBean
- Specified by:
getResource
in interfaceorg.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 interfaceContextMXBean
- Parameters:
host
- Hostpath
- Path- Returns:
- Scope
- See Also:
IScope
,Scope
-
hasBean
public boolean hasBean(String beanId)
- Specified by:
hasBean
in interfaceorg.red5.server.api.IContext
-
getBean
public Object getBean(String beanId)
Return bean instantiated by bean factory- Specified by:
getBean
in interfaceContextMXBean
- Specified by:
getBean
in interfaceorg.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 interfaceContextMXBean
- Specified by:
getCoreService
in interfaceorg.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 interfaceorg.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
-
-