public class BundleImpl extends java.lang.Object implements Bundle
Bundle
限定符和类型 | 字段和说明 |
---|---|
protected BundleActivator |
bactivator
BundleActivator for bundle.
|
protected BundleContextImpl |
bundleContext
BundleContext for bundle.
|
protected FileTree |
bundleDir
Directory for bundle data.
|
protected java.util.Vector<BundleGeneration> |
generations
Bundle generation data.
|
protected int |
operation
Type of operation in progress.
|
ACTIVE, INSTALLED, RESOLVED, SIGNERS_ALL, SIGNERS_TRUSTED, START_ACTIVATION_POLICY, START_TRANSIENT, STARTING, STOP_TRANSIENT, STOPPING, UNINSTALLED
限定符和类型 | 方法和说明 |
---|---|
<A> A |
adapt(java.lang.Class<A> type)
Adapt this bundle to the specified type.
|
int |
compareTo(Bundle bundle) |
java.util.Enumeration<java.net.URL> |
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.io.File |
getDataFile(java.lang.String filename)
Creates a
File object for a file in the persistent storage area
provided for this bundle by the Framework. |
java.net.URL |
getEntry(java.lang.String name)
Returns a URL to the entry at the specified path in this bundle.
|
java.util.Enumeration<java.lang.String> |
getEntryPaths(java.lang.String path)
Returns an Enumeration of all the paths (
String objects) to
entries within this bundle whose longest sub-path matches the specified
path. |
java.util.Dictionary<java.lang.String,java.lang.String> |
getHeaders()
Get header data.
|
java.util.Dictionary<java.lang.String,java.lang.String> |
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's class loader.
|
java.util.Enumeration<java.net.URL> |
getResources(java.lang.String name)
Find the specified resources from this bundle's class loader.
|
ServiceReference<?>[] |
getServicesInUse()
Get services that this bundle uses.
|
java.util.Map<java.security.cert.X509Certificate,java.util.List<java.security.cert.X509Certificate>> |
getSignerCertificates(int signersType)
Return the certificates for the signers of this bundle and the
certificate chains for those signers.
|
int |
getState()
Get bundle state.
|
java.lang.String |
getSymbolicName()
Returns the symbolic name of this bundle as specified by its
Bundle-SymbolicName manifest header. |
Version |
getVersion()
Returns the version of this bundle as specified by its
Bundle-Version 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 class loader.
|
void |
start()
Starts this bundle with no options.
|
void |
start(int options)
Start this bundle.
|
void |
stop()
Stop this bundle.
|
void |
stop(int options)
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.
|
protected final java.util.Vector<BundleGeneration> generations
protected FileTree bundleDir
protected BundleContextImpl bundleContext
protected BundleActivator bactivator
protected volatile int operation
public int getState()
getState
在接口中 Bundle
UNINSTALLED
,INSTALLED
,
RESOLVED
, STARTING
, STOPPING
,
ACTIVE
.Bundle.getState()
public void start() throws BundleException
Bundle
This method performs the same function as calling start(0)
.
start
在接口中 Bundle
BundleException
- If this bundle could not be started.
BundleException types thrown by this method include:
BundleException.NATIVECODE_ERROR
,
BundleException.RESOLVE_ERROR
,
BundleException.STATECHANGE_ERROR
, and
BundleException.ACTIVATOR_ERROR
.Bundle.start(int)
public void start(int options) throws BundleException
start
在接口中 Bundle
options
- The options for starting this bundle. See
Bundle.START_TRANSIENT
and Bundle.START_ACTIVATION_POLICY
. The
Framework must ignore unrecognized options.BundleException
- If this bundle could not be started.
BundleException types thrown by this method include:
BundleException.START_TRANSIENT_ERROR
,
BundleException.NATIVECODE_ERROR
,
BundleException.RESOLVE_ERROR
,
BundleException.STATECHANGE_ERROR
, and
BundleException.ACTIVATOR_ERROR
.Bundle.start(int)
public void stop() throws BundleException
stop
在接口中 Bundle
BundleException
- BundleException types thrown by this method
include: BundleException.STATECHANGE_ERROR
and
BundleException.ACTIVATOR_ERROR
.Bundle.stop(int)
public void stop(int options) throws BundleException
stop
在接口中 Bundle
options
- The options for stopping this bundle. See
Bundle.STOP_TRANSIENT
. The Framework must ignore unrecognized
options.BundleException
- BundleException types thrown by this method
include: BundleException.STATECHANGE_ERROR
and
BundleException.ACTIVATOR_ERROR
.Bundle.stop(int)
public void update() throws BundleException
update
在接口中 Bundle
BundleException
- If this bundle could not be updated.
BundleException types thrown by this method include:
BundleException.READ_ERROR
,
BundleException.DUPLICATE_BUNDLE_ERROR
,
BundleException.MANIFEST_ERROR
,
BundleException.NATIVECODE_ERROR
,
BundleException.RESOLVE_ERROR
,
BundleException.STATECHANGE_ERROR
, and
BundleException.ACTIVATOR_ERROR
.Bundle.update(java.io.InputStream)
public void update(java.io.InputStream in) throws BundleException
update
在接口中 Bundle
in
- The InputStream
from which to read the new bundle or
null
to indicate the Framework must create the input
stream from this bundle's Bundle-UpdateLocation
Manifest header, if present, or this
bundle's original location. The input stream must always be closed
when this method completes, even if an exception is thrown.BundleException
- If this bundle could not be updated.
BundleException types thrown by this method include:
BundleException.READ_ERROR
,
BundleException.DUPLICATE_BUNDLE_ERROR
,
BundleException.MANIFEST_ERROR
,
BundleException.NATIVECODE_ERROR
,
BundleException.RESOLVE_ERROR
,
BundleException.STATECHANGE_ERROR
, and
BundleException.ACTIVATOR_ERROR
.Bundle.update(java.io.InputStream)
public void uninstall() throws BundleException
uninstall
在接口中 Bundle
BundleException
- If the uninstall failed. This can occur if
another thread is attempting to change this bundle's state and
does not complete in a timely manner. BundleException types
thrown by this method include:
BundleException.STATECHANGE_ERROR
Bundle.uninstall()
public java.util.Dictionary<java.lang.String,java.lang.String> getHeaders()
getHeaders
在接口中 Bundle
Dictionary
object containing this
bundle's Manifest headers and values.Bundle.getHeaders()
public long getBundleId()
getBundleId
在接口中 Bundle
org.osgi.fwCtx.Bundle#getBundleId
public java.lang.String getLocation()
getLocation
在接口中 Bundle
Bundle.getLocation()
public ServiceReference<?>[] getRegisteredServices()
getRegisteredServices
在接口中 Bundle
ServiceReference
objects or null
.Bundle.getRegisteredServices()
public ServiceReference<?>[] getServicesInUse()
getServicesInUse
在接口中 Bundle
ServiceReference
objects or null
.Bundle.getServicesInUse()
public boolean hasPermission(java.lang.Object permission)
hasPermission
在接口中 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
在接口中 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 this 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 this bundle has not been resolved. If this bundle is a
fragment bundle then null
is returned.
Note: Jar and zip files are not required to include directory entries. URLs to directory entries will not be returned if the bundle contents do not contain directory entries.
getResource
在接口中 Bundle
name
- The name of the resource. See 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 bundle symbolic name
should be based on the reverse domain name naming convention like that
used for java packages.
This method must continue to return this bundle's symbolic name while
this bundle is in the UNINSTALLED
state.
getSymbolicName
在接口中 Bundle
null
if this bundle
does not have a symbolic name.Bundle.getSymbolicName()
public long getLastModified()
Bundle
The time value is the number of milliseconds since January 1, 1970, 00:00:00 UTC.
getLastModified
在接口中 Bundle
Bundle.getLastModified()
public java.util.Map<java.security.cert.X509Certificate,java.util.List<java.security.cert.X509Certificate>> getSignerCertificates(int signersType)
Bundle
getSignerCertificates
在接口中 Bundle
signersType
- If Bundle.SIGNERS_ALL
is specified, then information
on all signers of this bundle is returned. If
Bundle.SIGNERS_TRUSTED
is specified, then only information on
the signers of this bundle trusted by the framework is returned.X509Certificate
s for the signers of this bundle and
the X509Certificate
chains for those signers. The keys of
the Map
are the X509Certificate
s of the signers
of this bundle. The value for a key is a List
containing
the X509Certificate
chain for the signer. The first item
in the List
is the signer's X509Certificate
which
is then followed by the rest of the X509Certificate
chain. The returned Map
will be empty if there are no
signers. The returned Map
is the property of the caller
who is free to modify it.org.osgi.framework.Bundle#getSignerCertificates()
public Version getVersion()
Bundle
Bundle-Version
manifest header. If this bundle does not have a
specified version then Version.emptyVersion
is returned.
This method must continue to return this bundle's version while this
bundle is in the UNINSTALLED
state.
getVersion
在接口中 Bundle
Bundle.getVersion()
public <A> A adapt(java.lang.Class<A> type)
Bundle
Adapting this bundle to the specified type may require certain checks,
including security checks, to succeed. If a check does not succeed, then
this bundle cannot be adapted and null
is returned.
public java.io.File getDataFile(java.lang.String filename)
Bundle
File
object for a file in the persistent storage area
provided for this bundle by the Framework. This method will return
null
if the platform does not have file system support or this
bundle is a fragment bundle.
A File
object for the base directory of the persistent storage
area provided for this bundle by the Framework can be obtained by calling
this method with an empty string as filename
.
If the Java Runtime Environment supports permissions, the Framework will
ensure that this bundle has the java.io.FilePermission
with
actions read
,write
,delete
for all files
(recursively) in the persistent storage area provided for this bundle.
getDataFile
在接口中 Bundle
filename
- A relative name to the file to be accessed.File
object that represents the requested file or
null
if the platform does not have file system support or
this bundle is a fragment bundle.public java.lang.String toString()
toString
在类中 java.lang.Object
public java.util.Enumeration<java.net.URL> findEntries(java.lang.String path, java.lang.String filePattern, boolean recurse)
findEntries
在接口中 Bundle
path
- The path name in which to look. The path is always relative
to the root of this bundle and may begin with "/". A
path value of "/" indicates the root of this bundle.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. If the entry is a directory then the
trailing "/" is not used for pattern matching. Substring
matching is supported, 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 specified path.null
if no matching entry could 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 attachment 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
The specified path is always relative to the root of this bundle and may begin with "/". A path value of "/" indicates the root of this bundle.
Note: Jar and zip files are not required to include directory entries. URLs to directory entries will not be returned if the bundle contents do not contain directory entries.
public java.util.Enumeration<java.lang.String> getEntryPaths(java.lang.String path)
Bundle
String
objects) to
entries within this bundle whose longest sub-path matches the specified
path. This bundle's class loader is not used to search for entries. Only
the contents of this bundle are searched.
The specified path is always relative to the root of this bundle and may begin with a "/". A path value of "/" indicates the root of this bundle.
Returned paths indicating subdirectory paths end with a "/". The returned paths are all relative to the root of this bundle and must not begin with "/".
Note: Jar and zip files are not required to include directory entries. Paths to directory entries will not be returned if the bundle contents do not contain directory entries.
getEntryPaths
在接口中 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.public java.util.Dictionary<java.lang.String,java.lang.String> 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 this bundle's 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. If no localization is found for a header
value, the header value without the leading "%" is 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
在接口中 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 java.util.Enumeration<java.net.URL> getResources(java.lang.String name) throws java.io.IOException
Bundle
INSTALLED
, this method must
attempt to resolve this 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.
Note: Jar and zip files are not required to include directory entries. URLs to directory entries will not be returned if the bundle contents do not contain directory entries.
getResources
在接口中 Bundle
name
- The name of the resource. See
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 this 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 this bundle before attempting to load the class.
If this bundle cannot be resolved, a Framework event of type
FrameworkEvent.ERROR
is fired containing a
BundleException
with details of the reason this 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
在接口中 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()