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
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enumeration of persistent settings for a modulestatic enumThe possible start options for a modulestatic enumAn enumeration of the possiblestatesa module may be in.static enumThe possible start options for a module -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final EnumSet<Module.State>A set ofstatesthat indicate a module is active.static final EnumSet<Module.State>A set ofstatesthat indicate a module is resolved. -
Constructor Summary
ConstructorsConstructorDescriptionModule(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 voidcleanup(ModuleRevision revision) The container is done with the revision and it has been completely removed.final intfinal ModuleContainerReturns the module container this module is contained in.final ModuleRevisionReturns the currentrevisionassociated with this module.final LonggetId()Returns the module id.final longReturns the time when this module was last modified.final StringReturns the module locationfinal ModuleRevisionsReturns theModuleRevisionsassociated with this module.final intfinal Module.StategetState()Returns the currentstateof this module.final ThreadReturns the thread that currently owns the state change lock for this module, ornullif not owned.final booleanholdsTransitionEventLock(ModuleContainerAdaptor.ModuleEvent transitionEvent) Returns true if the current thread holds the state change lock for the specified transition event.final booleanbooleanReturns if this module should be activated in parallel with other modules that have the samestart level.final booleanprotected final voidlockStateChange(ModuleContainerAdaptor.ModuleEvent transitionEvent) Acquires the module lock for state changes by the current thread for the specified transition event.voidsetParallelActivation(boolean parallelActivation) Set if this module should be activated in parallel with other modules that have the samestart level.final voidsetStartLevel(int startLevel) voidstart(Module.StartOptions... options) Starts this moduleprotected voidPerforms any work associated with starting a module.voidstop(Module.StopOptions... options) Stops this module.protected voidPerforms any work associated with stopping a module.toString()protected final voidunlockStateChange(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, waitMethods 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 benullif 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 theModuleRevisionsassociated with this module.- Returns:
- the
ModuleRevisionsassociated with this module
-
getContainer
Returns the module container this module is contained in.- Returns:
- the module container.
-
getCurrentRevision
Returns the currentrevisionassociated with this module. If the module is uninstalled then the last current revision is returned.- Returns:
- the current
revisionassociated with this module.
-
getState
Returns the currentstateof this module.- Returns:
- the current state of this module.
-
getStartLevel
public final int getStartLevel()- Specified by:
getStartLevelin interfaceBundleStartLevel
-
setStartLevel
public final void setStartLevel(int startLevel) - Specified by:
setStartLevelin interfaceBundleStartLevel
-
isPersistentlyStarted
public final boolean isPersistentlyStarted()- Specified by:
isPersistentlyStartedin interfaceBundleStartLevel
-
isActivationPolicyUsed
public final boolean isActivationPolicyUsed()- Specified by:
isActivationPolicyUsedin 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, ornullif not owned.- Returns:
- the owner, or
nullif 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:
compareToin 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
-