|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.knopflerfish.framework.BundleImpl
public class BundleImpl
Implementation of the Bundle object.
Bundle
Field Summary | |
---|---|
protected BundleActivator |
bactivator
BundleActivator for bundle. |
protected BundleContextImpl |
bundleContext
BundleContext for bundle. |
protected FileTree |
bundleDir
Directory for bundle data. |
protected long |
lastModified
Time when bundle was last modified. |
Fields inherited from interface org.osgi.framework.Bundle |
---|
ACTIVE, INSTALLED, RESOLVED, STARTING, STOPPING, UNINSTALLED |
Method Summary | |
---|---|
java.util.Enumeration |
findEntries(java.lang.String path,
java.lang.String filePattern,
boolean recurse)
Get bundle data. |
BundleContext |
getBundleContext()
Returns this bundle's BundleContext. |
long |
getBundleId()
Get bundle identifier. |
java.security.cert.Certificate[] |
getCertificates()
Get protection domain for bundle. |
java.net.URL |
getEntry(java.lang.String name)
Returns a URL to the specified entry in this bundle. |
java.util.Enumeration |
getEntryPaths(java.lang.String path)
Returns an Enumeration of all the paths ( String objects)
to entries within the bundle whose longest sub-path matches the supplied
path argument. |
java.util.Dictionary |
getHeaders()
Get header data. |
java.util.Dictionary |
getHeaders(java.lang.String locale)
Returns this bundle's Manifest headers and values localized to the specified locale. |
long |
getLastModified()
Returns the time when this bundle was last modified. |
java.lang.String |
getLocation()
Get bundle location. |
ServiceReference[] |
getRegisteredServices()
Get services that this bundle has registrated. |
java.net.URL |
getResource(java.lang.String name)
Find the specified resource from this bundle. |
java.util.Enumeration |
getResources(java.lang.String name)
Find the specified resources from this bundle. |
ServiceReference[] |
getServicesInUse()
Get services that this bundle uses. |
int |
getState()
Get bundle state. |
java.lang.String |
getSymbolicName()
Returns the symbolic name of this bundle as specified by its Bundle-SymbolicName manifest header. |
boolean |
hasPermission(java.lang.Object permission)
Determine whether the bundle has the requested permission. |
java.lang.Class |
loadClass(java.lang.String name)
Loads the specified class using this bundle's classloader. |
protected void |
readLocalization(java.lang.String locale,
java.util.Hashtable localization_entries,
java.lang.String baseName)
Reads all localization entries that affects this bundle (including its host/fragments) |
void |
start()
Start this bundle. |
void |
stop()
Stop this bundle. |
java.lang.String |
toString()
Return a string representing this bundle. |
void |
uninstall()
Uninstall this bundle. |
void |
update()
Update this bundle. |
void |
update(java.io.InputStream in)
Update this bundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected FileTree bundleDir
protected BundleContextImpl bundleContext
protected BundleActivator bactivator
protected long lastModified
Method Detail |
---|
public int getState()
getState
in interface Bundle
UNINSTALLED
,INSTALLED
,
RESOLVED
,STARTING
,
STOPPING
,ACTIVE
.Bundle.getState()
public void start() throws BundleException
start
in interface Bundle
BundleException
- If this bundle could not be started. This could
be because a code dependency could not be resolved or the
specified BundleActivator
could not be loaded or
threw an exception.Bundle.start()
public void stop() throws BundleException
stop
in interface Bundle
BundleException
- If this bundle's BundleActivator
could not be loaded or threw an exception.Bundle.stop()
public void update() throws BundleException
update
in interface Bundle
BundleException
- If the update fails.Bundle.update()
public void update(java.io.InputStream in) throws BundleException
update
in interface Bundle
in
- The InputStream
from which to read the new
bundle.
BundleException
- If the provided stream cannot be read or the
update fails.Bundle.update()
public void uninstall() throws BundleException
uninstall
in interface Bundle
BundleException
- If the uninstall failed. This can occur if
another thread is attempting to change the bundle's state and
does not complete in a timely manner.Bundle.uninstall()
public java.util.Dictionary getHeaders()
getHeaders
in interface Bundle
Dictionary
object containing this bundle's
Manifest headers and values.Bundle.getHeaders()
public long getBundleId()
getBundleId
in interface Bundle
Bundle.getBundleId()
public java.lang.String getLocation()
getLocation
in interface Bundle
Bundle.getLocation()
public ServiceReference[] getRegisteredServices()
getRegisteredServices
in interface Bundle
ServiceReference
objects or
null
.Bundle.getRegisteredServices()
public ServiceReference[] getServicesInUse()
getServicesInUse
in interface Bundle
ServiceReference
objects or
null
.Bundle.getServicesInUse()
public boolean hasPermission(java.lang.Object permission)
hasPermission
in interface Bundle
permission
- The permission to verify.
true
if this bundle has the specified permission
or the permissions possessed by this bundle imply the specified
permission; false
if this bundle does not have the
specified permission or permission
is not an
instanceof
java.security.Permission
.Bundle.hasPermission(java.lang.Object)
public BundleContext getBundleContext()
getBundleContext
in interface Bundle
BundleContext
for this bundle or
null
if this bundle has no valid
BundleContext
.Bundle.getBundleContext()
public java.net.URL getResource(java.lang.String name)
Bundle
INSTALLED
, this method must
attempt to resolve the bundle before attempting to get the specified resource.
If this bundle cannot be resolved, then only this bundle
must be searched for the specified resource. Imported packages cannot be
searched when a bundle has not been resolved. If this bundle is a
fragment bundle then null
is returned.
getResource
in interface Bundle
name
- The name of the resource. See
java.lang.ClassLoader.getResource
for a description
of the format of a resource name.
null
if the
resource could not be found or if this bundle is a fragment
bundle or if the caller does not have the appropriate
AdminPermission[this,RESOURCE]
, and the Java Runtime
Environment supports permissions.Bundle.getResource(String name)
public java.lang.String getSymbolicName()
Bundle
Bundle-SymbolicName
manifest header. The name must be
unique, it is recommended to use a reverse domain name naming convention
like that used for java packages. If the bundle does not have a specified
symbolic name then null
is returned.
This method must continue to return this bundle's symbolic name while
this bundle is in the UNINSTALLED
state.
getSymbolicName
in interface Bundle
Bundle.getSymbolicName()
public java.security.cert.Certificate[] getCertificates()
public java.lang.String toString()
toString
in class java.lang.Object
public java.util.Enumeration findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)
findEntries
in interface Bundle
path
- The path name in which to look. A specified path of
"/" indicates the root of the bundle. Path is relative
to the root of the bundle and must not be null.filePattern
- The file name pattern for selecting entries in the
specified path. The pattern is only matched against the last
element of the entry path and it supports substring matching, as
specified in the Filter specification, using the wildcard
character ("*"). If null is specified, this is
equivalent to "*" and matches all files.recurse
- If true
, recurse into subdirectories.
Otherwise only return entries from the given directory.
null
if an entry could not be found or if the
caller does not have the appropriate
AdminPermission[this,RESOURCE]
, and the Java Runtime
Environment supports permissions. The URLs are sorted such that
entries from this bundle are returned first followed by the
entries from attached fragments in ascending bundle id order. If
this bundle is a fragment, then only matching entries in this
fragment are returned.Bundle.findEntries(java.lang.String, java.lang.String, boolean)
public java.net.URL getEntry(java.lang.String name)
Bundle
getEntry
in interface Bundle
name
- The name of the entry. See
java.lang.ClassLoader.getResource
for a description
of the format of a resource name.
null
if no entry
could be found or if the caller does not have the appropriate
AdminPermission[this,RESOURCE]
and the Java Runtime
Environment supports permissions.public java.util.Enumeration getEntryPaths(java.lang.String path)
Bundle
String
objects)
to entries within the bundle whose longest sub-path matches the supplied
path argument. The bundle's classloader is not used to search for
entries. Only the contents of the bundle is searched. A specified path of
"/" indicates the root of the bundle.
Returned paths indicating subdirectory paths end with a "/". The returned paths are all relative to the root of the bundle.
getEntryPaths
in interface Bundle
path
- The path name for which to return entry paths.
String
objects) or null
if no entry could be found or if
the caller does not have the appropriate
AdminPermission[this,RESOURCE]
and the Java Runtime
Environment supports permissions.protected void readLocalization(java.lang.String locale, java.util.Hashtable localization_entries, java.lang.String baseName)
locale
- locale == "" the bundle.properties will be read
o/w it will read the files as described in the spec.localization_entries
- will append the new entries to this dictionarybaseName
- the basename for localization properties,
null
will choose OSGi defaultpublic java.util.Dictionary getHeaders(java.lang.String locale)
Bundle
This method performs the same function as
Bundle.getHeaders()
except the manifest header values are
localized to the specified locale.
If a Manifest header value starts with "%", it must be localized according to the specified locale. If a locale is specified and cannot be found, then the header values must be returned using the default locale. Localizations are searched for in the following order:
bn + "_" + Ls + "_" + Cs + "_" + Vs bn + "_" + Ls + "_" + Cs bn + "_" + Ls bn + "_" + Ld + "_" + Cd + "_" + Vd bn + "_" + Ld + "_" + Cd bn + "_" + Ld bnWhere
bn
is the bundle localization basename, Ls
,
Cs
and Vs
are the specified locale (language,
country, variant) and Ld
, Cd
and Vd
are the default locale (language, country, variant).
If null
is specified as the locale string, the header
values must be localized using the default locale. If the empty string
("") is specified as the locale string, the header values must
not be localized and the raw (unlocalized) header values, including any
leading "%", must be returned.
This method must continue to return Manifest header information while
this bundle is in the UNINSTALLED
state, however the
header values must only be available in the raw and default locale
values.
getHeaders
in interface Bundle
locale
- The locale name into which the header values are to be
localized. If the specified locale is null
then the
locale returned by java.util.Locale.getDefault
is
used. If the specified locale is the empty string, this method
will return the raw (unlocalized) manifest headers including any
leading "%".
Dictionary
object containing this bundle's
Manifest headers and values.Bundle.getHeaders(String locale)
public long getLastModified()
Bundle
The time value is the number of milliseconds since January 1, 1970, 00:00:00 GMT.
getLastModified
in interface Bundle
Bundle.getLastModified()
public java.util.Enumeration getResources(java.lang.String name) throws java.io.IOException
Bundle
INSTALLED
, this method must
attempt to resolve the bundle before attempting to get the specified resources.
If this bundle cannot be resolved, then only this bundle
must be searched for the specified resources. Imported packages cannot be
searched when a bundle has not been resolved. If this bundle is a
fragment bundle then null
is returned.
getResources
in interface Bundle
name
- The name of the resource. See
java.lang.ClassLoader.getResources
for a
description of the format of a resource name.
null
if the resource could not be found or if this
bundle is a fragment bundle or if the caller does not have the
appropriate AdminPermission[this,RESOURCE]
, and the
Java Runtime Environment supports permissions.
java.io.IOException
- If there is an I/O error.Bundle.getResources(String name)
public java.lang.Class loadClass(java.lang.String name) throws java.lang.ClassNotFoundException
Bundle
If the bundle is a fragment bundle then this method must throw a
ClassNotFoundException
.
If this bundle's state is INSTALLED
, this method must
attempt to resolve the bundle before attempting to load the class.
If the bundle cannot be resolved, a Framework event of type
FrameworkEvent.ERROR
is fired containing a
BundleException
with details of the reason the bundle
could not be resolved. This method must then throw a
ClassNotFoundException
.
If this bundle's state is UNINSTALLED
, then an
IllegalStateException
is thrown.
loadClass
in interface Bundle
name
- The name of the class to load.
java.lang.ClassNotFoundException
- If no such class can be found or
if this bundle is a fragment bundle or if the caller does not
have the appropriate AdminPermission[this,CLASS]
, and
the Java Runtime Environment supports permissions.org.osgi.framework.Bundle#loadClass()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |