Package org.eclipse.osgi.container
Class Module
java.lang.Object
org.eclipse.osgi.container.Module
- All Implemented Interfaces:
Comparable<Module>
,BundleReference
,BundleStartLevel
- Direct Known Subclasses:
SystemModule
public abstract class Module
extends Object
implements BundleReference, BundleStartLevel, Comparable<Module>
A module represents a set of revisions installed in a module
container
.- Since:
- 3.10
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enumeration of persistent settings for a modulestatic enum
The possible start options for a modulestatic enum
An enumeration of the possiblestates
a module may be in.static enum
The possible start options for a module -
Field Summary
Modifier and TypeFieldDescriptionstatic final EnumSet<Module.State>
A set ofstates
that indicate a module is active.static final EnumSet<Module.State>
A set ofstates
that indicate a module is resolved. -
Constructor Summary
ConstructorDescriptionModule
(Long id, String location, ModuleContainer container, EnumSet<Module.Settings> settings, int startlevel) Constructs a new module with the specified id, location and container. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
cleanup
(ModuleRevision revision) The container is done with the revision and it has been completely removed.final int
final ModuleContainer
Returns the module container this module is contained in.final ModuleRevision
Returns the currentrevision
associated with this module.final Long
getId()
Returns the module id.final long
Returns the time when this module was last modified.final String
Returns the module locationfinal ModuleRevisions
Returns theModuleRevisions
associated with this module.final int
final Module.State
getState()
Returns the currentstate
of this module.final Thread
Returns the thread that currently owns the state change lock for this module, ornull
if not owned.final boolean
holdsTransitionEventLock
(ModuleContainerAdaptor.ModuleEvent transitionEvent) Returns true if the current thread holds the state change lock for the specified transition event.final boolean
boolean
Returns if this module should be activated in parallel with other modules that have the samestart level
.final boolean
protected final void
lockStateChange
(ModuleContainerAdaptor.ModuleEvent transitionEvent) Acquires the module lock for state changes by the current thread for the specified transition event.void
setParallelActivation
(boolean parallelActivation) Set if this module should be activated in parallel with other modules that have the samestart level
.final void
setStartLevel
(int startLevel) void
start
(Module.StartOptions... options) Starts this moduleprotected void
Performs any work associated with starting a module.void
stop
(Module.StopOptions... options) Stops this module.protected void
Performs any work associated with stopping a module.toString()
protected final void
unlockStateChange
(ModuleContainerAdaptor.ModuleEvent transitionEvent) Releases the lock for state changes for the specified transition event.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.osgi.framework.BundleReference
getBundle
-
Field Details
-
Constructor Details
-
Module
public Module(Long id, String location, ModuleContainer container, EnumSet<Module.Settings> settings, int startlevel) Constructs a new module with the specified id, location and container.- Parameters:
id
- the new module idlocation
- the new module locationcontainer
- the container for the new modulesettings
- the persisted settings. May benull
if there are no settings.startlevel
- the persisted start level or initial start level.
-
-
Method Details
-
getId
Returns the module id.- Returns:
- the module id.
-
getLocation
Returns the module location- Returns:
- the module location
-
getRevisions
Returns theModuleRevisions
associated with this module.- Returns:
- the
ModuleRevisions
associated with this module
-
getContainer
Returns the module container this module is contained in.- Returns:
- the module container.
-
getCurrentRevision
Returns the currentrevision
associated with this module. If the module is uninstalled then the last current revision is returned.- Returns:
- the current
revision
associated with this module.
-
getState
Returns the currentstate
of this module.- Returns:
- the current state of this module.
-
getStartLevel
public final int getStartLevel()- Specified by:
getStartLevel
in interfaceBundleStartLevel
-
setStartLevel
public final void setStartLevel(int startLevel) - Specified by:
setStartLevel
in interfaceBundleStartLevel
-
isPersistentlyStarted
public final boolean isPersistentlyStarted()- Specified by:
isPersistentlyStarted
in interfaceBundleStartLevel
-
isActivationPolicyUsed
public final boolean isActivationPolicyUsed()- Specified by:
isActivationPolicyUsed
in interfaceBundleStartLevel
-
getLastModified
public final long getLastModified()Returns the time when this module was last modified. A module is considered to be modified when it is installed, updated or uninstalled.The time value is a the number of milliseconds since January 1, 1970, 00:00:00 UTC.
- Returns:
- the time when this bundle was last modified.
-
lockStateChange
protected final void lockStateChange(ModuleContainerAdaptor.ModuleEvent transitionEvent) throws BundleException Acquires the module lock for state changes by the current thread for the specified transition event. Certain transition events locks may be nested within other transition event locks. For example, a resolved transition event lock may be nested within a started transition event lock. A stopped transition lock may be nested within an updated, unresolved or uninstalled transition lock.- Parameters:
transitionEvent
- the transition event to acquire the lock for.- Throws:
BundleException
-
unlockStateChange
Releases the lock for state changes for the specified transition event. -
holdsTransitionEventLock
Returns true if the current thread holds the state change lock for the specified transition event.- Returns:
- true if the current thread holds the state change lock for the specified transition event.
-
getStateChangeOwner
Returns the thread that currently owns the state change lock for this module, ornull
if not owned.- Returns:
- the owner, or
null
if not owned.
-
start
Starts this module- Parameters:
options
- the options for starting- Throws:
BundleException
- if an errors occurs while starting
-
stop
Stops this module.- Parameters:
options
- options for stopping- Throws:
BundleException
- if an error occurs while stopping
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Module>
-
startWorker
Performs any work associated with starting a module. For example, loading and calling start on an activator.- Throws:
BundleException
- if there was an exception starting the module
-
stopWorker
Performs any work associated with stopping a module. For example, calling stop on an activator.- Throws:
BundleException
- if there was an exception stopping the module
-
toString
-
setParallelActivation
public void setParallelActivation(boolean parallelActivation) Set if this module should be activated in parallel with other modules that have the samestart level
.- Parameters:
parallelActivation
- true if the module should be started in parallel; false otherwise- Since:
- 3.15
-
isParallelActivated
public boolean isParallelActivated()Returns if this module should be activated in parallel with other modules that have the samestart level
.- Returns:
- true if the module should be started in parallel; false otherwise
- Since:
- 3.15
-
cleanup
The container is done with the revision and it has been completely removed. This method allows the resources behind the revision to be cleaned up.- Parameters:
revision
- the revision to clean up
-