org.red5.server

## Class Context

- java.lang.Object
- - org.red5.server.Context

All Implemented Interfaces:
  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 IContext, org.springframework.context.ApplicationContextAware, ContextMXBean

This is basic context implementation used by Red5.

### Field Summary

Fields
`static org.slf4j.Logger` `logger`

### Fields inherited from interface org.red5.server.api.IContext

`ID`

### Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver

`CLASSPATH_ALL_URL_PREFIX`

### Fields inherited from interface org.springframework.core.io.ResourceLoader

`CLASSPATH_URL_PREFIX`

### Constructor Summary

Constructors
Constructor and 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

### Method Summary

Methods
`static Context` `from(CompositeData cd)` Allows for reconstruction via CompositeData.
`org.springframework.context.ApplicationContext` `getApplicationContext()` Return application context
`Object` `getBean(String beanId)` Return bean instantiated by bean factory
`ClassLoader` `getClassLoader()` Return current thread's context classloader
`IClientRegistry` `getClientRegistry()` Return client registry
`Object` `getCoreService(String beanId)` Return core Red5 service instantiated by core context bean factory
`IGlobalScope` `getGlobalScope()` Return global scope
`IMappingStrategy` `getMappingStrategy()` Return mapping strategy used by this context.
`IPersistenceStore` `getPersistanceStore()` Return persistence store
`org.springframework.core.io.Resource` `getResource(String path)` Return resouce by path
`org.springframework.core.io.Resource[]` `getResources(String pattern)` Return array or resournce that match given pattern
`IScope` `getScope()` Return scope
`IScopeResolver` `getScopeResolver()` Return scope resolver
`IServiceInvoker` `getServiceInvoker()` Return service invoker
`boolean` `hasBean(String beanId)` Returns true if the context contains a certain bean, false otherwise.
`IScopeHandler` `lookupScopeHandler(String contextPath)` Look up scope handler for context path
`Object` `lookupService(String serviceName)` Look up service by name
`IScope` `resolveScope(IScope root, String path)` Resolves scope from given root using scope resolver.
`IScope` `resolveScope(String path)` Resolves scope using scope resolver collaborator
`IScope` `resolveScope(String host, String path)` Resolve scope from host and path
`void` `setApplicationContext(org.springframework.context.ApplicationContext context)` Setter for application context
`void` `setClientRegistry(IClientRegistry clientRegistry)` Setter for client registry
`void` `setContextPath(String contextPath)` Setter for context path.
`void` `setCoreBeanFactory(org.springframework.beans.factory.BeanFactory core)`
`void` `setMappingStrategy(IMappingStrategy mappingStrategy)` Setter for mapping strategy
`void` `setPersistanceStore(IPersistenceStore persistanceStore)` Setter for persistence store
`void` `setScopeResolver(IScopeResolver scopeResolver)` Setter for scope resolver
`void` `setServiceInvoker(IServiceInvoker serviceInvoker)` Setter for service invoker

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### logger

    public static org.slf4j.Logger logger

### Constructor Detail

#### Context

    @ConstructorProperties(value="")
    public Context()

Initializes core context bean factory using red5.core bean factory from red5.xml context

#### Context

    @ConstructorProperties(value={"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 IGlobalScope getGlobalScope()

Return global scope

Specified by:
  `getGlobalScope` in interface `IContext`
Specified by:
  `getGlobalScope` in interface `ContextMXBean`
Returns:
  Global scope

#### getScopeResolver

    public IScopeResolver getScopeResolver()

Return scope resolver

Returns:
  scope resolver

#### resolveScope

    public IScope resolveScope(String path)

Resolves scope using scope resolver collaborator

Specified by:
  `resolveScope` in interface `IContext`
Specified by:
  `resolveScope` in interface `ContextMXBean`
Parameters:
  `path` - Path to resolve
Returns:
  Scope resolution result

#### resolveScope

    public IScope resolveScope(IScope root,
                      String path)

Resolves scope from given root using scope resolver.

Specified by:
  `resolveScope` in interface `IContext`
Specified by:
  `resolveScope` in interface `ContextMXBean`
Parameters:
  `root` - Scope to start from.
  `path` - Path to resolve.
Returns:
  Scope resolution result.

#### setClientRegistry

    public void setClientRegistry(IClientRegistry clientRegistry)

Setter for client registry

Parameters:
  `clientRegistry` - Client registry

#### setMappingStrategy

    public void setMappingStrategy(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(IServiceInvoker serviceInvoker)

Setter for service invoker

Parameters:
  `serviceInvoker` - Service invoker object

#### getPersistanceStore

    public IPersistenceStore getPersistanceStore()

Return persistence store

Specified by:
  `getPersistanceStore` in interface `IContext`
Specified by:
  `getPersistanceStore` in interface `ContextMXBean`
Returns:
  Persistence store

#### setPersistanceStore

    public void setPersistanceStore(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 `IContext`
Specified by:
  `getApplicationContext` in interface `ContextMXBean`
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 IClientRegistry getClientRegistry()

Return client registry

Specified by:
  `getClientRegistry` in interface `IContext`
Specified by:
  `getClientRegistry` in interface `ContextMXBean`
Returns:
  Client registry

#### getScope

    public IScope getScope()

Return scope

Specified by:
  `getScope` in interface `ContextMXBean`
Returns:
  null

#### getServiceInvoker

    public IServiceInvoker getServiceInvoker()

Return service invoker

Specified by:
  `getServiceInvoker` in interface `IContext`
Specified by:
  `getServiceInvoker` in interface `ContextMXBean`
Returns:
  Service invoker

#### lookupService

    public Object lookupService(String serviceName)

Look up service by name

Specified by:
  `lookupService` in interface `IContext`
Specified by:
  `lookupService` in interface `ContextMXBean`
Parameters:
  `serviceName` - Service name
Returns:
  Service object
Throws:
  `ServiceNotFoundException` - When service found but null
  `org.springframework.beans.factory.NoSuchBeanDefinitionException` - When bean with given name doesn't exist

#### lookupScopeHandler

    public IScopeHandler lookupScopeHandler(String contextPath)

Look up scope handler for context path

Specified by:
  `lookupScopeHandler` in interface `IContext`
Specified by:
  `lookupScopeHandler` in interface `ContextMXBean`
Parameters:
  `contextPath` - Context path
Returns:
  Scope handler
Throws:
  `ScopeHandlerNotFoundException` - If there's no handler for given context path

#### getMappingStrategy

    public 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 `IContext`
Specified by:
  `getMappingStrategy` in interface `ContextMXBean`
Returns:
  Mapping strategy

#### getResources

    public org.springframework.core.io.Resource[] getResources(String pattern)
                                                        throws IOException

Return array or resournce 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 resouce 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 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)

Returns true if the context contains a certain bean, false otherwise.

Specified by:
  `hasBean` in interface `IContext`
Parameters:
  `beanId` - The name of the bean to find.
Returns:
  True if the bean exists, false otherwise.

#### getBean

    public Object getBean(String beanId)

Return bean instantiated by bean factory

Specified by:
  `getBean` in interface `IContext`
Specified by:
  `getBean` in interface `ContextMXBean`
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 `IContext`
Specified by:
  `getCoreService` in interface `ContextMXBean`
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