Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.eclipse.gemini.blueprint.context.support
Class AbstractOsgiBundleApplicationContext

    java.lang.Object
      org.springframework.core.io.DefaultResourceLoader
          org.springframework.context.support.AbstractApplicationContext
              org.springframework.context.support.AbstractRefreshableApplicationContext
                  org.eclipse.gemini.blueprint.context.support.AbstractOsgiBundleApplicationContext

All Implemented Interfaces:
  ConfigurableOsgiBundleApplicationContext, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.ListableBeanFactory, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

Direct Known Subclasses:
  AbstractDelegatedExecutionApplicationContext

    public abstract class AbstractOsgiBundleApplicationContext

extends org.springframework.context.support.AbstractRefreshableApplicationContext
implements ConfigurableOsgiBundleApplicationContext

`AbstractRefreshableApplicationContext` subclass that implements the `ConfigurableOsgiBundleApplicationContext` interface for OSGi environments. Pre-implements a `configLocation` property, to be populated through the `ConfigurableOsgiApplicationContext` interface after OSGi bundle startup.

This class is as easy to subclass as `AbstractRefreshableApplicationContext`(see the javadoc for details): all you need to implement is the `loadBeanDefinitions` method Note that implementations are supposed to load bean definitions from the files specified by the locations returned by `getConfigLocations` method.

In addition to the special beans detected by `AbstractApplicationContext`, this class registers the `BundleContextAwareProcessor` for processing beans that implement the `BundleContextAware` interface. Also it interprets resource paths as OSGi bundle resources (either from the bundle class space, bundle space or jar space).

This application context implementation offers the OSGi-specific, bundle scope.

Note: `OsgiApplicationContext` implementations are generally supposed to configure themselves based on the configuration received through the `ConfigurableOsgiBundleApplicationContext` interface. In contrast, a stand-alone application context might allow for configuration in custom startup code (for example, `GenericApplicationContext`).

Author:
  Costin Leau, Adrian Colyer, Hal Hildebrand

Field Summary

Fields inherited from class org.springframework.context.support.AbstractApplicationContext
`APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME`

Fields inherited from interface org.eclipse.gemini.blueprint.context.ConfigurableOsgiBundleApplicationContext
`APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME, BUNDLE_BEAN_NAME, BUNDLE_CONTEXT_BEAN_NAME, SPRING_DM_APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME`

Fields inherited from interface org.springframework.context.ConfigurableApplicationContext
`CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME`

Fields inherited from interface org.springframework.beans.factory.BeanFactory
`FACTORY_BEAN_PREFIX`

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
`AbstractOsgiBundleApplicationContext()` Creates a new `AbstractOsgiBundleApplicationContext` with no parent.
`AbstractOsgiBundleApplicationContext(org.springframework.context.ApplicationContext parent)` Creates a new `AbstractOsgiBundleApplicationContext` with the given parent context.

Method Summary
`protected org.springframework.core.io.support.ResourcePatternResolver` | `createResourcePatternResolver()` Creates an OSGi specific resource pattern resolver.
`protected void` | `customizeApplicationContextServiceProperties(Map<Object,Object> serviceProperties)` Customizes the properties of the application context OSGi service.
`protected void` | `destroyBeans()`
`protected void` | `doClose()` Unregister the ApplicationContext OSGi service (in case there is any).
`protected void` | `finishRefresh()`
`org.osgi.framework.Bundle` | `getBundle()` Returns the OSGi `Bundle` for this application context.
`org.osgi.framework.BundleContext` | `getBundleContext()` Return the `BundleContext` for this application context.
`ClassLoader` | `getClassLoader()`
`String[]` | `getConfigLocations()` Returns this application context configuration locations.
`protected String[]` | `getDefaultConfigLocations()` Returns the default configuration locations to use, for the case where no explicit configuration locations have been specified.
`org.springframework.core.io.Resource` | `getResource(String location)`
`protected org.springframework.core.io.Resource` | `getResourceByPath(String path)`
`protected org.springframework.core.io.support.ResourcePatternResolver` | `getResourcePatternResolver()` This implementation supports pattern matching inside the OSGi bundle.
`org.springframework.core.io.Resource[]` | `getResources(String locationPattern)`
`protected void` | `postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)`
`protected void` | `prepareRefresh()`
`void` | `setBundleContext(org.osgi.framework.BundleContext bundleContext)` Sets the `BundleContext` used by this OSGi bundle application context.
`void` | `setClassLoader(ClassLoader classLoader)`
`void` | `setConfigLocations(String[] configLocations)` Sets the config locations for this OSGi bundle application context.
`void` | `setPublishContextAsService(boolean publishContextAsService)` Indicates whether this application context should be publish as an OSGi service if successfully started.

