org.netbeans.bootstrap/1 2.52

org.netbeans
Class Module

java.lang.Object
  extended by org.openide.modules.ModuleInfo
      extended by org.netbeans.Module
Direct Known Subclasses:
JaveleonModule

public abstract class Module
extends ModuleInfo

Object representing one module, possibly installed. Responsible for opening of module JAR file; reading manifest; parsing basic information such as dependencies; and creating a classloader for use by the installer. Methods not defined in ModuleInfo must be called from within the module manager's read mutex as a rule.

Since:
2.1 the class was made public abstract

Nested Class Summary
static class Module.PackageExport
          Struct representing a package exported from a module.
 
Field Summary
protected  ClassLoader classloader
          currently active module classloader
protected  Events events
          event logging (should not be much here)
protected  ModuleManager mgr
          manager which owns this module
static String PROP_CLASS_LOADER
           
static String PROP_MANIFEST
           
static String PROP_PROBLEMS
           
static String PROP_RELOADABLE
           
static String PROP_VALID
           
protected  boolean reloadable
           
 
Fields inherited from class org.openide.modules.ModuleInfo
PROP_ENABLED
 
Constructor Summary
protected Module(ModuleManager mgr, Events ev, Object history, boolean reloadable, boolean autoload, boolean eager)
          Use ModuleManager.create as a factory.
protected Module(ModuleManager mgr, Events ev, Object history, ClassLoader classloader)
          Create a special-purpose "fixed" JAR.
protected Module(ModuleManager mgr, Events ev, Object history, ClassLoader classloader, boolean autoload, boolean eager)
          Create a special-purpose "fixed" JAR which may nonetheless be marked eager or autoload.
 
Method Summary
protected abstract  void classLoaderDown()
          Turn off the classloader and release all resources.
protected abstract  void classLoaderUp(Set<Module> parents)
          Turn on the classloader.
protected abstract  void cleanup()
          Should be called after turning off the classloader of one or more modules & GC'ing.
protected abstract  void destroy()
          Notify the module that it is being deleted.
 Enumeration<URL> findResources(String resources)
          Locates resource in this module.
abstract  List<File> getAllJars()
          Get all JARs loaded by this module.
 Object getAttribute(String attr)
          Get an associated arbitrary attribute.
 String getBuildVersion()
           
 ClassLoader getClassLoader()
           
 String getCodeName()
           
 String getCodeNameBase()
           
 int getCodeNameRelease()
           
 Set<Dependency> getDependencies()
           
 Dependency[] getDependenciesArray()
           
 Object getHistory()
          Get the history object representing what has happened to this module before.
 String getImplementationVersion()
           
 File getJarFile()
          Get the JAR this module is packaged in.
 ModuleManager getManager()
          Get the associated module manager.
abstract  Manifest getManifest()
          Get the JAR manifest.
 Set<Object> getProblems()
          Get a set of Dependency objects representing missed dependencies.
 String[] getProvides()
           
 Module.PackageExport[] getPublicPackages()
          Get all packages exported by this module to other modules.
 SpecificationVersion getSpecificationVersion()
           
 int getStartLevel()
          Finds out if a module has been assigned with a specific start level.
 boolean isAutoload()
          Is this module automatically loaded? If so, no information about its state is kept permanently beyond the existence of its JAR file; it is enabled when some real module needs it to be, and disabled when this is no longer the case.
 boolean isEager()
          Is this module eagerly enabled? If so, no information about its state is kept permanently.
 boolean isEnabled()
           
abstract  boolean isFixed()
          Fixed modules are treated differently.
 boolean isNetigso()
          Is this module a wrapper around OSGi?
 boolean isReloadable()
          Is this module supposed to be easily reloadable? If so, it is suitable for testing inside the IDE.
 boolean isValid()
          Normally a module once created and managed is valid (that is, either installed or not, but at least managed).
 boolean owns(Class<?> clazz)
           
protected  void parseManifest()
          Parse information from the current manifest.
 boolean provides(String token)
          Test whether the module provides a given token or not.
 void releaseManifest()
          Release memory storage for the JAR manifest, if applicable.
abstract  void reload()
          Reload this module.
abstract  void setReloadable(boolean r)
          Set whether this module is supposed to be reloadable.
 String toString()
          String representation for debugging.
 
Methods inherited from class org.openide.modules.ModuleInfo
addPropertyChangeListener, firePropertyChange, getDisplayName, getLocalizedAttribute, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_RELOADABLE

