Interface State
This interface is not intended to be implemented by clients. The
StateObjectFactory
should be used to construct instances.
- Since:
- 3.1
- Restriction:
- This interface is not intended to be implemented by clients.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
addBundle
(BundleDescription description) Adds the given bundle to this state.void
addDisabledInfo
(DisabledInfo disabledInfo) Adds the disabled info to this state.void
addDynamicImportPackages
(BundleDescription importingBundle, ImportPackageSpecification[] dynamicImports) Adds the specified dynamic imports to the specified importingBundle.void
addResolverError
(BundleDescription bundle, int type, String data, VersionConstraint unsatisfied) Adds a newResolverError
for the specified bundle.Returns a delta describing the differences between this state and the given state.getBundle
(long id) Returns the bundle descriptor for the bundle with the given id.Returns the bundle descriptor for the bundle with the given name and version.getBundleByLocation
(String location) Returns the bundle descriptor for the bundle with the given location identifier. null is returned if no such bundle is found in this state.Returns descriptions for all bundles known to this state.getBundles
(String symbolicName) Returns all bundle descriptions with the given bundle symbolic name.Returns the delta representing the changes from the time this state was first captured until now.getDependencyClosure
(Collection<BundleDescription> bundles) Returns the dependency closure for the specified bundles.Returns an array of BundleDescriptions for the bundles that are disabled in the system.getDisabledInfo
(BundleDescription bundle, String policyName) Returns the disabled info for the specified bundle with the specified policy name.getDisabledInfos
(BundleDescription bundle) Returns an array of disabled info for the specified bundle.Returns all exported packages in this state, according to the OSGi rules for resolution.Returns the factory that created this state.long
Returns the highest bundle ID.Returns the list of platform properties currently set for this state.Returns descriptions for all bundles in a removal pending state.Returns descriptions for all bundles currently resolved in this state.Returns the resolver associated with this state.getResolverErrors
(BundleDescription bundle) Returns allResolverError
s for the given bundleReturns a state helper object.Returns the list of system packages which are exported by the system bundle.long
Returns the timestamp for this state.boolean
isEmpty()
Returns whether this state is empty.boolean
Returns true if there have been no modifications to this state since the last time resolve() was called.linkDynamicImport
(BundleDescription importingBundle, String requestedPackage) Attempts to find an ExportPackageDescription that will satisfy a dynamic import for the specified requestedPackage for the specified importingBundle.removeBundle
(long bundleId) Removes a bundle description with the given bundle id.boolean
removeBundle
(BundleDescription bundle) Removes the given bundle description.void
Sets the given removal pending bundle to removal complete for this state.void
removeDisabledInfo
(DisabledInfo disabledInfo) Removes the disabled info from the state.void
Removes allResolverError
s for the specified bundle.resolve()
Same as State.resolve(true);resolve
(boolean incremental) Resolves the constraints contained in this state using the resolver currently associated with the state and returns a delta describing the changes in resolved states and dependencies in the state.resolve
(BundleDescription[] discard) Resolves the constraints contained in this state using the resolver currently associated with the state in an incremental, "least-perturbing" mode, and returns a delta describing the changes in resolved states and dependencies in the state.resolve
(BundleDescription[] resolve, boolean discard) Resolves the constraints contained in this state using the resolver currently associated with the state in an incremental, "least-perturbing" mode, and returns a delta describing the changes in resolved states and dependencies in the state.void
resolveBundle
(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports) Deprecated.void
resolveBundle
(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports) void
resolveBundle
(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, GenericDescription[] selectedCapabilities, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports, GenericDescription[] resolvedCapabilities, Map<String, List<StateWire>> resolvedWires) Sets whether or not the given bundle is selected in this state.void
resolveConstraint
(VersionConstraint constraint, BaseDescription supplier) Resolves the given version constraint with the given supplier.void
setNativePathsInvalid
(NativeCodeDescription nativeCodeDescription, boolean hasInvalidNativePaths) Sets the native code paths of a native code description as invalid.void
setOverrides
(Object value) Deprecated.The exact form of this has never been defined.boolean
setPlatformProperties
(Dictionary<?, ?> platformProperties) Sets the platform properties of the state.boolean
setPlatformProperties
(Dictionary<?, ?>[] platformProperties) Sets the platform properties of the state to a list of platform properties.void
setResolver
(Resolver value) Sets the resolver associated with this state.void
setResolverHookFactory
(ResolverHookFactory hookFactory) Sets the resolver hook factory for this state.void
setTimeStamp
(long newTimeStamp) Sets the timestamp for this stateboolean
updateBundle
(BundleDescription newDescription) Updates an existing bundle description with the given description.
-
Method Details
-
addBundle
Adds the given bundle to this state.If the bundle already exists in another state then an
IllegalStateException
will be thrown. Note that even if you remove aBundleDescription
from oneState
object usingremoveBundle(BundleDescription)
it may still be considered as removing pending if other bundles in that state depend on the bundle you removed. To complete a pending removal a call must be done toresolve(BundleDescription[])
with the removed bundle.- Parameters:
description
- the description to add- Returns:
- a boolean indicating whether the bundle was successfully added
- Throws:
IllegalStateException
- if the bundle already exists in another state
-
compare
Returns a delta describing the differences between this state and the given state. The given state is taken as the base so the absence of a bundle in this state is reported as a deletion, etc.Note that the generated StateDelta will contain BundleDeltas with one of the following types: BundleDelta.ADDED, BundleDelta.REMOVED and BundleDelta.UPDATED
- Parameters:
baseState
- the base state- Returns:
- a delta describing differences between this and the base state state
- Throws:
BundleException
-
removeBundle
Removes a bundle description with the given bundle id.- Parameters:
bundleId
- the id of the bundle description to be removed- Returns:
- the removed bundle description, or
null
, if a bundle with the given id does not exist in this state
-
removeBundle
Removes the given bundle description.- Parameters:
bundle
- the bundle description to be removed- Returns:
true
, if if the bundle description was removed,false
otherwise
-
updateBundle
Updates an existing bundle description with the given description.- Parameters:
newDescription
- the bundle description to replace an existing one- Returns:
true
, if if the bundle description was updated,false
otherwise
-
getChanges
StateDelta getChanges()Returns the delta representing the changes from the time this state was first captured until now.- Returns:
- the state delta
-
getBundles
BundleDescription[] getBundles()Returns descriptions for all bundles known to this state.- Returns:
- the descriptions for all bundles known to this state.
-
getBundle
Returns the bundle descriptor for the bundle with the given id.null
is returned if no such bundle is found in this state.- Returns:
- the descriptor for the identified bundle
- See Also:
-
getBundle
Returns the bundle descriptor for the bundle with the given name and version. A null value is returned if no such bundle is found in this state. A resolved bundle is always preferably returned over an unresolved bundle. If multiple bundles with the same resolution state are available, the bundle with the highest version number is returned if theversion
is null.- Parameters:
symbolicName
- symbolic name of the bundle to queryversion
- version of the bundle to query. null matches any bundle- Returns:
- the descriptor for the identified bundle
-
getBundleByLocation
Returns the bundle descriptor for the bundle with the given location identifier. null is returned if no such bundle is found in this state.- Parameters:
location
- location identifier of the bundle to query- Returns:
- the descriptor for the identified bundle
-
getTimeStamp
long getTimeStamp()Returns the timestamp for this state. This correlates this timestamp to the system state. For example, if the system state timestamp is 4 but then some bundles are installed, the system state timestamp is updated. By comparing 4 to the current system state timestamp it is possible to detect if the states are out of sync.- Returns:
- the timestamp of this state
-
setTimeStamp
void setTimeStamp(long newTimeStamp) Sets the timestamp for this state- Parameters:
newTimeStamp
- the new timestamp for this state
-
isResolved
boolean isResolved()Returns true if there have been no modifications to this state since the last time resolve() was called.- Returns:
- whether or not this state has changed since last resolved.
-
resolveConstraint
Resolves the given version constraint with the given supplier. The given constraint object is destructively modified to reflect its new resolved state. Note that a constraint can be unresolved by passing null for the supplier.This method is intended to be used by resolvers in the process of determining which constraints are satisfied by which components.
- Parameters:
constraint
- the version constraint to updatesupplier
- the supplier which satisfies the constraint. May be null if the constraint is to be unresolved.- Throws:
IllegalStateException
- if this is not done during a call toresolve
-
resolveBundle
void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports) Sets whether or not the given bundle is selected in this state.This method is intended to be used by resolvers in the process of determining which constraints are satisfied by which components.
- Parameters:
bundle
- the bundle to updatestatus
- whether or not the given bundle is resolved, if false the other parameters are ignoredhosts
- the host for the resolve fragment, can benull
selectedExports
- the selected exported packages for this resolved bundle, can benull
resolvedRequires
- theBundleDescription
s that resolve the required bundles for this bundle, can benull
resolvedImports
- the exported packages that resolve the imports for this bundle, can benull
- Throws:
IllegalStateException
- if this is not done during a call toresolve
-
resolveBundle
void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports) Sets whether or not the given bundle is selected in this state.This method is intended to be used by resolvers in the process of determining which constraints are satisfied by which components.
- Parameters:
bundle
- the bundle to updatestatus
- whether or not the given bundle is resolved, if false the other parameters are ignoredhosts
- the host for the resolve fragment, can benull
selectedExports
- the selected exported packages for this resolved bundle, can benull
substitutedExports
- the exported packages that resolve imports for this bundle and substitute exports, can benull
resolvedRequires
- theBundleDescription
s that resolve the required bundles for this bundle, can benull
resolvedImports
- the exported packages that resolve the imports for this bundle, can benull
- Throws:
IllegalStateException
- if this is not done during a call toresolve
- Since:
- 3.4
-
resolveBundle
void resolveBundle(BundleDescription bundle, boolean status, BundleDescription[] hosts, ExportPackageDescription[] selectedExports, ExportPackageDescription[] substitutedExports, GenericDescription[] selectedCapabilities, BundleDescription[] resolvedRequires, ExportPackageDescription[] resolvedImports, GenericDescription[] resolvedCapabilities, Map<String, List<StateWire>> resolvedWires) Sets whether or not the given bundle is selected in this state.This method is intended to be used by resolvers in the process of determining which constraints are satisfied by which components.
- Parameters:
bundle
- the bundle to updatestatus
- whether or not the given bundle is resolved, if false the other parameters are ignoredhosts
- the host for the resolve fragment, can benull
selectedExports
- the selected exported packages for this resolved bundle, can benull
substitutedExports
- the exported packages that resolve imports for this bundle and substitute exports, can benull
selectedCapabilities
- the selected capabilities for this resolved bundle, can benull
resolvedRequires
- theBundleDescription
s that resolve the required bundles for this bundle, can benull
resolvedImports
- the exported packages that resolve the imports for this bundle, can benull
resolvedCapabilities
- the capabilities that resolve the required capabilities for this bundle, can benull
resolvedWires
- the map of state wires for the resolved requirements of the given bundle. The key is the name space of the requirement.- Throws:
IllegalStateException
- if this is not done during a call toresolve
- Since:
- 3.7
-
removeBundleComplete
Sets the given removal pending bundle to removal complete for this state.This method is intended to be used by resolvers in the process of resolving bundles.
- Parameters:
bundle
- the bundle to set a removal complete.- Throws:
IllegalStateException
- if this is not done during a call toresolve
-
addResolverError
void addResolverError(BundleDescription bundle, int type, String data, VersionConstraint unsatisfied) Adds a newResolverError
for the specified bundle.This method is intended to be used by resolvers in the process of resolving.
- Parameters:
bundle
- the bundle to add a newResolverError
fortype
- the type ofResolverError
to adddata
- the data for theResolverError
unsatisfied
- the unsatisfied constraint or null if the resolver error was not caused by an unsatisfied constraint.- Throws:
IllegalStateException
- if this is not done during a call toresolve
- Since:
- 3.2
-
removeResolverErrors
Removes allResolverError
s for the specified bundle.This method is intended to be used by resolvers in the process of resolving.
- Parameters:
bundle
- the bundle to remove allResolverError
s for- Throws:
IllegalStateException
- if this is not done during a call toresolve
- Since:
- 3.2
-
getResolverErrors
Returns allResolverError
s for the given bundle- Parameters:
bundle
- the bundle to get allResolverError
s for- Returns:
- all
ResolverError
s for the given bundle - Since:
- 3.2
-
getResolver
Resolver getResolver()Returns the resolver associated with this state. A state can work with at most one resolver at any given time. Similarly, a resolver can work with at most one state at a time.- Returns:
- the resolver for this state. null is returned if the state does not have a resolver
-
setResolver
Sets the resolver associated with this state. A state can work with at most one resolver at any given time. Similarly, a resolver can work with at most one state at a time.To ensure that this state and the given resovler are properly linked, the following expression must be included in this method if the given resolver (value) is not identical to the result of this.getResolver().
if (this.getResolver() != value) value.setState(this);
-
resolve
Resolves the constraints contained in this state using the resolver currently associated with the state and returns a delta describing the changes in resolved states and dependencies in the state.Note that this method is typically implemented using
this.getResolver().resolve();
and is the preferred path for invoking resolution. In particular, states should refuse to perform updates (@see #select() and #resolveConstraint()) if they are not currently involved in a resolution cycle.Note the given state is destructively modified to reflect the results of resolution.
- Parameters:
incremental
- a flag controlling whether resolution should be incremental- Returns:
- a delta describing the changes in resolved state and interconnections
-
resolve
StateDelta resolve()Same as State.resolve(true); -
resolve
Resolves the constraints contained in this state using the resolver currently associated with the state in an incremental, "least-perturbing" mode, and returns a delta describing the changes in resolved states and dependencies in the state.- Parameters:
discard
- an array containing descriptions for bundles whose current resolution state should be forgotten. Ifnull
then all the current removal pending BundleDescriptions are refreshed.- Returns:
- a delta describing the changes in resolved state and interconnections
-
resolve
Resolves the constraints contained in this state using the resolver currently associated with the state in an incremental, "least-perturbing" mode, and returns a delta describing the changes in resolved states and dependencies in the state. If discard is set to true the the descriptions contained in the resolve array will have their current resolution state discarded and will be re-resolved. This method will attempt to resolve the supplied descriptions and may attempt to resolve any other unresolved descriptions contained in this state.- Parameters:
resolve
- an array containing descriptions for bundles to resolve.discard
- a value of true indicates the resolve descriptions should have their current resolution state discarded and re-resolved.- Returns:
- a delta describing the changes in the resolved state and interconnections.
- Since:
- 3.7
-
setOverrides
Deprecated.The exact form of this has never been defined. There is no alternative method available.Sets the version overrides which are to be applied during the resolution of this state. Version overrides allow external forces to refine/override the version constraints setup by the components in the state.- Parameters:
value
- Format undefined.
-
getResolvedBundles
BundleDescription[] getResolvedBundles()Returns descriptions for all bundles currently resolved in this state.- Returns:
- the descriptions for all bundles currently resolved in this state.
-
getRemovalPending
BundleDescription[] getRemovalPending()Returns descriptions for all bundles in a removal pending state.- Returns:
- the descriptions for all bundles in a removal pending state.
- Since:
- 3.7
-
getDependencyClosure
Returns the dependency closure for the specified bundles.A graph of bundles is computed starting with the specified bundles. The graph is expanded by adding any bundle that is either wired to a package that is currently exported by a bundle in the graph or requires a bundle in the graph. The graph is fully constructed when there is no bundle outside the graph that is wired to a bundle in the graph. The graph may contain removal pending bundles.
- Parameters:
bundles
- The initial bundles for which to generate the dependency closure.- Returns:
- A collection containing a snapshot of the dependency closure of the specified bundles, or an empty collection if there were no specified bundles.
- Since:
- 3.7
-
isEmpty
boolean isEmpty()Returns whether this state is empty.- Returns:
true
if this state is empty,false
otherwise
-
getExportedPackages
ExportPackageDescription[] getExportedPackages()Returns all exported packages in this state, according to the OSGi rules for resolution. -
getBundles
Returns all bundle descriptions with the given bundle symbolic name.- Parameters:
symbolicName
- symbolic name of the bundles to query- Returns:
- the descriptors for all bundles known to this state with the specified symbolic name.
-
getFactory
StateObjectFactory getFactory()Returns the factory that created this state.- Returns:
- the state object factory that created this state
-
linkDynamicImport
ExportPackageDescription linkDynamicImport(BundleDescription importingBundle, String requestedPackage) Attempts to find an ExportPackageDescription that will satisfy a dynamic import for the specified requestedPackage for the specified importingBundle. If no ExportPackageDescription is available that satisfies a dynamic import for the importingBundle thennull
is returned.- Parameters:
importingBundle
- the BundleDescription that is requesting a dynamic packagerequestedPackage
- the name of the package that is being requested- Returns:
- the ExportPackageDescription that satisfies the dynamic import
request; a value of
null
is returned if none is available.
-
addDynamicImportPackages
void addDynamicImportPackages(BundleDescription importingBundle, ImportPackageSpecification[] dynamicImports) Adds the specified dynamic imports to the specified importingBundle. The added dynamic imports are only valid for the instance of this state and will be forgotten if this state is read from a persistent cache.- Parameters:
importingBundle
- the bundle to add the imports to.dynamicImports
- the dynamic imports to add.- Since:
- 3.7
- See Also:
-
setPlatformProperties
Sets the platform properties of the state. The platform properties are used to resolve the following constraints:- The execution environment requirements (i.e. Bundle-RequiredExecutionEnvironment).
- The platform filter requirements (i.e. Eclipse-PlatformFilter).
- The native code requirements (i.e. Bundle-NativeCode).
- osgi.nl - the platform language setting.
- osgi.os - the platform operating system.
- osgi.arch - the platform architecture.
- osgi.ws - the platform windowing system.
- osgi.resolverMode - the resolver mode. A value of "strict" will set the resolver mode to strict.
- org.osgi.framework.system.packages - the packages exported by the system bundle.
- org.osgi.framework.executionenvironment - the comma separated list of supported execution environments. This property is then used to resolve the required execution environment the bundles in a state.
- org.osgi.framework.os.name - the name of the operating system. This property is used to resolve the osname attribute of bundle native code (i.e. Bundle-NativeCode).
- org.osgi.framework.os.version - the version of the operating system. This property is used to resolve the osversion attribute of bundle native code (i.e. Bundle-NativeCode).
- org.osgi.framework.processor - the processor name. This property is used to resolve the processor attribute of bundle native code (i.e. Bundle-NativeCode).
- org.osgi.framework.language - the language being used. This property is used to resolve the language attribute of bundle native code (i.e. Bundle-NativeCode).
String
type to specify a single value for the property or they can byString[]
to specify a list of values for the property.- Parameters:
platformProperties
- the platform properties of the state- Returns:
- false if the platformProperties specified do not change any of the supported properties already set. If any of the supported property values are changed as a result of calling this method then true is returned.
-
setPlatformProperties
Sets the platform properties of the state to a list of platform properties.- Parameters:
platformProperties
- a set of platform properties for the state- Returns:
- false if the platformProperties specified do not change any of the supported properties already set. If any of the supported property values are changed as a result of calling this method then true is returned.
- See Also:
-
getPlatformProperties
Dictionary[] getPlatformProperties()Returns the list of platform properties currently set for this state.- Returns:
- the list of platform properties currently set for this state.
-
getSystemPackages
ExportPackageDescription[] getSystemPackages()Returns the list of system packages which are exported by the system bundle. The list of system packages is set by the org.osgi.framework.system.packages value in the platform properties for this state.- Returns:
- the list of system packages
- See Also:
-
getStateHelper
StateHelper getStateHelper()Returns a state helper object. State helpers provide convenience methods for manipulating states.A possible implementation for this method would provide the same single StateHelper instance to all clients.
- Returns:
- a state helper
- Since:
- 3.2
- See Also:
-
getHighestBundleId
long getHighestBundleId()Returns the highest bundle ID. The value -1 is returned if no bundles exist in this state.Note that this method returns the highest bundle ID the ever existed in this this state object. This bundle may have been removed from the state.
- Returns:
- the highest bundle ID.
- Since:
- 3.3
-
setNativePathsInvalid
void setNativePathsInvalid(NativeCodeDescription nativeCodeDescription, boolean hasInvalidNativePaths) Sets the native code paths of a native code description as invalid. Native code paths are invalid if they can not be found in the bundle content.The framework, or some other entity which has access to bundle content, will call this method to validate or invalidate native code paths.
- Parameters:
nativeCodeDescription
- the native code description.hasInvalidNativePaths
- true if the native code paths are invalid; false otherwise.- Since:
- 3.4
-
getDisabledBundles
BundleDescription[] getDisabledBundles()Returns an array of BundleDescriptions for the bundles that are disabled in the system. UsegetDisabledInfos(BundleDescription)
to interrogate the reason that each bundle is disabled.- Returns:
- the array of disabled bundles. An empty array is returned if no bundles are disabled.
- Since:
- 3.4
- See Also:
-
addDisabledInfo
Adds the disabled info to this state. If a disable info already exists for the specified policy and the specified bundle then it is replaced with the given disabled info.- Parameters:
disabledInfo
- the disabled info to add.- Throws:
IllegalArgumentException
- if theBundleDescription
for the specified disabled info does not exist in this state.- Since:
- 3.4
-
removeDisabledInfo
Removes the disabled info from the state.- Parameters:
disabledInfo
- the disabled info to remove- Since:
- 3.4
-
getDisabledInfos
Returns an array of disabled info for the specified bundle. If no disabled info exist then an empty array is returned.- Parameters:
bundle
- the bundle to get the disabled info for.- Returns:
- the array of disabled info.
- Since:
- 3.4
-
getDisabledInfo
Returns the disabled info for the specified bundle with the specified policy name. If no disabled info exists thennull
is returned.- Parameters:
bundle
- the bundle to get the disabled info for- Returns:
- the disabled info.
- Since:
- 3.4
-
setResolverHookFactory
Sets the resolver hook factory for this state. The resolver hook factory is used during resolve operations according to the OSGi specification for the resolver hook factory.- Parameters:
hookFactory
- the resolver hook factory- Throws:
IllegalStateException
- if the resolver hook factory is already set- Since:
- 3.7
-
resolveBundle(BundleDescription, boolean, BundleDescription[], ExportPackageDescription[], ExportPackageDescription[], GenericDescription[], BundleDescription[], ExportPackageDescription[], GenericDescription[], Map)