Package gw.internal.gosu.module
Class Module
java.lang.Object
gw.internal.gosu.module.Module
- All Implemented Interfaces:
IModule
- Direct Known Subclasses:
GlobalModule
,JreModule
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Singleton extension classloader. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<IDirectory>
private List<IDirectory>
private List<Dependency>
private final IExecutionEnvironment
private ClassLoader
private final IFileSystemGosuClassRepository
private ModuleTypeLoader
private ClassLoader
private INativeModule
private String
private LocklessLazyVar<IModule[]>
Fields inherited from interface gw.lang.reflect.module.IModule
CONFIG_RESOURCE_PREFIX
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
private List<IDirectory>
addFromManifestClassPath
(List<IDirectory> classpath) This will add items to the Gosu classpath, but only under very specific circumstances.private IModule[]
void
configurePaths
(List<IDirectory> classpath, List<IDirectory> sourcePaths, List<IDirectory> backingSourcePaths) Configure both source and Java classpaths of the module in a semi-automated way.private ITypeLoader
createAndPushTypeLoader
(IFileSystemGosuClassRepository classRepository, String className) protected void
protected void
protected void
void
boolean
protected List<IDirectory>
private Constructor
getConstructor
(Class<?> loaderClass, Class... argTypes) final IExecutionEnvironment
private ClassLoader
private URL[]
Get class loader, associated with this module.final IModule[]
getName()
<T extends ITypeLoader>
List<? extends T>getTypeLoaders
(Class<T> typeLoaderClass) Returns typeloaders of the given class that are local to this module as well as such typeloaders from dependent modules.int
hashCode()
void
protected void
void
private static void
scanPaths
(List<IDirectory> paths, Set<String> extensions, List<IDirectory> roots) void
setBackingSourcePath
(List<IDirectory> backingSourcePath) void
setDependencies
(List<Dependency> newDeps) void
setExcludedPaths
(List<IDirectory> paths) void
setJavaClassPath
(List<IDirectory> classpath) void
setModuleTypeLoader
(ModuleTypeLoader modTypeLoader) void
void
setNativeModule
(INativeModule nativeModule) void
setSourcePath
(List<IDirectory> sourcePaths) toString()
protected void
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface gw.lang.reflect.module.IModule
configurePaths
-
Field Details
-
_execEnv
-
_strName
-
_dependencies
-
_traversalList
-
_modTypeLoader
-
_classpath
-
_backingSourcePath
-
_nativeModule
-
_moduleClassLoader
-
_extensionsClassLoader
-
_fileRepository
-
-
Constructor Details
-
Module
-
-
Method Details
-
getExecutionEnvironment
- Specified by:
getExecutionEnvironment
in interfaceIModule
-
getFileRepository
- Specified by:
getFileRepository
in interfaceIModule
-
setDependencies
- Specified by:
setDependencies
in interfaceIModule
-
getDependencies
- Specified by:
getDependencies
in interfaceIModule
- Returns:
- A list of dependencies for this module. The list may contain both libraries and other modules. The dependency graph must not have cycles.
-
addDependency
- Specified by:
addDependency
in interfaceIModule
-
removeDependency
- Specified by:
removeDependency
in interfaceIModule
-
getSourcePath
- Specified by:
getSourcePath
in interfaceIModule
- Returns:
- The path[s] having source files that should be exposed to this module.
-
setSourcePath
- Specified by:
setSourcePath
in interfaceIModule
-
getExcludedPaths
- Specified by:
getExcludedPaths
in interfaceIModule
-
setExcludedPaths
- Specified by:
setExcludedPaths
in interfaceIModule
-
getModuleClassLoader
Description copied from interface:IModule
Get class loader, associated with this module.- Specified by:
getModuleClassLoader
in interfaceIModule
- Returns:
-
disposeLoader
public void disposeLoader()- Specified by:
disposeLoader
in interfaceIModule
-
scanPaths
private static void scanPaths(List<IDirectory> paths, Set<String> extensions, List<IDirectory> roots) -
getOutputPath
- Specified by:
getOutputPath
in interfaceIModule
-
getModuleTypeLoader
- Specified by:
getModuleTypeLoader
in interfaceIModule
-
setModuleTypeLoader
-
configurePaths
public void configurePaths(List<IDirectory> classpath, List<IDirectory> sourcePaths, List<IDirectory> backingSourcePaths) Description copied from interface:IModule
Configure both source and Java classpaths of the module in a semi-automated way. First parameter is Java classpath. Second parameter is extended with all paths from Java classpath that are marked to have Gosu "sources" (through MANIFEST.MF with Contains-Sources header) and used as Gosu source path.- Specified by:
configurePaths
in interfaceIModule
- Parameters:
classpath
- path to types not directly in the module's sources e.g., jar files containing .class files and other types/resourcessourcePaths
- path to the sources directly defined in this module; sources in this path are statically compiled as part of this module's build target e.g., ./src directoriesbackingSourcePaths
- path to sources corresponding with the classpath parameter (intended for IDE use)
-
addFromManifestClassPath
This will add items to the Gosu classpath, but only under very specific circumstances.
If both of the following conditions are met:
- The JAR's manifest contains a Class-Path entry
- The Class-Path entry contains a space-delimited list of URIs
Then the entries will be parsed and added to the Gosu classpath.
This logic also handles strange libraries packaged pre-Maven such as xalan:xalan:2.4.1
The xalan JAR above has a Class-Path attribute referencing the following:
Class-Path: xercesImpl.jar xml-apis.jar
These unqualified references should have been resolved by the build tooling, and if we try to interfere and resolve the references, we may cause classpath confusion. Therefore any Class-Path entry not resolvable to an absolute path on disk (and, therefore, can be listed as a URL) will be skipped.- Parameters:
classpath
- The module's Java classpath- Returns:
- The original classpath, possibly with dependencies listed in JAR manifests Class-Path extracted and explicitly listed
- See Also:
-
getJavaClassPath
- Specified by:
getJavaClassPath
in interfaceIModule
-
setJavaClassPath
- Specified by:
setJavaClassPath
in interfaceIModule
-
getBackingSourcePath
- Specified by:
getBackingSourcePath
in interfaceIModule
-
setBackingSourcePath
- Specified by:
setBackingSourcePath
in interfaceIModule
-
toString
-
getNativeModule
- Specified by:
getNativeModule
in interfaceIModule
- Returns:
- The module/project from the execution environment that corresponds with this logical module. For example, in Eclipse the native module is of type IJavaProject.
-
setNativeModule
- Specified by:
setNativeModule
in interfaceIModule
-
initializeTypeLoaders
public void initializeTypeLoaders() -
createExtensionTypeLoaders
protected void createExtensionTypeLoaders() -
createExtensionTypeloadersImpl
protected void createExtensionTypeloadersImpl() -
getExtensionTypeloaderNames
-
createStandardTypeLoaders
protected void createStandardTypeLoaders() -
maybeCreateModuleTypeLoader
protected void maybeCreateModuleTypeLoader() -
getModuleTraversalList
- Specified by:
getModuleTraversalList
in interfaceIModule
-
buildTraversalList
-
traverse
-
getTypeLoaders
Description copied from interface:IModule
Returns typeloaders of the given class that are local to this module as well as such typeloaders from dependent modules.- Specified by:
getTypeLoaders
in interfaceIModule
- Returns:
-
createAndPushTypeLoader
private ITypeLoader createAndPushTypeLoader(IFileSystemGosuClassRepository classRepository, String className) -
getExtensionClassLoader
-
getExtensionURLs
-
getConstructor
-
equals
-
hashCode
public int hashCode() -
getName
-
setName
-
getAdditionalSourceRoots
-