public static final String PROP_RELOADABLE
See Also:
Constant Field Values

PROP_CLASS_LOADER

public static final String PROP_CLASS_LOADER
See Also:
Constant Field Values

PROP_MANIFEST

public static final String PROP_MANIFEST
See Also:
Constant Field Values

PROP_VALID

public static final String PROP_VALID
See Also:
Constant Field Values

PROP_PROBLEMS

public static final String PROP_PROBLEMS
See Also:
Constant Field Values

mgr

protected final ModuleManager mgr
manager which owns this module


events

protected final Events events
event logging (should not be much here)


reloadable

protected boolean reloadable

classloader

protected ClassLoader classloader
currently active module classloader

Constructor Detail

Module

protected Module(ModuleManager mgr,
                 Events ev,
                 Object history,
                 boolean reloadable,
                 boolean autoload,
                 boolean eager)
          throws IOException
Use ModuleManager.create as a factory.

Throws:
IOException

Module

protected Module(ModuleManager mgr,
                 Events ev,
                 Object history,
                 ClassLoader classloader)
          throws InvalidException
Create a special-purpose "fixed" JAR.

Throws:
InvalidException

Module

protected Module(ModuleManager mgr,
                 Events ev,
                 Object history,
                 ClassLoader classloader,
                 boolean autoload,
                 boolean eager)
          throws InvalidException
Create a special-purpose "fixed" JAR which may nonetheless be marked eager or autoload.

Throws:
InvalidException
Since:
2.7
Method Detail

getManager

public ModuleManager getManager()
Get the associated module manager.


isEnabled

public boolean isEnabled()
Specified by:
isEnabled in class ModuleInfo

isValid

public boolean isValid()
Normally a module once created and managed is valid (that is, either installed or not, but at least managed). If it is deleted any remaining references to it become invalid.


isAutoload

public boolean isAutoload()
Is this module automatically loaded? If so, no information about its state is kept permanently beyond the existence of its JAR file; it is enabled when some real module needs it to be, and disabled when this is no longer the case.

See Also:
#9779

isEager

public boolean isEager()
Is this module eagerly enabled? If so, no information about its state is kept permanently. It is turned on whenever it can be, i.e. whenever it meets all of its dependencies. This may be used to implement "bridge" modules with simple functionality that just depend on two normal modules. A module may not be simultaneously eager and autoload.

Since:
org.netbeans.core/1 1.3
See Also:
#17501

getAttribute

public Object getAttribute(String attr)
Get an associated arbitrary attribute. Right now, simply provides the main attributes of the manifest. In the future some of these could be suppressed (if only of dangerous interest, e.g. Class-Path) or enhanced with other information available from the core (if needed).

Specified by:
getAttribute in class ModuleInfo

getCodeName

public String getCodeName()
Specified by:
getCodeName in class ModuleInfo

getCodeNameBase

public String getCodeNameBase()
Specified by:
getCodeNameBase in class ModuleInfo

getCodeNameRelease

public int getCodeNameRelease()
Specified by:
getCodeNameRelease in class ModuleInfo

getProvides

public String[] getProvides()
Overrides:
getProvides in class ModuleInfo

provides

public final boolean provides(String token)
Test whether the module provides a given token or not.

Since:
JST-PENDING again used from NbProblemDisplayer

getDependencies

public Set<Dependency> getDependencies()
Specified by:
getDependencies in class ModuleInfo

getDependenciesArray

public final Dependency[] getDependenciesArray()

getSpecificationVersion

public SpecificationVersion getSpecificationVersion()
Specified by:
getSpecificationVersion in class ModuleInfo

getImplementationVersion

public String getImplementationVersion()
Overrides:
getImplementationVersion in class ModuleInfo

getBuildVersion

public String getBuildVersion()
Overrides:
getBuildVersion in class ModuleInfo

owns

public boolean owns(Class<?> clazz)
Specified by:
owns in class ModuleInfo

getPublicPackages

public Module.PackageExport[] getPublicPackages()
Get all packages exported by this module to other modules.

Returns:
a list (possibly empty) of exported packages, or null to export everything
Since:
org.netbeans.core/1 > 1.4
See Also:
"#19621"

parseManifest

protected void parseManifest()
                      throws InvalidException
Parse information from the current manifest. Includes code name, specification version, and dependencies. If anything is in an invalid format, throws an exception with some kind of description of the problem.

Throws:
InvalidException

getAllJars

