Qwylt

java.lang.module
Class ModuleArchive

java.lang.Object
  extended by java.lang.module.AttributeSource
      extended by java.lang.module.ModuleArchive
All Implemented Interfaces:
java.lang.reflect.AnnotatedElement

public abstract class ModuleArchive
extends AttributeSource
implements java.lang.reflect.AnnotatedElement

This class represents the data, both metadata and resources, of a module stored in a ModuleRepository.

Since:
Dec 10, 2008
Author:
Bryan Atsatt

Field Summary
 
Fields inherited from class java.lang.module.AttributeSource
NO_ATTRIBUTES, SERVICE_IMPLEMENTATION_KEY
 
Constructor Summary
ModuleArchive()
           
 
Method Summary
protected abstract  void close()
          Close this archive.
protected  Module createNewModule()
          Create a new Module instance.
 boolean equals(java.lang.Object other)
          Test if the specified object is equal to this instance, enforcing identity comparison.
<T extends java.lang.annotation.Annotation>
T
getAnnotation(java.lang.Class<T> annotationClass)
          Returns this element's annotation for the specified type if such an annotation is present, else null.
 java.lang.annotation.Annotation[] getAnnotations()
          Returns all annotations present on this element.
protected  java.lang.reflect.AnnotatedElement getAnnotationSource()
          Returns the AnnotatedElement instance to which the public AnnotatedElement methods will delegate.
 java.lang.annotation.Annotation[] getDeclaredAnnotations()
          Returns all annotations that are directly present on this element.
 ConnectionError getError()
          Returns the error if this Module failed during initialization.
abstract  Export getExport(ExportMatcher matcher)
          Returns the first Export matching the specified matcher.
abstract  Export getExport(ScopedName.Scope scope, java.lang.String name)
          Returns the first Export matching the specified scope and name.
abstract  java.util.List<? extends Export> getExports()
          Returns the direct exports of this ModuleArchive.
abstract  java.util.List<? extends Export> getExports(ExportMatcher matcher)
          Returns all Exports matching the specified matcher.
abstract  ModuleIdentity getIdentity()
          Returns the identity of this ModuleArchive.
 java.util.Set<ModuleArchive> getImported()
          Returns the imported ModuleArchives.
abstract  java.util.List<? extends Import> getImports()
          Returns the module imports of this ModuleArchive.
abstract  java.lang.String getMainClassName()
          Returns the name of the main class.
 Module getModule()
          Get the cached Module instance for this ModuleArchive, creating and initializing it if required.
 ModuleSystem getModuleSystem()
          Returns the ModuleSystem of this ModuleArchive.
 java.lang.String getName()
          Returns the name of this ModuleArchive.
abstract  ModuleRepository getRepository()
          Returns the ModuleRepository that contains this ModuleArchive.
abstract  java.util.List<? extends ModuleResources> getResources()
          Returns the list of resources of this ModuleArchive.
static ModuleArchive getRootArchive()
          Returns the root ModuleArchive, which is the sole exporter of packages with the "java." prefix.
abstract  ModuleState getState()
          TODO: change to 'module' access! Returns the state for this instance.
abstract  long getStorageSize()
          Returns the number of bytes required to store this archive.
 Version getVersion()
          Returns the version of this ModuleArchive.
 boolean hasExport(ExportMatcher matcher)
          Returns true if this ModuleArchive has a matching Export.
 int hashCode()
          Returns the identity hash code for this instance.
 boolean hasModule()
          Returns whether or not this ModuleArchive has a fully initialized Module instance.
 boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
          Returns true if an annotation for the specified type is present on this element, else false.
 Module newModule()
          Creates and returns a new Module instance from this archive.
abstract  boolean permitsImport(Import requestor)
          Returns true if this ModuleArchive may be imported by the specified import.
abstract  boolean permitsLocal(ModuleArchive requestor)
          Returns true if this ModuleArchive may be made local to the specified archive.
 void releaseModule(boolean disconnect)
          Release the cached Module so that the next call to getModule() will create a new instance.
 java.lang.String toString()
          Returns a string representation of this instance.
 
Methods inherited from class java.lang.module.AttributeSource
appendAttributes, asList, containsAttribute, containsAttributes, getAttribute, getAttributeAsList, getAttributeKeys, getAttributes, modifiableList, unmodifiableMap, unmodifiableMap
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModuleArchive

public ModuleArchive()
Method Detail

getRootArchive

public static ModuleArchive getRootArchive()
Returns the root ModuleArchive, which is the sole exporter of packages with the "java." prefix.

Returns:
The root ModuleArchive.

getName

public java.lang.String getName()
Returns the name of this ModuleArchive.

Specified by:
getName in class AttributeSource
Returns:
The name.

getVersion

public Version getVersion()
Returns the version of this ModuleArchive.

Returns:
The Version.

getIdentity

public abstract ModuleIdentity getIdentity()
Returns the identity of this ModuleArchive.

Returns:
The ModuleIdentity.

getModuleSystem

public ModuleSystem getModuleSystem()
Returns the ModuleSystem of this ModuleArchive.

Returns:
The ModuleSystem.

getImports

public abstract java.util.List<? extends Import> getImports()
Returns the module imports of this ModuleArchive.

Returns:
The unmodifiable list of Imports.

getExport

public abstract Export getExport(ScopedName.Scope scope,
                                 java.lang.String name)
Returns the first Export matching the specified scope and name.

Parameters:
scope - The scope for the name.
name -
Returns:
The Export or null if not found.

getExport

public abstract Export getExport(ExportMatcher matcher)
Returns the first Export matching the specified matcher.

Parameters:
matcher - The matcher.
Returns:
The Export or null if not found.

