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 classSingleton extension classloader. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List<IDirectory>private List<IDirectory>private List<Dependency>private final IExecutionEnvironmentprivate ClassLoaderprivate final IFileSystemGosuClassRepositoryprivate ModuleTypeLoaderprivate ClassLoaderprivate INativeModuleprivate Stringprivate LocklessLazyVar<IModule[]>Fields inherited from interface gw.lang.reflect.module.IModule
CONFIG_RESOURCE_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidprivate List<IDirectory>addFromManifestClassPath(List<IDirectory> classpath) This will add items to the Gosu classpath, but only under very specific circumstances.private IModule[]voidconfigurePaths(List<IDirectory> classpath, List<IDirectory> sourcePaths, List<IDirectory> backingSourcePaths) Configure both source and Java classpaths of the module in a semi-automated way.private ITypeLoadercreateAndPushTypeLoader(IFileSystemGosuClassRepository classRepository, String className) protected voidprotected voidprotected voidvoidbooleanprotected List<IDirectory>private ConstructorgetConstructor(Class<?> loaderClass, Class... argTypes) final IExecutionEnvironmentprivate ClassLoaderprivate 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.inthashCode()voidprotected voidvoidprivate static voidscanPaths(List<IDirectory> paths, Set<String> extensions, List<IDirectory> roots) voidsetBackingSourcePath(List<IDirectory> backingSourcePath) voidsetDependencies(List<Dependency> newDeps) voidsetExcludedPaths(List<IDirectory> paths) voidsetJavaClassPath(List<IDirectory> classpath) voidsetModuleTypeLoader(ModuleTypeLoader modTypeLoader) voidvoidsetNativeModule(INativeModule nativeModule) voidsetSourcePath(List<IDirectory> sourcePaths) toString()protected voidMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
getExecutionEnvironmentin interfaceIModule
-
getFileRepository
- Specified by:
getFileRepositoryin interfaceIModule
-
setDependencies
- Specified by:
setDependenciesin interfaceIModule
-
getDependencies
- Specified by:
getDependenciesin 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:
addDependencyin interfaceIModule
-
removeDependency
- Specified by:
removeDependencyin interfaceIModule
-
getSourcePath
- Specified by:
getSourcePathin interfaceIModule- Returns:
- The path[s] having source files that should be exposed to this module.
-
setSourcePath
- Specified by:
setSourcePathin interfaceIModule
-
getExcludedPaths
- Specified by:
getExcludedPathsin interfaceIModule
-
setExcludedPaths
- Specified by:
setExcludedPathsin interfaceIModule
-
getModuleClassLoader
Description copied from interface:IModuleGet class loader, associated with this module.- Specified by:
getModuleClassLoaderin interfaceIModule- Returns:
-
disposeLoader
public void disposeLoader()- Specified by:
disposeLoaderin interfaceIModule
-
scanPaths
private static void scanPaths(List<IDirectory> paths, Set<String> extensions, List<IDirectory> roots) -
getOutputPath
- Specified by:
getOutputPathin interfaceIModule
-
getModuleTypeLoader
- Specified by:
getModuleTypeLoaderin interfaceIModule
-
setModuleTypeLoader
-
configurePaths
public void configurePaths(List<IDirectory> classpath, List<IDirectory> sourcePaths, List<IDirectory> backingSourcePaths) Description copied from interface:IModuleConfigure 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:
configurePathsin 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:
getJavaClassPathin interfaceIModule
-
setJavaClassPath
- Specified by:
setJavaClassPathin interfaceIModule
-
getBackingSourcePath
- Specified by:
getBackingSourcePathin interfaceIModule
-
setBackingSourcePath
- Specified by:
setBackingSourcePathin interfaceIModule
-
toString
-
getNativeModule
- Specified by:
getNativeModulein 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:
setNativeModulein 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:
getModuleTraversalListin interfaceIModule
-
buildTraversalList
-
traverse
-
getTypeLoaders
Description copied from interface:IModuleReturns typeloaders of the given class that are local to this module as well as such typeloaders from dependent modules.- Specified by:
getTypeLoadersin interfaceIModule- Returns:
-
createAndPushTypeLoader
private ITypeLoader createAndPushTypeLoader(IFileSystemGosuClassRepository classRepository, String className) -
getExtensionClassLoader
-
getExtensionURLs
-
getConstructor
-
equals
-
hashCode
public int hashCode() -
getName
-
setName
-
getAdditionalSourceRoots
-