public class BaseAdaptor extends Object implements FrameworkAdaptor
HookConfigurator
objects. A framework extension may add hook configurators which can be used
to add hooks to the HookRegistry
.HookConfigurator
,
HookRegistry
,
AdaptorHook
FRAMEWORK_SYMBOLICNAME
Constructor and Description |
---|
BaseAdaptor(String[] args)
Constructs a BaseAdaptor.
|
Modifier and Type | Method and Description |
---|---|
void |
compactStorage()
Compact/cleanup the persistent storage for the adaptor.
|
BundleFile |
createBundleFile(Object content,
BaseData data)
Creates a bundle file object for the given content and base data.
|
BundleData |
createSystemBundleData()
Creates a BundleData object for the System Bundle.
|
Enumeration<URL> |
findEntries(List<BundleData> datas,
String path,
String filePattern,
int options)
Returns resources entries for the specified bundle datas.
|
void |
frameworkStart(BundleContext fwContext)
This method calls all the configured adaptor hook
AdaptorHook.frameworkStart(BundleContext) methods. |
void |
frameworkStop(BundleContext fwContext)
This method calls all the configured adaptor hook
AdaptorHook.frameworkStop(BundleContext) methods. |
void |
frameworkStopping(BundleContext fwContext)
This method calls all the configured adaptor hook
AdaptorHook.frameworkStopping(BundleContext) methods. |
Bundle |
getBundle(long id)
Returns the bundle with the specified identifier.
|
ClassLoader |
getBundleClassLoaderParent()
This method calls all the configured classloading hooks
ClassLoadingHook.getBundleClassLoaderParent() methods
until one returns a non-null value. |
BundleWatcher |
getBundleWatcher()
Returns the bundle watcher for this FrameworkAdaptor.
|
BundleContext |
getContext()
Returns the system bundle's context
|
EventPublisher |
getEventPublisher()
Returns the event publisher for this BaseAdaptor
|
FrameworkLog |
getFrameworkLog()
This method calls all configured adaptor hook
AdaptorHook.createFrameworkLog() methods
until the first one returns a non-null value. |
HookRegistry |
getHookRegistry()
Returns the
HookRegistry object for this adaptor. |
int |
getInitialBundleStartLevel()
Returns the initial bundle start level as maintained by this adaptor
|
BundleData[] |
getInstalledBundles()
Return a list of the installed bundles.
|
PermissionStorage |
getPermissionStorage()
Returns the PermissionStorage object which will be used to
to manage the permission data.
|
PlatformAdmin |
getPlatformAdmin()
Returns the PlatformAdmin for this FrameworkAdaptor.
|
Properties |
getProperties()
This method will call all the configured adaptor hook
AdaptorHook.addProperties(Properties) methods. |
State |
getState()
Returns the State for this FrameworkAdaptor.
|
protected BaseStorage |
getStorage() |
long |
getTotalFreeSpace()
Returns the total amount of free space available for bundle storage on the device.
|
void |
handleRuntimeError(Throwable error)
This method calls all the configured adaptor hooks
AdaptorHook.handleRuntimeError(Throwable) methods. |
void |
initialize(EventPublisher publisher)
This method will call all configured adaptor hooks
AdaptorHook.initialize(BaseAdaptor) method. |
void |
initializeStorage()
Initialize the persistent storage for the adaptor.
|
BundleOperation |
installBundle(String location,
URLConnection source)
Prepare to install a bundle from a URLConnection.
|
boolean |
isReadOnly()
Returns true if the persistent storage is read-only
|
boolean |
isStopping()
Returns true if the
frameworkStopping(BundleContext) method has been called |
List<String> |
listEntryPaths(List<BundleFile> bundleFiles,
String path,
String filePattern,
int options)
Returns the names of resources available from a list of bundle files.
|
URLConnection |
mapLocationToURLConnection(String location)
This method will call each configured adaptor hook
AdaptorHook.mapLocationToURLConnection(String) method
until one returns a non-null value. |
void |
setInitialBundleStartLevel(int value)
Sets the initial bundle start level
|
BundleOperation |
uninstallBundle(BundleData bundledata)
Prepare to uninstall a bundle.
|
BundleOperation |
updateBundle(BundleData bundledata,
URLConnection source)
Prepare to update a bundle from a URLConnection.
|
public BaseAdaptor(String[] args)
args
- arguments passed to the adaptor by the framework.public void initialize(EventPublisher publisher)
AdaptorHook.initialize(BaseAdaptor)
method.initialize
in interface FrameworkAdaptor
publisher
- The EventPublisher used to publish any events to
the framework.FrameworkAdaptor.initialize(EventPublisher)
public void initializeStorage() throws IOException
FrameworkAdaptor
initializeStorage
in interface FrameworkAdaptor
IOException
- If the adaptor is unable to
initialize the bundle storage.FrameworkAdaptor.initializeStorage()
public void compactStorage() throws IOException
FrameworkAdaptor
compactStorage
in interface FrameworkAdaptor
IOException
FrameworkAdaptor.compactStorage()
public Properties getProperties()
AdaptorHook.addProperties(Properties)
methods.getProperties
in interface FrameworkAdaptor
FrameworkAdaptor.getProperties()
public BundleData[] getInstalledBundles()
FrameworkAdaptor
BundleData
. Each BundleData
corresponds to one bundle that is persistently stored.
This method must construct BundleData
objects for all
installed bundles and return an array containing the objects.
The returned array becomes the property of the framework.getInstalledBundles
in interface FrameworkAdaptor
FrameworkAdaptor.getInstalledBundles()
public URLConnection mapLocationToURLConnection(String location) throws BundleException
AdaptorHook.mapLocationToURLConnection(String)
method
until one returns a non-null value. If none of the adaptor hooks return a non-null value then the
string is used to construct a new URL object to open a new url connection.mapLocationToURLConnection
in interface FrameworkAdaptor
location
- of the bundle.BundleException
- if the mapping fails.FrameworkAdaptor.mapLocationToURLConnection(String)
public BundleOperation installBundle(String location, URLConnection source)
FrameworkAdaptor
To complete the install,
begin and then commit
must be called on the returned BundleOperation
object.
If either of these methods throw a BundleException
or some other error occurs,
then undo must be called on the BundleOperation
object
to undo the change to persistent storage.
installBundle
in interface FrameworkAdaptor
location
- Bundle location.source
- URLConnection from which the bundle may be read.
Any InputStreams returned from the source
(URLConnections.getInputStream) must be closed by the
BundleOperation
object.FrameworkAdaptor.installBundle(String, URLConnection)
public BundleOperation updateBundle(BundleData bundledata, URLConnection source)
FrameworkAdaptor
To complete the update
begin and then commit
must be called on the returned BundleOperation
object.
If either of these methods throw a BundleException
or some other error occurs,
then undo must be called on the BundleOperation
object
to undo the change to persistent storage.
updateBundle
in interface FrameworkAdaptor
bundledata
- BundleData to update.source
- URLConnection from which the updated bundle may be read.
Any InputStreams returned from the source
(URLConnections.getInputStream) must be closed by the
BundleOperation
object.FrameworkAdaptor.updateBundle(BundleData, URLConnection)
public BundleOperation uninstallBundle(BundleData bundledata)
FrameworkAdaptor
To complete the uninstall,
begin and then commit
must be called on the returned BundleOperation
object.
If either of these methods throw a BundleException
or some other error occurs,
then undo must be called on the BundleOperation
object
to undo the change to persistent storage.
uninstallBundle
in interface FrameworkAdaptor
bundledata
- BundleData to uninstall.FrameworkAdaptor.uninstallBundle(BundleData)
public long getTotalFreeSpace() throws IOException
FrameworkAdaptor
getTotalFreeSpace
in interface FrameworkAdaptor
IOException
- if an I/O error occurs determining the available spaceFrameworkAdaptor.getTotalFreeSpace()
public PermissionStorage getPermissionStorage() throws IOException
FrameworkAdaptor
getPermissionStorage
in interface FrameworkAdaptor
IOException
FrameworkAdaptor.getPermissionStorage()
public void frameworkStart(BundleContext fwContext) throws BundleException
AdaptorHook.frameworkStart(BundleContext)
methods.frameworkStart
in interface FrameworkAdaptor
fwContext
- The System Bundle's BundleContext.BundleException
- on any error that may occur.FrameworkAdaptor.frameworkStart(BundleContext)
public void frameworkStop(BundleContext fwContext) throws BundleException
AdaptorHook.frameworkStop(BundleContext)
methods.frameworkStop
in interface FrameworkAdaptor
fwContext
- The System Bundle's BundleContext.BundleException
- on any error that may occur.FrameworkAdaptor.frameworkStop(BundleContext)
public void frameworkStopping(BundleContext fwContext)
AdaptorHook.frameworkStopping(BundleContext)
methods.frameworkStopping
in interface FrameworkAdaptor
fwContext
- The System Bundle's BundleContext.FrameworkAdaptor.frameworkStopping(BundleContext)
public int getInitialBundleStartLevel()
FrameworkAdaptor
getInitialBundleStartLevel
in interface FrameworkAdaptor
FrameworkAdaptor.getInitialBundleStartLevel()
public void setInitialBundleStartLevel(int value)
FrameworkAdaptor
setInitialBundleStartLevel
in interface FrameworkAdaptor
value
- the initial bundle start levelFrameworkAdaptor.setInitialBundleStartLevel(int)
public FrameworkLog getFrameworkLog()
AdaptorHook.createFrameworkLog()
methods
until the first one returns a non-null value. If none of the adaptor hooks return a non-null
value then a framework log implementation which does nothing is returned.getFrameworkLog
in interface FrameworkAdaptor
FrameworkAdaptor.getFrameworkLog()
public BundleData createSystemBundleData() throws BundleException
FrameworkAdaptor
createSystemBundleData
in interface FrameworkAdaptor
BundleException
- if any error occurs while creating the
System BundleData.FrameworkAdaptor.createSystemBundleData()
public BundleWatcher getBundleWatcher()
FrameworkAdaptor
getBundleWatcher
in interface FrameworkAdaptor
FrameworkAdaptor.getBundleWatcher()
public PlatformAdmin getPlatformAdmin()
FrameworkAdaptor
This method will not be called until after
FrameworkAdaptor.frameworkStart(BundleContext)
is called.
getPlatformAdmin
in interface FrameworkAdaptor
FrameworkAdaptor.getPlatformAdmin()
public State getState()
FrameworkAdaptor
This method will not be called until after
FrameworkAdaptor.frameworkStart(BundleContext)
is called.
The State returned is used by the framework to resolve bundle
dependencies.
getState
in interface FrameworkAdaptor
FrameworkAdaptor.getState()
public ClassLoader getBundleClassLoaderParent()
ClassLoadingHook.getBundleClassLoaderParent()
methods
until one returns a non-null value.getBundleClassLoaderParent
in interface FrameworkAdaptor
FrameworkAdaptor.getBundleClassLoaderParent()
public void handleRuntimeError(Throwable error)
AdaptorHook.handleRuntimeError(Throwable)
methods.handleRuntimeError
in interface FrameworkAdaptor
error
- The Throwable for the runtime error that is to be handled.FrameworkAdaptor.handleRuntimeError(Throwable)
public boolean isStopping()
frameworkStopping(BundleContext)
method has been calledpublic EventPublisher getEventPublisher()
public HookRegistry getHookRegistry()
HookRegistry
object for this adaptor.HookRegistry
object for this adaptor.public BundleContext getContext()
public Bundle getBundle(long id)
id
- The identifier of the bundle to retrieve.Bundle
object or null
if the identifier does
not match any installed bundle.public BundleFile createBundleFile(Object content, BaseData data) throws IOException
BundleFileFactoryHook.createBundleFile(Object, BaseData, boolean)
method until one
factory returns a non-null value. If no bundle file factory returns a non-null value
then the the default behavior will be performed.
If the specified content is null
then the base content of the specified
bundledata must be found before calling any bundle file factories.
After the bundle file has been created each configured bundle file wrapper factory
BundleFileWrapperFactoryHook.wrapBundleFile(BundleFile, Object, BaseData, boolean)
method is called to wrap the bundle file.
content
- The object which contains the content of a bundle file. A value of
null
indicates that the storage must find the base content for the
specified BaseData.data
- The BaseData associated with the contentIOException
- if an error occured while creating the BundleFilepublic boolean isReadOnly()
protected BaseStorage getStorage()
public Enumeration<URL> findEntries(List<BundleData> datas, String path, String filePattern, int options)
FrameworkAdaptor
findEntries
in interface FrameworkAdaptor
datas
- the list of bundle datas to search inpath
- The path name in which to look.filePattern
- The file name pattern for selecting resource names in
the specified path.options
- The options for listing resource names.FrameworkAdaptor.findEntries(List, String, String, int)
public List<String> listEntryPaths(List<BundleFile> bundleFiles, String path, String filePattern, int options)
bundleFiles
- the list of bundle files to search inpath
- The path name in which to look.filePattern
- The file name pattern for selecting resource names in
the specified path.options
- The options for listing resource names.BundleWiring.listResources(String, String, int)
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.