## org.red5.server
Class Context

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

All Implemented Interfaces:
  IContext, ContextMBean, ApplicationContextAware, ResourceLoader, ResourcePatternResolver

    public class Context

extends Object
implements IContext, ApplicationContextAware, ContextMBean

This is basic context implementation used by Red5.

Field Summary
`static 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
`Context()` Initializes core context bean factory using red5.core bean factory from red5.xml context
`Context(ApplicationContext context, String contextPath)` Initializes app context and context path from given parameters

Method Summary
`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
`Resource` `getResource(String path)` Return resouce by path
`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(ApplicationContext context)` Setter for application context
`void` `setClientRegistry(IClientRegistry clientRegistry)` Setter for client registry
`void` `setContextPath(String contextPath)` Setter for context path.
`void` `setCoreBeanFactory(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 Logger logger

Constructor Detail

### Context

    public Context()

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

### Context

    public 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 `ContextMBean`
  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 `ContextMBean`
  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 `ContextMBean`
  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 `ContextMBean`
  Returns:
    Persistence store

### setPersistanceStore

    public void setPersistanceStore(IPersistenceStore persistanceStore)

  Setter for persistence store

  Parameters:
    `persistanceStore` - Persistence store

### setApplicationContext

    public void setApplicationContext(ApplicationContext context)

  Setter for application context

  Specified by:
    `setApplicationContext` in interface `ApplicationContextAware`
  Parameters:
    `context` - App context

### getApplicationContext

    public ApplicationContext getApplicationContext()

  Return application context

  Specified by:
    `getApplicationContext` in interface `IContext`
  Specified by:
    `getApplicationContext` in interface `ContextMBean`
  Returns:
    App context

### setContextPath

    public void setContextPath(String contextPath)

  Setter for context path. Adds slash at the end of path if there's no one

  Specified by:
    `setContextPath` in interface `ContextMBean`
  Parameters:
    `contextPath` - Context path

### getClientRegistry

    public IClientRegistry getClientRegistry()

  Return client registry

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

### getScope

    public IScope getScope()

  Return scope

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

### getServiceInvoker

    public IServiceInvoker getServiceInvoker()

  Return service invoker

  Specified by:
    `getServiceInvoker` in interface `IContext`
  Specified by:
    `getServiceInvoker` in interface `ContextMBean`
  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 `ContextMBean`
  Parameters:
    `serviceName` - Service name
  Returns:
    Service object
  Throws:
    `ServiceNotFoundException` - When service found but null
    `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 `ContextMBean`
  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 `ContextMBean`
  Returns:
    Mapping strategy

### getResources

    public Resource[] getResources(String pattern)
                            throws IOException

  Return array or resournce that match given pattern

  Specified by:
    `getResources` in interface `ContextMBean`
  Specified by:
    `getResources` in interface `ResourcePatternResolver`
  Parameters:
    `pattern` - Pattern to check against
  Returns:
    Array of Resource objects
  Throws:
    `IOException` - On I/O exception
  See Also:
    `Resource`

### getResource

    public Resource getResource(String path)

  Return resouce by path

  Specified by:
    `getResource` in interface `ContextMBean`
  Specified by:
    `getResource` in interface `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 `ContextMBean`
  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 `ContextMBean`
  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 `ContextMBean`
  Parameters:
    `beanId` - Bean name
  Returns:
    Core Red5 service instantiated
  See Also:
    `BeanFactory`

### setCoreBeanFactory

    public void setCoreBeanFactory(BeanFactory core)

### getClassLoader

    public ClassLoader getClassLoader()

  Return current thread's context classloader

  Specified by:
    `getClassLoader` in interface `ResourceLoader`
  Returns:
    Classloder context of current thread

Copyright © 2006-2010 The Red5 Project