Package org.eclipse.osgi.container
Class ModuleContainer
java.lang.Object
org.eclipse.osgi.container.ModuleContainer
- All Implemented Interfaces:
EventListener
,DebugOptionsListener
A container for installing, updating, uninstalling and resolve modules.
- Since:
- 3.10
-
Constructor Summary
ConstructorDescriptionModuleContainer
(ModuleContainerAdaptor adaptor, ModuleDatabase moduledataBase) Constructs a new container with the specified adaptor, module database. -
Method Summary
Modifier and TypeMethodDescriptionstatic Requirement
Creates a synthetic requirement that is not associated with any module revision.Returns the adaptor for this containergetDependencyClosure
(Collection<Module> initial) Returns the dependency closure of for the specified modules.Returns theFrameworkStartLevel
for this containerReturns theFrameworkWiring
for this containergetModule
(long id) Returns the module installed with the specified id, or null if no such module is installed.Returns the module installed with the specified location, or null if no such module is installed.Returns the list of currently installed modules sorted by module id.Returns the revisions that havenon-current
,in use
module wirings.int
Return the active start level value of this container.install
(Module origin, String location, ModuleRevisionBuilder builder, Object revisionInfo) Installs a new module using the specified location.void
optionsChanged
(DebugOptions options) Notifies this listener that an option-path for its plug-in has changed.refresh
(Collection<Module> initial) Refreshes the specified collection of modules.resolve
(Collection<Module> triggers, boolean triggersMandatory) Attempts to resolve the current revisions of the specified modules.resolveDynamic
(String dynamicPkgName, ModuleRevision revision) Attempts to resolve the specified dynamic package name request for the specified revision.void
Sets all the module states uninstalled except for the system module.void
store
(DataOutputStream stream, boolean persistWirings) Writes the data for this container in a format suitable for using theModuleDatabase.load(DataInputStream)
method.static String
toString
(Capability capability) Generates a human readable string representation of the the given capability, mapping the namespace to well-known header names.static String
toString
(Requirement requirement) Generates a human readable string representation of the the given requirement, mapping the namespace to well-known header names.static String
Generates a human readable string representation of the the givenResource
using the IDENTITY_NAMESPACEvoid
Uninstalls the specified module.void
update
(Module module, ModuleRevisionBuilder builder, Object revisionInfo) Updates the specified module with a new revision.
-
Constructor Details
-
ModuleContainer
Constructs a new container with the specified adaptor, module database.- Parameters:
adaptor
- the adaptor for the containermoduledataBase
- the module database
-
-
Method Details
-
getAdaptor
Returns the adaptor for this container- Returns:
- the adaptor for this container
-
getModules
Returns the list of currently installed modules sorted by module id.- Returns:
- the list of currently installed modules sorted by module id.
-
getModule
Returns the module installed with the specified id, or null if no such module is installed.- Parameters:
id
- the id of the module- Returns:
- the module with the specified id, or null of no such module is installed.
-
getModule
Returns the module installed with the specified location, or null if no such module is installed.- Parameters:
location
- the location of the module- Returns:
- the module with the specified location, or null of no such module is installed.
-
createRequirement
public static Requirement createRequirement(String namespace, Map<String, String> directives, Map<String, ?> attributes) Creates a synthetic requirement that is not associated with any module revision. This is useful for callingFrameworkWiring.findProviders(Requirement)
.- Parameters:
namespace
- the requirement namespacedirectives
- the requirement directivesattributes
- the requirement attributes- Returns:
- a synthetic requirement
-
toString
Generates a human readable string representation of the the given capability, mapping the namespace to well-known header names.- Parameters:
capability
- theCapability
for which a string representation is desired- Since:
- 3.19
-
toString
Generates a human readable string representation of the the givenResource
using the IDENTITY_NAMESPACE- Parameters:
resource
- theResource
for which a string representation is desired- Since:
- 3.22
-
toString
Generates a human readable string representation of the the given requirement, mapping the namespace to well-known header names.- Parameters:
requirement
- theRequirement
for which a string representation is desired- Since:
- 3.19
-
install
public Module install(Module origin, String location, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException Installs a new module using the specified location. The specified builder is used to create a newrevision
which will become thecurrent
revision of the new module.If a module already exists with the specified location then the existing module is returned and the builder is not used.
- Parameters:
origin
- the module performing the install, may benull
.location
- The location identifier of the module to install.builder
- the builder used to create the revision to install.revisionInfo
- the revision info for the new revision, may benull
.- Returns:
- a new module or a existing module if one exists at the specified location.
- Throws:
BundleException
- if some error occurs installing the module
-
update
public void update(Module module, ModuleRevisionBuilder builder, Object revisionInfo) throws BundleException Updates the specified module with a new revision. The specified builder is used to create a newrevision
which will become thecurrent
revision of the new module.- Parameters:
module
- the module to updatebuilder
- the builder used to create the revision for the update.revisionInfo
- the revision info for the new revision, may benull
.- Throws:
BundleException
- if some error occurs updating the module
-
uninstall
Uninstalls the specified module.- Parameters:
module
- the module to uninstall- Throws:
BundleException
- if some error occurs uninstalling the module
-
getFrameworkWiring
Returns theFrameworkWiring
for this container- Returns:
- the framework wiring for this container.
-
getFrameworkStartLevel
Returns theFrameworkStartLevel
for this container- Returns:
- the framework start level for this container
-
resolve
Attempts to resolve the current revisions of the specified modules.- Parameters:
triggers
- the modules to resolve ornull
to resolve all unresolved current revisions.triggersMandatory
- true if the triggers must be resolved. This will result in aResolutionException
if set to true and one of the triggers could not be resolved.- Returns:
- A resolution report for the resolve operation
- See Also:
-
resolveDynamic
Attempts to resolve the specified dynamic package name request for the specified revision.- Parameters:
dynamicPkgName
- the package name to attempt a dynamic resolution forrevision
- the module revision the dynamic resolution request is for- Returns:
- the new resolution wire establishing a dynamic package resolution or null if a dynamic wire could not be established.
-
refresh
Refreshes the specified collection of modules.- Parameters:
initial
- the modules to refresh ornull
to refresh the removal pending.- Returns:
- a resolution report for the resolve operation that may have occurred during the refresh operation.
- See Also:
-
getDependencyClosure
Returns the dependency closure of for the specified modules.- Parameters:
initial
- The initial modules for which to generate the dependency closure- Returns:
- A collection containing a snapshot of the dependency closure of the specified modules, or an empty collection if there were no specified modules.
-
getRemovalPending
Returns the revisions that havenon-current
,in use
module wirings.- Returns:
- A collection containing a snapshot of the revisions which have non-current, in use ModuleWirings, or an empty collection if there are no such revisions.
-
getStartLevel
public int getStartLevel()Return the active start level value of this container. If the container is in the process of changing the start level this method must return the active start level if this differs from the requested start level.- Returns:
- The active start level value of the Framework.
-
setInitialModuleStates
Sets all the module states uninstalled except for the system module.- Throws:
BundleException
-
optionsChanged
Description copied from interface:DebugOptionsListener
Notifies this listener that an option-path for its plug-in has changed. This method is also called initially by the DebugOptions implementation when the listener is registered as a service. This allows the listener to obtain the initial set of debug options without the need to acquire the debug options service.- Specified by:
optionsChanged
in interfaceDebugOptionsListener
- Parameters:
options
- a reference to the DebugOptions
-
store
Writes the data for this container in a format suitable for using theModuleDatabase.load(DataInputStream)
method.- Parameters:
stream
- the stream to usepersistWirings
- true if wirings should be persisted- Throws:
IOException
- if there is any problem storing to the stream- Since:
- 3.19
- See Also:
-