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.mock
Class MockBundleContext

    java.lang.Object
      org.eclipse.gemini.blueprint.mock.MockBundleContext

All Implemented Interfaces:
  BundleContext

    public class MockBundleContext

extends Object
implements BundleContext

BundleContext mock.

Can be configured to use a predefined Bundle or/and configuration. By default, will create an internal MockBundle. Most of the operations are no-op (as anonymous classes with specific functionality can be created per use basis).

Author:
  Costin Leau

Field Summary
`protected Set` | `bundleListeners`
`static Properties` | `DEFAULT_PROPERTIES`
`protected Set` | `serviceListeners`

Constructor Summary
`MockBundleContext()` Constructs a new `MockBundleContext` instance.
`MockBundleContext(Bundle bundle)` Constructs a new `MockBundleContext` instance.
`MockBundleContext(Bundle bundle, Properties props)` Constructs a new `MockBundleContext` instance allowing both the bundle and the context properties to be specified.

Method Summary
`void` | `addBundleListener(BundleListener listener)`
`void` | `addFrameworkListener(FrameworkListener listener)`
`void` | `addServiceListener(ServiceListener listener)`
`void` | `addServiceListener(ServiceListener listener, String filter)`
`Filter` | `createFilter(String filter)`
`ServiceReference[]` | `getAllServiceReferences(String clazz, String filter)`
`Bundle` | `getBundle()`
`Bundle` | `getBundle(long id)`
`Set` | `getBundleListeners()` Returns a set of registered bundle listeners.
`Bundle[]` | `getBundles()`
`File` | `getDataFile(String filename)`
`String` | `getProperty(String key)`
`Object` | `getService(ServiceReference reference)`
`Set` | `getServiceListeners()` Returns a set of registered service listeners.
`ServiceReference` | `getServiceReference(String clazz)`
`ServiceReference[]` | `getServiceReferences(String clazz, String filter)`
`Bundle` | `installBundle(String location)`
`Bundle` | `installBundle(String location, InputStream input)`
`ServiceRegistration` | `registerService(String[] clazzes, Object service, Dictionary properties)`
`ServiceRegistration` | `registerService(String clazz, Object service, Dictionary properties)`
`void` | `removeBundleListener(BundleListener listener)`
`void` | `removeFrameworkListener(FrameworkListener listener)`
`void` | `removeServiceListener(ServiceListener listener)`
`void` | `setBundle(Bundle bundle)` Sets the bundle associated with this context.
`boolean` | `ungetService(ServiceReference reference)`

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

Field Detail

### DEFAULT_PROPERTIES

    public static final Properties DEFAULT_PROPERTIES

### serviceListeners

    protected Set serviceListeners

### bundleListeners

    protected Set bundleListeners

Constructor Detail

### MockBundleContext

    public MockBundleContext()

  Constructs a new `MockBundleContext` instance. The associated bundle will be created automatically.

### MockBundleContext

    public MockBundleContext(Bundle bundle)

  Constructs a new `MockBundleContext` instance.

  Parameters:
    `bundle` - associated bundle

### MockBundleContext

    public MockBundleContext(Bundle bundle,
                             Properties props)

  Constructs a new `MockBundleContext` instance allowing both the bundle and the context properties to be specified.

  Parameters:
    `bundle` - associated bundle
    `props` - context properties

Method Detail

### addBundleListener

    public void addBundleListener(BundleListener listener)

  Specified by:
    `addBundleListener` in interface `BundleContext`

### addFrameworkListener

    public void addFrameworkListener(FrameworkListener listener)

  Specified by:
    `addFrameworkListener` in interface `BundleContext`

### addServiceListener

    public void addServiceListener(ServiceListener listener)

  Specified by:
    `addServiceListener` in interface `BundleContext`

### addServiceListener

    public void addServiceListener(ServiceListener listener,
                                   String filter)
                            throws InvalidSyntaxException

  Specified by:
    `addServiceListener` in interface `BundleContext`
  Throws:
    `InvalidSyntaxException`

### createFilter

    public Filter createFilter(String filter)
                        throws InvalidSyntaxException

  Specified by:
    `createFilter` in interface `BundleContext`
  Throws:
    `InvalidSyntaxException`

### getAllServiceReferences

    public ServiceReference[] getAllServiceReferences(String clazz,
                                                      String filter)
                                               throws InvalidSyntaxException

  Specified by:
    `getAllServiceReferences` in interface `BundleContext`
  Throws:
    `InvalidSyntaxException`

### getBundle

    public Bundle getBundle()

  Specified by:
    `getBundle` in interface `BundleContext`

### getBundle

    public Bundle getBundle(long id)

  Specified by:
    `getBundle` in interface `BundleContext`

### getBundles

    public Bundle[] getBundles()

  Specified by:
    `getBundles` in interface `BundleContext`

### getDataFile

    public File getDataFile(String filename)

  Specified by:
    `getDataFile` in interface `BundleContext`

### getProperty

    public String getProperty(String key)

  Specified by:
    `getProperty` in interface `BundleContext`

### getService

    public Object getService(ServiceReference reference)

  Specified by:
    `getService` in interface `BundleContext`

### getServiceReference

    public ServiceReference getServiceReference(String clazz)

  Specified by:
    `getServiceReference` in interface `BundleContext`

### getServiceReferences

    public ServiceReference[] getServiceReferences(String clazz,
                                                   String filter)
                                            throws InvalidSyntaxException

  Specified by:
    `getServiceReferences` in interface `BundleContext`
  Throws:
    `InvalidSyntaxException`

### installBundle

    public Bundle installBundle(String location)
                         throws BundleException

  Specified by:
    `installBundle` in interface `BundleContext`
  Throws:
    `BundleException`

### installBundle

    public Bundle installBundle(String location,
                                InputStream input)
                         throws BundleException

  Specified by:
    `installBundle` in interface `BundleContext`
  Throws:
    `BundleException`

### registerService

    public ServiceRegistration registerService(String[] clazzes,
                                               Object service,
                                               Dictionary properties)

  Specified by:
    `registerService` in interface `BundleContext`

### registerService

    public ServiceRegistration registerService(String clazz,
                                               Object service,
                                               Dictionary properties)

  Specified by:
    `registerService` in interface `BundleContext`

### removeBundleListener

    public void removeBundleListener(BundleListener listener)

  Specified by:
    `removeBundleListener` in interface `BundleContext`

### removeFrameworkListener

    public void removeFrameworkListener(FrameworkListener listener)

  Specified by:
    `removeFrameworkListener` in interface `BundleContext`

### removeServiceListener

    public void removeServiceListener(ServiceListener listener)

  Specified by:
    `removeServiceListener` in interface `BundleContext`

### ungetService

    public boolean ungetService(ServiceReference reference)

  Specified by:
    `ungetService` in interface `BundleContext`

### setBundle

    public void setBundle(Bundle bundle)

  Sets the bundle associated with this context.

  Parameters:
    `bundle` - associated bundle

### getServiceListeners

    public Set getServiceListeners()

  Returns a set of registered service listeners. Handy method when mocking with listeners is required.

  Returns:
    set of registered service listeners

### getBundleListeners

    public Set getBundleListeners()

  Returns a set of registered bundle listeners.

  Returns:
    set of registered bundle listeners

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-2010 Spring Framework. All Rights Reserved.