|
||||||||||
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(Bundle b)
Constructor used by BundleMock, it ensures the bundle and its context are wired together correctly. |
Method Summary | |
---|---|
void |
addBundle(Bundle b)
|
void |
addServiceListener(ServiceListener listener)
Add a service listener. |
void |
addServiceListener(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. |
ServiceReference[] |
getAllServiceReferences(String className,
String filter)
This method finds all the service references in the registry with the matching class name and filter. |
Bundle |
getBundle()
|
Bundle[] |
getBundles()
|
String |
getProperty(String name)
|
Object |
getService(ServiceReference ref)
Retrieve a service from the registry. |
static Object |
getService(String interfaceName,
Bundle bundle)
This helper method is used to get the service from the registry with the given interface name. |
static List<ServiceListener> |
getServiceListeners()
|
ServiceReference |
getServiceReference(String className)
Gets the first matching service reference. |
ServiceReference[] |
getServiceReferences(String className,
String filter)
A mock implementation of the getServiceReferences method. |
Bundle |
installBundle(String location)
Asks to install an OSGi bundle from the given location. |
Bundle |
installBundle(String location,
InputStream is)
This method implements the installBundle method from BundleContext. |
ServiceRegistration |
registerService(String[] interfaces,
Object service,
Dictionary<String,Object> properties)
This implements the registerService method from BundleContext. |
ServiceRegistration |
registerService(String interFace,
Object service,
Dictionary<String,Object> properties)
This implements the registerService method from BundleContext. |
void |
removeServiceListener(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(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 ServiceRegistration registerService(String interFace, Object service, Dictionary<String,Object> properties)
interFace
- service
- properties
-
public ServiceRegistration registerService(String[] interfaces, Object service, Dictionary<String,Object> properties)
interfaces
- service
- properties
-
public static Object getService(String interfaceName, Bundle bundle)
This should really return multiple services.
interfaceName
- the interface name.bundle
- the bundle name.
public ServiceReference[] getServiceReferences(String className, String filter) throws 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
-
InvalidSyntaxException
public ServiceReference getServiceReference(String className)
className
- the class name wanted.
public ServiceReference[] getAllServiceReferences(String className, String filter) throws InvalidSyntaxException
className
- filter
-
InvalidSyntaxException
public Object getService(ServiceReference ref)
ref
- the service reference.
public Bundle installBundle(String location, InputStream is) throws BundleException
location
- the location of the bundle.is
- the input stream to read from.
BundleException
public Bundle installBundle(String location) throws BundleException
location
- the location of the bundle on the file system.
BundleException
public Bundle[] getBundles()
public void addServiceListener(ServiceListener listener, String filter)
listener
- filter
- public void addServiceListener(ServiceListener listener)
listener
- public void removeServiceListener(ServiceListener listener)
listener
- public String getProperty(String name)
public Bundle getBundle()
public static void clear()
public static List<ServiceListener> getServiceListeners()
public void addBundle(Bundle b)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |