org.eclipse.gemini.blueprint.extender.internal.activator
Class ContextLoaderListener

java.lang.Object
  extended by org.eclipse.gemini.blueprint.extender.internal.activator.ContextLoaderListener
All Implemented Interfaces:
org.osgi.framework.BundleActivator
Direct Known Subclasses:
BlueprintLoaderListener

public class ContextLoaderListener
extends Object
implements org.osgi.framework.BundleActivator

Osgi Extender that bootstraps 'Spring powered bundles'.

The class listens to bundle events and manages the creation and destruction of application contexts for bundles that have one or both of:

The extender also discovers any Spring namespace/schema handlers in resolved bundles and makes them available through a dedicated OSGi service.

The extender behaviour can be customized by attaching fragments to the extender bundle. On startup, the extender will look for META-INF/spring/*.xml files and merge them into an application context. From the resulting context, the context will look for beans with predefined names to determine its configuration. The current version recognises the following bean names:

Bean Name Bean Type Description
taskExecutor org.springframework.core.task.TaskExecutor Task executor used for creating the discovered application contexts.
shutdownTaskExecutor org.springframework.core.task.TaskExecutor Task executor used for shutting down various application contexts.
extenderProperties java.util.Properties Various properties for configuring the extender behaviour (see below)

extenderProperties recognises the following properties:

Name Type Description
shutdown.wait.time Number The amount of time the extender will wait for each application context to shutdown gracefully. Expressed in milliseconds.
process.annotations Boolean Whether or not, the extender will process SpringOSGi annotations.

Note: The extender configuration context is created during the bundle activation (a synchronous OSGi lifecycle callback) and should contain only simple bean definitions that will not delay context initialisation.

Author:
Bill Gallagher, Andy Piper, Hal Hildebrand, Adrian Colyer, Costin Leau

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
ContextLoaderListener()
           
 
Method Summary
protected  void addApplicationListener(OsgiBundleApplicationContextEventMulticaster multicaster)
           
protected  ApplicationContextConfigurationFactory createContextConfigFactory()
           
protected  OsgiContextProcessor createContextProcessor()
           
protected  String getManagedBundleExtenderVersionHeader()
           
protected  TypeCompatibilityChecker getTypeCompatibilityChecker()
           
protected  ExtenderConfiguration initExtenderConfiguration(org.osgi.framework.BundleContext bundleContext)
           
protected  void initListenerService()
           
protected  void initNamespaceHandlers(org.osgi.framework.BundleContext context)
           
protected  void initStartedBundles(org.osgi.framework.BundleContext bundleContext)
           
protected  void maybeAddNamespaceHandlerFor(org.osgi.framework.Bundle bundle, boolean isLazy)
           
protected  void maybeRemoveNameSpaceHandlerFor(org.osgi.framework.Bundle bundle)
           
protected  void shutdown()
          Shutdown the extender and all bundled managed by it.
 void start(org.osgi.framework.BundleContext context)
          

Called by OSGi when this bundle is started.

 void stop(org.osgi.framework.BundleContext context)
          Called by OSGi when this bundled is stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

ContextLoaderListener

public ContextLoaderListener()
Method Detail

start

public void start(org.osgi.framework.BundleContext context)
           throws Exception

Called by OSGi when this bundle is started. Finds all previously resolved bundles and adds namespace handlers for them if necessary.

Creates application contexts for bundles started before the extender was started.

Registers a namespace/entity resolving service for use by web app contexts.

Specified by:
start in interface org.osgi.framework.BundleActivator
Throws:
Exception
See Also:
BundleActivator.start(org.osgi.framework.BundleContext)

initExtenderConfiguration

protected ExtenderConfiguration initExtenderConfiguration(org.osgi.framework.BundleContext bundleContext)

createContextProcessor

protected OsgiContextProcessor createContextProcessor()

getTypeCompatibilityChecker

protected TypeCompatibilityChecker getTypeCompatibilityChecker()

getManagedBundleExtenderVersionHeader

protected String getManagedBundleExtenderVersionHeader()

initNamespaceHandlers

protected void initNamespaceHandlers(org.osgi.framework.BundleContext context)

initStartedBundles

protected void initStartedBundles(org.osgi.framework.BundleContext bundleContext)

stop

public void stop(org.osgi.framework.BundleContext context)
          throws Exception
Called by OSGi when this bundled is stopped. Unregister the namespace/entity resolving service and clear all state. No further management of application contexts created by this extender prior to stopping the bundle occurs after this point (even if the extender bundle is subsequently restarted).

Specified by:
stop in interface org.osgi.framework.BundleActivator
Throws:
Exception
See Also:
BundleActivator.stop(org.osgi.framework.BundleContext)

shutdown

protected void shutdown()
Shutdown the extender and all bundled managed by it. Shutdown of contexts is in the topological order of the dependency graph formed by the service references.


maybeAddNamespaceHandlerFor

protected void maybeAddNamespaceHandlerFor(org.osgi.framework.Bundle bundle,
                                           boolean isLazy)

maybeRemoveNameSpaceHandlerFor

protected void maybeRemoveNameSpaceHandlerFor(org.osgi.framework.Bundle bundle)

createContextConfigFactory

protected ApplicationContextConfigurationFactory createContextConfigFactory()

initListenerService

protected void initListenerService()

addApplicationListener

protected void addApplicationListener(OsgiBundleApplicationContextEventMulticaster multicaster)


Copyright © 2006-2012. All Rights Reserved.