public class MockBundle
extends java.lang.Object
implements org.osgi.framework.Bundle
| Modifier and Type | Class and Description |
|---|---|
private static class |
MockBundle.EmptyEnumeration |
| Modifier and Type | Field and Description |
|---|---|
private org.osgi.framework.BundleContext |
bundleContext |
private long |
bundleId |
private java.util.Dictionary |
defaultHeaders |
private static int |
GENERAL_BUNDLE_ID |
private java.util.Dictionary |
headers |
private java.lang.ClassLoader |
loader |
private java.lang.String |
location |
private java.lang.String |
SYMBOLIC_NAME |
private java.lang.String |
symName |
private org.osgi.framework.Version |
version |
| Constructor and Description |
|---|
MockBundle()
Constructs a new
MockBundle instance using default values. |
MockBundle(org.osgi.framework.BundleContext context)
Constructs a new
MockBundle instance associated with the given bundle context. |
MockBundle(java.util.Dictionary headers)
Constructs a new
MockBundle instance with the given bundle headers. |
MockBundle(java.lang.String symName)
Constructs a new
MockBundle instance with the given symbolic name. |
MockBundle(java.lang.String symName,
java.util.Dictionary headers,
org.osgi.framework.BundleContext context)
Constructs a new
MockBundle instance using the given bundle symbolic name, properties and associated
bundle context. |
| Modifier and Type | Method and Description |
|---|---|
java.util.Enumeration |
findEntries(java.lang.String path,
java.lang.String filePattern,
boolean recurse)
Delegates to the classloader.
|
org.osgi.framework.BundleContext |
getBundleContext() |
long |
getBundleId() |
org.osgi.framework.BundleContext |
getContext() |
java.net.URL |
getEntry(java.lang.String name) |
java.util.Enumeration |
getEntryPaths(java.lang.String path) |
java.util.Dictionary |
getHeaders() |
java.util.Dictionary |
getHeaders(java.lang.String locale) |
long |
getLastModified() |
java.lang.String |
getLocation() |
org.osgi.framework.ServiceReference[] |
getRegisteredServices() |
java.net.URL |
getResource(java.lang.String name) |
java.util.Enumeration |
getResources(java.lang.String name) |
org.osgi.framework.ServiceReference[] |
getServicesInUse() |
java.util.Map |
getSignerCertificates(int signerType) |
int |
getState() |
java.lang.String |
getSymbolicName() |
org.osgi.framework.Version |
getVersion() |
private static org.osgi.framework.Version |
getVersion(java.util.Dictionary headers) |
boolean |
hasPermission(java.lang.Object permission) |
java.lang.Class<?> |
loadClass(java.lang.String name) |
void |
setBundleId(long bundleId) |
void |
setClassLoader(java.lang.ClassLoader loader)
Sets the class loader internally used by the bundle to mock the loading operations.
|
void |
setLocation(java.lang.String location)
Sets the location for this mock bundle.
|
void |
start() |
void |
start(int options) |
void |
stop() |
void |
stop(int options) |
java.lang.String |
toString() |
void |
uninstall() |
void |
update() |
void |
update(java.io.InputStream in) |
private java.lang.String location
private final java.util.Dictionary headers
private static int GENERAL_BUNDLE_ID
private long bundleId
private org.osgi.framework.BundleContext bundleContext
private java.lang.ClassLoader loader
private final java.util.Dictionary defaultHeaders
private final java.lang.String SYMBOLIC_NAME
private final java.lang.String symName
private final org.osgi.framework.Version version
public MockBundle()
MockBundle instance using default values.public MockBundle(java.util.Dictionary headers)
MockBundle instance with the given bundle headers.headers - bundle headerspublic MockBundle(org.osgi.framework.BundleContext context)
MockBundle instance associated with the given bundle context.context - associated bundle contextpublic MockBundle(java.lang.String symName)
MockBundle instance with the given symbolic name.symName - bundle symbolic namepublic MockBundle(java.lang.String symName,
java.util.Dictionary headers,
org.osgi.framework.BundleContext context)
MockBundle instance using the given bundle symbolic name, properties and associated
bundle context.symName - bundle symbolic nameheaders - bundle headerscontext - associated bundle contextpublic java.util.Enumeration findEntries(java.lang.String path,
java.lang.String filePattern,
boolean recurse)
findEntries in interface org.osgi.framework.BundleBundle.findEntries(java.lang.String, java.lang.String, boolean)public long getBundleId()
getBundleId in interface org.osgi.framework.Bundlepublic void setBundleId(long bundleId)
public java.net.URL getEntry(java.lang.String name)
getEntry in interface org.osgi.framework.Bundlepublic java.util.Enumeration getEntryPaths(java.lang.String path)
getEntryPaths in interface org.osgi.framework.Bundlepublic java.util.Dictionary getHeaders()
getHeaders in interface org.osgi.framework.Bundlepublic java.util.Dictionary getHeaders(java.lang.String locale)
getHeaders in interface org.osgi.framework.Bundlepublic long getLastModified()
getLastModified in interface org.osgi.framework.Bundlepublic java.lang.String getLocation()
getLocation in interface org.osgi.framework.Bundlepublic org.osgi.framework.ServiceReference[] getRegisteredServices()
getRegisteredServices in interface org.osgi.framework.Bundlepublic java.net.URL getResource(java.lang.String name)
getResource in interface org.osgi.framework.Bundlepublic java.util.Enumeration getResources(java.lang.String name)
throws java.io.IOException
getResources in interface org.osgi.framework.Bundlejava.io.IOExceptionpublic org.osgi.framework.ServiceReference[] getServicesInUse()
getServicesInUse in interface org.osgi.framework.Bundlepublic int getState()
getState in interface org.osgi.framework.Bundlepublic java.lang.String getSymbolicName()
getSymbolicName in interface org.osgi.framework.Bundlepublic boolean hasPermission(java.lang.Object permission)
hasPermission in interface org.osgi.framework.Bundlepublic java.lang.Class<?> loadClass(java.lang.String name)
throws java.lang.ClassNotFoundException
loadClass in interface org.osgi.framework.Bundlejava.lang.ClassNotFoundExceptionpublic void start()
throws org.osgi.framework.BundleException
start in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void start(int options)
throws org.osgi.framework.BundleException
start in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void stop()
throws org.osgi.framework.BundleException
stop in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void stop(int options)
throws org.osgi.framework.BundleException
stop in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void uninstall()
throws org.osgi.framework.BundleException
uninstall in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void update()
throws org.osgi.framework.BundleException
update in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic void update(java.io.InputStream in)
throws org.osgi.framework.BundleException
update in interface org.osgi.framework.Bundleorg.osgi.framework.BundleExceptionpublic org.osgi.framework.Version getVersion()
getVersion in interface org.osgi.framework.Bundleprivate static org.osgi.framework.Version getVersion(java.util.Dictionary headers)
public java.util.Map getSignerCertificates(int signerType)
getSignerCertificates in interface org.osgi.framework.Bundlepublic org.osgi.framework.BundleContext getContext()
public org.osgi.framework.BundleContext getBundleContext()
getBundleContext in interface org.osgi.framework.Bundlepublic java.lang.String toString()
toString in class java.lang.Objectpublic void setLocation(java.lang.String location)
location - bundle locationpublic void setClassLoader(java.lang.ClassLoader loader)
loader - mock bundle class loader