public abstract List<File> getAllJars()
Get all JARs loaded by this module. Includes the module itself, any locale variants of the module, any extensions specified with Class-Path, any locale variants of those extensions. The list will be in classpath order (patches first). Currently the temp JAR is provided in the case of test modules, to prevent sporadic ZIP file exceptions when background threads (like Java parsing) tries to open libraries found in the library path. JARs already present in the classpath are not listed.

Returns:
a list of JARs

isReloadable

public boolean isReloadable()
Is this module supposed to be easily reloadable? If so, it is suitable for testing inside the IDE. Controls whether a copy of the JAR file is made before passing it to the classloader, which can affect locking and refreshing of the JAR.


setReloadable

public abstract void setReloadable(boolean r)
Set whether this module is supposed to be reloadable. Has no immediate effect, only impacts what happens the next time it is enabled (after having been disabled if necessary). Must be called from within a write mutex.

Parameters:
r - whether the module should be considered reloadable

reload

public abstract void reload()
                     throws IOException
Reload this module. Access from ModuleManager. If an exception is thrown, the module is considered to be in an invalid state.

Throws:
IOException
Since:
JST-PENDING: needed from ModuleSystem

getClassLoader

public ClassLoader getClassLoader()
                           throws IllegalArgumentException
Overrides:
getClassLoader in class ModuleInfo
Throws:
IllegalArgumentException

classLoaderUp

protected abstract void classLoaderUp(Set<Module> parents)
                               throws IOException
Turn on the classloader. Passed a list of parent modules to use. The parents should already have had their classloaders initialized.

Throws:
IOException

classLoaderDown

protected abstract void classLoaderDown()
Turn off the classloader and release all resources.


cleanup

protected abstract void cleanup()
Should be called after turning off the classloader of one or more modules & GC'ing.


destroy

protected abstract void destroy()
Notify the module that it is being deleted.


isFixed

public abstract boolean isFixed()
Fixed modules are treated differently.

See Also:
FixedModule

getJarFile

public File getJarFile()
Get the JAR this module is packaged in. May be null for modules installed specially, e.g. automatically from the classpath.

See Also:
isFixed()

getManifest

public abstract Manifest getManifest()
Get the JAR manifest. Should never be null, even if disabled. Might change if a module is reloaded. It is not guaranteed that change events will be fired for changes in this property.


releaseManifest

public void releaseManifest()
Release memory storage for the JAR manifest, if applicable.


getProblems

public Set<Object> getProblems()
Get a set of Dependency objects representing missed dependencies. This module is examined to see why it would not be installable. If it is enabled, there are no problems. If it is in fact installable (possibly only by also enabling some other managed modules which are currently disabled), and all of its non-module dependencies are met, the returned set will be empty. Otherwise it will contain a list of reasons why this module cannot be installed: non-module dependencies which are not met; and module dependencies on modules which either do not exist in the managed set, or are the wrong version, or themselves cannot be installed for some reason or another (which may be separately examined). Note that in the (illegal) situation of two or more modules forming a cyclic dependency cycle, none of them will be installable, and the missing dependencies for each will be stated as the dependencies on the others. Again other modules dependent on modules in the cycle will list failed dependencies on the cyclic modules. Missing package dependencies are not guaranteed to be reported unless an install of the module has already been attempted, and failed due to them. The set may also contain InvalidExceptions representing known failures of the module to be installed, e.g. due to classloader problems, missing runtime resources, or failed ad-hoc dependencies. Again these are not guaranteed to be reported unless an install has already been attempted and failed due to them.


getHistory

public final Object getHistory()
Get the history object representing what has happened to this module before.

See Also:
org.netbeans.core.startup.ModuleHistory

getStartLevel

public final int getStartLevel()
Finds out if a module has been assigned with a specific start level. Start level is only useful for OSGi bundles. Otherwise it is always zero.

Returns:
-1, if no specific level is assigned, non-negative integer if so
Since:
2.43

toString

public String toString()
String representation for debugging.

Overrides:
toString in class Object

findResources

public Enumeration<URL> findResources(String resources)
Locates resource in this module. May search only the main JAR of the module (which is what it does in case of OSGi bundles). Should be as lightweight as possible - e.g. if it is OK to not initialize something in the module while perfoming this method, the something should not be initialized (e.g. OSGi bundles are not resolved).

Parameters:
resources - path to the resources we are looking for
Since:
2.49

isNetigso

public final boolean isNetigso()
Is this module a wrapper around OSGi?

Returns:
true, if the module is build around OSGi
Since:
2.51

org.netbeans.bootstrap/1 2.52

Built on May 22 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.