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.extender.support
Class ConditionalApplicationContextCreator

    java.lang.Object
      org.eclipse.gemini.blueprint.extender.support.ConditionalApplicationContextCreator

All Implemented Interfaces:
  OsgiApplicationContextCreator, org.springframework.beans.factory.InitializingBean

    public class ConditionalApplicationContextCreator

extends Object
implements OsgiApplicationContextCreator, org.springframework.beans.factory.InitializingBean

Useful `OsgiApplicationContextCreator` implementation that dictates whether the default application context used by the Spring-DM extender should be created (or not) based on a `boolean` value. This allows clients to handle only the bundleContext filtering while being decoupled from the context creation process:

     ConditionalApplicationContextCreator creator = new ConditionalApplicationContextCreator();

     creator.setFilter(new ConditionalApplicationContextCreator.BundleContextFilter() {
            // filter bundles with no copyright
            public boolean matches(BundleContext bundleContext) {
                    return bundleContext.getBundle().getHeaders().get(Constants.BUNDLE_COPYRIGHT) != null)
            }
     }

     creator.createApplicationContext(bundleContext);

Author:
  Costin Leau
See Also:
  `OsgiApplicationContextCreator`

Nested Class Summary
`static interface` | `ConditionalApplicationContextCreator.BundleContextFilter` Callback used to filter the bundle contexts for which the default application contexts are created.

Constructor Summary
`ConditionalApplicationContextCreator()`

Method Summary
`void` | `afterPropertiesSet()`
`DelegatedExecutionOsgiBundleApplicationContext` | `createApplicationContext(org.osgi.framework.BundleContext bundleContext)` Creates an application context for the given bundle context.
`void` | `setDelegatedApplicationContextCreator(OsgiApplicationContextCreator delegatedContextCreator)` Sets the `OsgiApplicationContextCreator` used by this context creator for the actual creation.
`void` | `setFilter(ConditionalApplicationContextCreator.BundleContextFilter filter)` Sets the `ConditionalApplicationContextCreator.BundleContextFilter` used by this context creator.

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

Constructor Detail

### ConditionalApplicationContextCreator

    public ConditionalApplicationContextCreator()

Method Detail

### afterPropertiesSet

    public void afterPropertiesSet()
                            throws Exception

  Specified by:
    `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`
  Throws:
    `Exception`

### createApplicationContext

    public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(org.osgi.framework.BundleContext bundleContext)
                                                                            throws Exception

  Description copied from interface: `OsgiApplicationContextCreator`
  Creates an application context for the given bundle context. If no application context needs to be created, then `null` should be returned. Exceptions will be caught and logged but will not prevent the creation of other application contexts.

  Specified by:
    `createApplicationContext` in interface `OsgiApplicationContextCreator`
  Parameters:
    `bundleContext` - OSGi bundle context determining the context creation
  Returns:
    `null` if no context should be created, non- `null` otherwise
  Throws:
    `Exception` - if something goes wrong

### setFilter

    public void setFilter(ConditionalApplicationContextCreator.BundleContextFilter filter)

  Sets the `ConditionalApplicationContextCreator.BundleContextFilter` used by this context creator.

  Parameters:
    `filter` - The bundle context filter to set.

### setDelegatedApplicationContextCreator

    public void setDelegatedApplicationContextCreator(OsgiApplicationContextCreator delegatedContextCreator)

  Sets the `OsgiApplicationContextCreator` used by this context creator for the actual creation. If none is specified, `DefaultOsgiApplicationContextCreator` is used.

  Parameters:
    `delegatedContextCreator` - the instance used for creating the application context

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-2013. All Rights Reserved.