Methods inherited from class org.springframework.context.support.AbstractRefreshableApplicationContext
`cancelRefresh, closeBeanFactory, createBeanFactory, customizeBeanFactory, getBeanFactory, hasBeanFactory, loadBeanDefinitions, refreshBeanFactory, setAllowBeanDefinitionOverriding, setAllowCircularReferences`

Methods inherited from class org.springframework.context.support.AbstractApplicationContext
`addApplicationListener, addBeanFactoryPostProcessor, addListener, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroy, findAnnotationOnBean, finishBeanFactoryInitialization, getAliases, getApplicationListeners, getAutowireCapableBeanFactory, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getStartupDate, getType, initApplicationEventMulticaster, initLifecycleProcessor, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isPrototype, isRunning, isSingleton, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, prepareBeanFactory, publishEvent, refresh, registerBeanPostProcessors, registerListeners, registerShutdownHook, setDisplayName, setEnvironment, setId, setParent, start, stop, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.springframework.context.ConfigurableApplicationContext
`addApplicationListener, addBeanFactoryPostProcessor, close, getBeanFactory, getEnvironment, isActive, refresh, registerShutdownHook, setEnvironment, setId, setParent`

Methods inherited from interface org.springframework.context.ApplicationContext
`getAutowireCapableBeanFactory, getDisplayName, getId, getParent, getStartupDate`

Methods inherited from interface org.springframework.beans.factory.ListableBeanFactory
`containsBeanDefinition, findAnnotationOnBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanNamesForType, getBeanNamesForType, getBeansOfType, getBeansOfType, getBeansWithAnnotation`

Methods inherited from interface org.springframework.beans.factory.HierarchicalBeanFactory
`containsLocalBean, getParentBeanFactory`

Methods inherited from interface org.springframework.beans.factory.BeanFactory
`containsBean, getAliases, getBean, getBean, getBean, getBean, getType, isPrototype, isSingleton, isTypeMatch`

Methods inherited from interface org.springframework.context.MessageSource
`getMessage, getMessage, getMessage`

Methods inherited from interface org.springframework.context.ApplicationEventPublisher
`publishEvent`

Methods inherited from interface org.springframework.context.Lifecycle
`isRunning, start, stop`

Constructor Detail

### AbstractOsgiBundleApplicationContext

    public AbstractOsgiBundleApplicationContext()

  Creates a new `AbstractOsgiBundleApplicationContext` with no parent.

### AbstractOsgiBundleApplicationContext

    public AbstractOsgiBundleApplicationContext(org.springframework.context.ApplicationContext parent)

  Creates a new `AbstractOsgiBundleApplicationContext` with the given parent context.

  Parameters:
    `parent` - the parent context

Method Detail

### setBundleContext

    public void setBundleContext(org.osgi.framework.BundleContext bundleContext)

  Sets the `BundleContext` used by this OSGi bundle application context. Normally it's the `BundleContext` in which the context runs.

  Does not cause an initialization of the context: `ConfigurableApplicationContext.refresh()` needs to be called after the setting of all configuration properties.

  Will automatically determine the bundle, create a new `ResourceLoader` (and set its `ClassLoader` (if none is set already) to a custom implementation that will delegate the calls to the bundle).

  Specified by:
    `setBundleContext` in interface `ConfigurableOsgiBundleApplicationContext`
  Parameters:
    `bundleContext` - the `BundleContext` used by this application context.
  See Also:
    `ConfigurableApplicationContext.refresh()`

### getBundleContext

    public org.osgi.framework.BundleContext getBundleContext()

  Description copied from interface: `ConfigurableOsgiBundleApplicationContext`
  Return the `BundleContext` for this application context. This method is offered as a helper since as of OSGi 4.1, the bundle context can be discovered directly from the given bundle.

  Specified by:
    `getBundleContext` in interface `ConfigurableOsgiBundleApplicationContext`
  Returns:
    the `BundleContext` in which this application context runs
  See Also:
    `ConfigurableOsgiBundleApplicationContext.getBundle()`

### getBundle

    public org.osgi.framework.Bundle getBundle()

  Description copied from interface: `ConfigurableOsgiBundleApplicationContext`
  Returns the OSGi `Bundle` for this application context.

  Specified by:
    `getBundle` in interface `ConfigurableOsgiBundleApplicationContext`
  Returns:
    the `Bundle` for this OSGi bundle application context.

### setConfigLocations

    public void setConfigLocations(String[] configLocations)

  Description copied from interface: `ConfigurableOsgiBundleApplicationContext`
  Sets the config locations for this OSGi bundle application context. If not set, the implementation is supposed to use a default for the given bundle.

  Specified by:
    `setConfigLocations` in interface `ConfigurableOsgiBundleApplicationContext`
  Parameters:
    `configLocations` - array of configuration locations

### getConfigLocations

    public String[] getConfigLocations()

  Returns this application context configuration locations. The default implementation will check whether there are any locations configured and, if not, will return the default locations.

  Returns:
    application context configuration locations.
  See Also:
    `getDefaultConfigLocations()`

### doClose

    protected void doClose()

  Unregister the ApplicationContext OSGi service (in case there is any).

  Overrides:
    `doClose` in class `org.springframework.context.support.AbstractApplicationContext`

### destroyBeans

    protected void destroyBeans()

  Overrides:
    `destroyBeans` in class `org.springframework.context.support.AbstractApplicationContext`

### getDefaultConfigLocations

    protected String[] getDefaultConfigLocations()

  Returns the default configuration locations to use, for the case where no explicit configuration locations have been specified.

  Default implementation returns `null`, requiring explicit configuration locations.

  Returns:
    application context default configuration locations
  See Also:
    `setConfigLocations(java.lang.String[])`

### prepareRefresh

    protected void prepareRefresh()

  Overrides:
    `prepareRefresh` in class `org.springframework.context.support.AbstractApplicationContext`

### finishRefresh

    protected void finishRefresh()

  Overrides:
    `finishRefresh` in class `org.springframework.context.support.AbstractApplicationContext`

### postProcessBeanFactory

    protected void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
                                   throws org.springframework.beans.BeansException

  Overrides:
    `postProcessBeanFactory` in class `org.springframework.context.support.AbstractApplicationContext`
  Throws:
    `org.springframework.beans.BeansException`

### customizeApplicationContextServiceProperties

    protected void customizeApplicationContextServiceProperties(Map<Object,Object> serviceProperties)

  Customizes the properties of the application context OSGi service. This method is called only if the application context will be published as an OSGi service.

  The default implementation stores the bundle symbolic name under `Constants.BUNDLE_SYMBOLICNAME` and `ConfigurableOsgiBundleApplicationContext.APPLICATION_CONTEXT_SERVICE_PROPERTY_NAME` and the bundle version under `Constants.BUNDLE_VERSION` property. Can be overridden by subclasses to add more properties if needed (for example for web applications where multiple application contexts are available inside the same bundle).

  Parameters:
    `serviceProperties` - service properties map (can be casted to `Dictionary`)

### createResourcePatternResolver

    protected org.springframework.core.io.support.ResourcePatternResolver createResourcePatternResolver()

  Creates an OSGi specific resource pattern resolver.

  Returns:
    returns an OSGi specific pattern resolver.

### getResourcePatternResolver

    protected org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()

  This implementation supports pattern matching inside the OSGi bundle.

  Overrides:
    `getResourcePatternResolver` in class `org.springframework.context.support.AbstractApplicationContext`
  See Also:
    `OsgiBundleResourcePatternResolver`

### getClassLoader

    public ClassLoader getClassLoader()

  Specified by:
    `getClassLoader` in interface `org.springframework.core.io.ResourceLoader`
  Overrides:
    `getClassLoader` in class `org.springframework.core.io.DefaultResourceLoader`

### getResource

    public org.springframework.core.io.Resource getResource(String location)

  Specified by:
    `getResource` in interface `org.springframework.core.io.ResourceLoader`
  Overrides:
    `getResource` in class `org.springframework.core.io.DefaultResourceLoader`

### getResources

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

  Specified by:
    `getResources` in interface `org.springframework.core.io.support.ResourcePatternResolver`
  Overrides:
    `getResources` in class `org.springframework.context.support.AbstractApplicationContext`
  Throws:
    `IOException`

### setClassLoader

    public void setClassLoader(ClassLoader classLoader)

  Overrides:
    `setClassLoader` in class `org.springframework.core.io.DefaultResourceLoader`

### getResourceByPath

    protected org.springframework.core.io.Resource getResourceByPath(String path)

  Overrides:
    `getResourceByPath` in class `org.springframework.core.io.DefaultResourceLoader`

### setPublishContextAsService

    public void setPublishContextAsService(boolean publishContextAsService)

  Description copied from interface: `ConfigurableOsgiBundleApplicationContext`
  Indicates whether this application context should be publish as an OSGi service if successfully started. By default, this is set to `true`.

  Specified by:
    `setPublishContextAsService` in interface `ConfigurableOsgiBundleApplicationContext`
  Parameters:
    `publishContextAsService` - true if the application context should be published as a service, false otherwise

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2012. All Rights Reserved.