hasExport

public boolean hasExport(ExportMatcher matcher)
Returns true if this ModuleArchive has a matching Export.

Parameters:
matcher - The matcher.
Returns:
true if a matching Export is found, false otherwise.

getExports

public abstract java.util.List<? extends Export> getExports(ExportMatcher matcher)
Returns all Exports matching the specified matcher.

Parameters:
matcher - The matcher.
Returns:
The Exports, empty if none.

getExports

public abstract java.util.List<? extends Export> getExports()
Returns the direct exports of this ModuleArchive.

Returns:
The unmodifiable set of Exports, including an entry for this archive itself (Scope == MODULE).

getRepository

public abstract ModuleRepository getRepository()
Returns the ModuleRepository that contains this ModuleArchive.

Returns:
The repository.

getResources

public abstract java.util.List<? extends ModuleResources> getResources()
Returns the list of resources of this ModuleArchive.

Returns:
The unmodifiable list of module resources, empty if none.

getMainClassName

public abstract java.lang.String getMainClassName()
Returns the name of the main class.

Returns:
The main class name or null if none.

getStorageSize

public abstract long getStorageSize()
Returns the number of bytes required to store this archive.

Returns:
The size.

hasModule

public boolean hasModule()
Returns whether or not this ModuleArchive has a fully initialized Module instance.

Returns:
true if this ModuleArchive has a fully initialized Module instance; otherwise, returns false.

getModule

public final Module getModule()
Get the cached Module instance for this ModuleArchive, creating and initializing it if required. The calling thread will block until initialization is completed.

Returns:
The fully initialized Module instance.
Throws:
ConnectionError - if the the instance does not already exist and initialization fails.

releaseModule

public final void releaseModule(boolean disconnect)
Release the cached Module so that the next call to getModule() will create a new instance.

Parameters:
disconnect - true iff the state should also be disconnected so that subsequent instances will be re-connected.

newModule

public final Module newModule()
Creates and returns a new Module instance from this archive. The result is not cached and is therefore guaranteed never to be the same as that returned by getModule().

Returns:
The new Module instance.
Throws:
ConnectionError - if initialization fails.

getError

public ConnectionError getError()
Returns the error if this Module failed during initialization.

Returns:
ConnectionError if initialization failed; otherwise, returns null.

getImported

public java.util.Set<ModuleArchive> getImported()
Returns the imported ModuleArchives.

Throws:
ConnectionError - if initialization fails.

permitsImport

public abstract boolean permitsImport(Import requestor)
Returns true if this ModuleArchive may be imported by the specified import.

Parameters:
requestor - The requesting import.
Returns:
true if this archive can be imported by the requestor, false if not.

permitsLocal

public abstract boolean permitsLocal(ModuleArchive requestor)
Returns true if this ModuleArchive may be made local to the specified archive.

Parameters:
requestor - The requesting archive.
Returns:
true if this archive can be made local to the requestor, false if not.

getState

public abstract ModuleState getState()
TODO: change to 'module' access! Returns the state for this instance.

Returns:
The state.

equals

public final boolean equals(java.lang.Object other)
Test if the specified object is equal to this instance, enforcing identity comparison.

Overrides:
equals in class java.lang.Object
Parameters:
other - The object to compare to.
Returns:
true if other is the same as this instance; otherwise, returns false.

hashCode

public final int hashCode()
Returns the identity hash code for this instance.

Overrides:
hashCode in class java.lang.Object
Returns:
The identity hash code for this instance.

toString

public java.lang.String toString()
Returns a string representation of this instance.

Overrides:
toString in class java.lang.Object
Returns:
The string.

isAnnotationPresent

public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Returns true if an annotation for the specified type is present on this element, else false. This method is designed primarily for convenient access to marker annotations.

Specified by:
isAnnotationPresent in interface java.lang.reflect.AnnotatedElement
Parameters:
annotationClass - the Class object corresponding to the annotation type
Returns:
true if an annotation for the specified annotation type is present on this element, else false
Throws:
java.lang.NullPointerException - if the given annotation class is null
Since:
1.5

getAnnotation

public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationClass)
Returns this element's annotation for the specified type if such an annotation is present, else null.

Specified by:
getAnnotation in interface java.lang.reflect.AnnotatedElement
Parameters:
annotationClass - the Class object corresponding to the annotation type
Returns:
this element's annotation for the specified annotation type if present on this element, else null
Throws:
java.lang.NullPointerException - if the given annotation class is null
Since:
1.5

getAnnotations

public java.lang.annotation.Annotation[] getAnnotations()
Returns all annotations present on this element. (Returns an array of length zero if this element has no annotations.) The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Specified by:
getAnnotations in interface java.lang.reflect.AnnotatedElement
Returns:
all annotations present on this element
Since:
1.5

getDeclaredAnnotations

public java.lang.annotation.Annotation[] getDeclaredAnnotations()
Returns all annotations that are directly present on this element. Unlike the other methods in this interface, this method ignores inherited annotations. (Returns an array of length zero if no annotations are directly present on this element.) The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.

Specified by:
getDeclaredAnnotations in interface java.lang.reflect.AnnotatedElement
Returns:
All annotations directly present on this element
Since:
1.5

getAnnotationSource

protected java.lang.reflect.AnnotatedElement getAnnotationSource()
Returns the AnnotatedElement instance to which the public AnnotatedElement methods will delegate. The default implementation of this method returns an instance with no annotations.

Returns:
The AnnotatedElement instance.

createNewModule

protected Module createNewModule()
Create a new Module instance.

Returns:
A new instance.

close

protected abstract void close()
Close this archive.


Qwylt

Send comments or questions to Bryan Atsatt