Package org.red5.server
Class Context
java.lang.Object
org.red5.server.Context
- All Implemented Interfaces:
IContext
,ContextMXBean
,Aware
,ApplicationContextAware
,ResourceLoader
,ResourcePatternResolver
This is basic context implementation used by Red5.
-
Field Summary
Modifier and TypeFieldDescriptionprivate ApplicationContext
Spring application contextprivate IClientRegistry
Client registryprivate String
Context pathprivate BeanFactory
Core contextstatic final org.slf4j.Logger
private IMappingStrategy
Mapping strategy collaboratorprivate IPersistenceStore
Persistence storeprivate IScopeResolver
Scope resolver collaboratorprivate IServiceInvoker
Service invoker collaboratorFields 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
ConstructorDescriptionContext()
Initializes core context bean factory using red5.core bean factory from red5.xml contextContext
(ApplicationContext context, String contextPath) Initializes app context and context path from given parameters -
Method Summary
Modifier and TypeMethodDescriptionstatic Context
from
(CompositeData cd) Allows for reconstruction via CompositeData.Return application contextReturn bean instantiated by bean factoryReturn current thread's context classloaderReturn client registrygetCoreService
(String beanId) Return core Red5 service instantiated by core context bean factoryReturn global scopeReturn mapping strategy used by this context.Return persistence storegetResource
(String path) Return resource by pathResource[]
getResources
(String pattern) Return array or resource that match given patterngetScope()
Return scopeReturn scope resolverReturn service invokerboolean
Returns true if the context contains a certain bean, false otherwise.lookupScopeHandler
(String contextPath) Look up scope handler for context pathlookupService
(String serviceName) Look up service by nameresolveScope
(String path) Resolves scope using scope resolver collaboratorresolveScope
(String host, String path) Resolve scope from host and pathresolveScope
(IScope root, String path) Resolves scope from given root using scope resolver.void
setApplicationContext
(ApplicationContext context) Setter for application contextvoid
setClientRegistry
(IClientRegistry clientRegistry) Setter for client registryvoid
setContextPath
(String contextPath) Setter for context path.void
void
setMappingStrategy
(IMappingStrategy mappingStrategy) Setter for mapping strategyvoid
setPersistanceStore
(IPersistenceStore persistanceStore) Setter for persistence storevoid
setScopeResolver
(IScopeResolver scopeResolver) Setter for scope resolvervoid
setServiceInvoker
(IServiceInvoker serviceInvoker) Setter for service invoker
-
Field Details
-
logger
public static final org.slf4j.Logger logger -
applicationContext
Spring application context -
coreContext
Core context -
contextPath
Context path -
scopeResolver
Scope resolver collaborator -
clientRegistry
Client registry -
serviceInvoker
Service invoker collaborator -
mappingStrategy
Mapping strategy collaborator -
persistanceStore
Persistence store
-
-
Constructor Details
-
Context
Initializes core context bean factory using red5.core bean factory from red5.xml context -
Context
@ConstructorProperties({"context","contextPath"}) public Context(ApplicationContext context, String contextPath) Initializes app context and context path from given parameters- Parameters:
context
- Application contextcontextPath
- Context path
-
-
Method Details
-
getGlobalScope
Return global scope- Specified by:
getGlobalScope
in interfaceContextMXBean
- Specified by:
getGlobalScope
in interfaceIContext
- Returns:
- Global scope
-
getScopeResolver
Return scope resolver- Returns:
- scope resolver
-
resolveScope
Resolves scope using scope resolver collaborator- Specified by:
resolveScope
in interfaceContextMXBean
- Specified by:
resolveScope
in interfaceIContext
- Parameters:
path
- Path to resolve- Returns:
- Scope resolution result
-
resolveScope
Resolves scope from given root using scope resolver.- Specified by:
resolveScope
in interfaceContextMXBean
- Specified by:
resolveScope
in interfaceIContext
- Parameters:
root
- Scope to start from.path
- Path to resolve.- Returns:
- Scope resolution result.
-
setClientRegistry
Setter for client registry- Parameters:
clientRegistry
- Client registry
-
setMappingStrategy
Setter for mapping strategy- Parameters:
mappingStrategy
- Mapping strategy
-
setScopeResolver
Setter for scope resolver- Parameters:
scopeResolver
- Scope resolver used to resolve scopes
-
setServiceInvoker
Setter for service invoker- Parameters:
serviceInvoker
- Service invoker object
-
getPersistanceStore
Return persistence store- Specified by:
getPersistanceStore
in interfaceContextMXBean
- Specified by:
getPersistanceStore
in interfaceIContext
- Returns:
- Persistence store
-
setPersistanceStore
Setter for persistence store- Parameters:
persistanceStore
- Persistence store
-
setApplicationContext
Setter for application context- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Parameters:
context
- App context
-
getApplicationContext
Return application context- Specified by:
getApplicationContext
in interfaceContextMXBean
- Specified by:
getApplicationContext
in interfaceIContext
- Returns:
- App context
-
setContextPath
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
Return client registry- Specified by:
getClientRegistry
in interfaceContextMXBean
- Specified by:
getClientRegistry
in interfaceIContext
- Returns:
- Client registry
-
getScope
Return scope- Specified by:
getScope
in interfaceContextMXBean
- Returns:
- null
-
getServiceInvoker
Return service invoker- Specified by:
getServiceInvoker
in interfaceContextMXBean
- Specified by:
getServiceInvoker
in interfaceIContext
- Returns:
- Service invoker
-
lookupService
Look up service by name- Specified by:
lookupService
in interfaceContextMXBean
- Specified by:
lookupService
in interfaceIContext
- Parameters:
serviceName
- Service name- Returns:
- Service object
- Throws:
ServiceNotFoundException
- When service found but nullNoSuchBeanDefinitionException
- When bean with given name doesn't exist
-
lookupScopeHandler
Look up scope handler for context path- Specified by:
lookupScopeHandler
in interfaceContextMXBean
- Specified by:
lookupScopeHandler
in interfaceIContext
- Parameters:
contextPath
- Context path- Returns:
- Scope handler
- Throws:
ScopeHandlerNotFoundException
- If there's no handler for given context path
-
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 interfaceIContext
- Returns:
- Mapping strategy
-
getResources
Return array or resource that match given pattern- Specified by:
getResources
in interfaceContextMXBean
- Specified by:
getResources
in interfaceResourcePatternResolver
- Parameters:
pattern
- Pattern to check against- Returns:
- Array of Resource objects
- Throws:
IOException
- On I/O exception- See Also:
-
getResource
Return resource by path- Specified by:
getResource
in interfaceContextMXBean
- Specified by:
getResource
in interfaceResourceLoader
- Parameters:
path
- Resource path- Returns:
- Resource
- See Also:
-
resolveScope
Resolve scope from host and path- Specified by:
resolveScope
in interfaceContextMXBean
- Parameters:
host
- Hostpath
- Path- Returns:
- Scope
- See Also:
-
hasBean
Returns true if the context contains a certain bean, false otherwise. -
getBean
Return bean instantiated by bean factory- Specified by:
getBean
in interfaceContextMXBean
- Specified by:
getBean
in interfaceIContext
- Parameters:
beanId
- Bean name- Returns:
- Instantiated bean
- See Also:
-
getCoreService
Return core Red5 service instantiated by core context bean factory- Specified by:
getCoreService
in interfaceContextMXBean
- Specified by:
getCoreService
in interfaceIContext
- Parameters:
beanId
- Bean name- Returns:
- Core Red5 service instantiated
- See Also:
-
setCoreBeanFactory
-
getClassLoader
Return current thread's context classloader- Specified by:
getClassLoader
in interfaceResourceLoader
- Returns:
- Classloder context of current thread
-
from
Allows for reconstruction via CompositeData.- Parameters:
cd
- composite data- Returns:
- Context class instance
-