|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.aries.mocks.BundleContextMock
public class BundleContextMock
This class is a partial implementation of BundleContext. Its main function is to provide a service registry implementation
| Constructor Summary | |
|---|---|
BundleContextMock()
Default constructor, widely used in the tests. |
|
BundleContextMock(org.osgi.framework.Bundle b)
Constructor used by BundleMock, it ensures the bundle and its context are wired together correctly. |
|
| Method Summary | |
|---|---|
void |
addBundle(org.osgi.framework.Bundle b)
|
void |
addServiceListener(org.osgi.framework.ServiceListener listener)
Add a service listener. |
void |
addServiceListener(org.osgi.framework.ServiceListener listener,
String filter)
Add a service listener. |
static void |
assertNoServiceExists(String interfaceName)
This checks that we have at no services with this interface name. |
static void |
assertServiceExists(String interfaceName)
This checks that we have at least one service with this interface name. |
static void |
clear()
This method clears the service registry. |
org.osgi.framework.ServiceReference[] |
getAllServiceReferences(String className,
String filter)
This method finds all the service references in the registry with the matching class name and filter. |
org.osgi.framework.Bundle |
getBundle()
|
org.osgi.framework.Bundle[] |
getBundles()
|
String |
getProperty(String name)
|
Object |
getService(org.osgi.framework.ServiceReference ref)
Retrieve a service from the registry. |
static Object |
getService(String interfaceName,
org.osgi.framework.Bundle bundle)
This helper method is used to get the service from the registry with the given interface name. |
static List<org.osgi.framework.ServiceListener> |
getServiceListeners()
|
org.osgi.framework.ServiceReference |
getServiceReference(String className)
Gets the first matching service reference. |
org.osgi.framework.ServiceReference[] |
getServiceReferences(String className,
String filter)
A mock implementation of the getServiceReferences method. |
org.osgi.framework.Bundle |
installBundle(String location)
Asks to install an OSGi bundle from the given location. |
org.osgi.framework.Bundle |
installBundle(String location,
InputStream is)
This method implements the installBundle method from BundleContext. |
org.osgi.framework.ServiceRegistration |
registerService(String[] interfaces,
Object service,
Dictionary<String,Object> properties)
This implements the registerService method from BundleContext. |
org.osgi.framework.ServiceRegistration |
registerService(String interFace,
Object service,
Dictionary<String,Object> properties)
This implements the registerService method from BundleContext. |
void |
removeServiceListener(org.osgi.framework.ServiceListener listener)
Remove a service listener |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public BundleContextMock()
public BundleContextMock(org.osgi.framework.Bundle b)
b - | Method Detail |
|---|
public static void assertServiceExists(String interfaceName)
interfaceName - the name of the interface.public static void assertNoServiceExists(String interfaceName)
interfaceName - the name of the interface.
public org.osgi.framework.ServiceRegistration registerService(String interFace,
Object service,
Dictionary<String,Object> properties)
interFace - service - properties -
public org.osgi.framework.ServiceRegistration registerService(String[] interfaces,
Object service,
Dictionary<String,Object> properties)
interfaces - service - properties -
public static Object getService(String interfaceName,
org.osgi.framework.Bundle bundle)
This should really return multiple services.
interfaceName - the interface name.bundle - the bundle name.
public org.osgi.framework.ServiceReference[] getServiceReferences(String className,
String filter)
throws org.osgi.framework.InvalidSyntaxException
Note this does not check that the service classes are visible to the caller as OSGi does. It is equivalent to getAllServiceReferences.
className - the name of the class the lookup is for.filter -
org.osgi.framework.InvalidSyntaxExceptionpublic org.osgi.framework.ServiceReference getServiceReference(String className)
className - the class name wanted.
public org.osgi.framework.ServiceReference[] getAllServiceReferences(String className,
String filter)
throws org.osgi.framework.InvalidSyntaxException
className - filter -
org.osgi.framework.InvalidSyntaxExceptionpublic Object getService(org.osgi.framework.ServiceReference ref)
ref - the service reference.
public org.osgi.framework.Bundle installBundle(String location,
InputStream is)
throws org.osgi.framework.BundleException
location - the location of the bundle.is - the input stream to read from.
org.osgi.framework.BundleException
public org.osgi.framework.Bundle installBundle(String location)
throws org.osgi.framework.BundleException
location - the location of the bundle on the file system.
org.osgi.framework.BundleExceptionpublic org.osgi.framework.Bundle[] getBundles()
public void addServiceListener(org.osgi.framework.ServiceListener listener,
String filter)
listener - filter - public void addServiceListener(org.osgi.framework.ServiceListener listener)
listener - public void removeServiceListener(org.osgi.framework.ServiceListener listener)
listener - public String getProperty(String name)
public org.osgi.framework.Bundle getBundle()
public static void clear()
public static List<org.osgi.framework.ServiceListener> getServiceListeners()
public void addBundle(org.osgi.framework.Bundle b)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||