Class Module

java.lang.Object
gw.internal.gosu.module.Module
All Implemented Interfaces:
IModule
Direct Known Subclasses:
GlobalModule, JreModule

public class Module extends Object implements IModule
  • Field Details

  • Constructor Details

  • Method Details

    • getExecutionEnvironment

      public final IExecutionEnvironment getExecutionEnvironment()
      Specified by:
      getExecutionEnvironment in interface IModule
    • getFileRepository

      public IFileSystemGosuClassRepository getFileRepository()
      Specified by:
      getFileRepository in interface IModule
    • setDependencies

      public void setDependencies(List<Dependency> newDeps)
      Specified by:
      setDependencies in interface IModule
    • getDependencies

      public List<Dependency> getDependencies()
      Specified by:
      getDependencies in interface IModule
      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

      public void addDependency(Dependency d)
      Specified by:
      addDependency in interface IModule
    • removeDependency

      public void removeDependency(Dependency d)
      Specified by:
      removeDependency in interface IModule
    • getSourcePath

      public List<IDirectory> getSourcePath()
      Specified by:
      getSourcePath in interface IModule
      Returns:
      The path[s] having source files that should be exposed to this module.
    • setSourcePath

      public void setSourcePath(List<IDirectory> sourcePaths)
      Specified by:
      setSourcePath in interface IModule
    • getExcludedPaths

      public List<IDirectory> getExcludedPaths()
      Specified by:
      getExcludedPaths in interface IModule
    • setExcludedPaths

      public void setExcludedPaths(List<IDirectory> paths)
      Specified by:
      setExcludedPaths in interface IModule
    • getModuleClassLoader

      public ClassLoader getModuleClassLoader()
      Description copied from interface: IModule
      Get class loader, associated with this module.
      Specified by:
      getModuleClassLoader in interface IModule
      Returns:
    • disposeLoader

      public void disposeLoader()
      Specified by:
      disposeLoader in interface IModule
    • scanPaths

      private static void scanPaths(List<IDirectory> paths, Set<String> extensions, List<IDirectory> roots)
    • getOutputPath

      public IDirectory getOutputPath()
      Specified by:
      getOutputPath in interface IModule
    • getModuleTypeLoader

      public ModuleTypeLoader getModuleTypeLoader()
      Specified by:
      getModuleTypeLoader in interface IModule
    • setModuleTypeLoader

      public void setModuleTypeLoader(ModuleTypeLoader modTypeLoader)
    • 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 interface IModule
      Parameters:
      classpath - path to types not directly in the module's sources e.g., jar files containing .class files and other types/resources
      sourcePaths - 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 directories
      backingSourcePaths - path to sources corresponding with the classpath parameter (intended for IDE use)
    • addFromManifestClassPath

      private List<IDirectory> addFromManifestClassPath(List<IDirectory> classpath)

      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

      public List<IDirectory> getJavaClassPath()
      Specified by:
      getJavaClassPath in interface IModule
    • setJavaClassPath

      public void setJavaClassPath(List<IDirectory> classpath)
      Specified by:
      setJavaClassPath in interface IModule
    • getBackingSourcePath

      public List<IDirectory> getBackingSourcePath()
      Specified by:
      getBackingSourcePath in interface IModule
    • setBackingSourcePath

      public void setBackingSourcePath(List<IDirectory> backingSourcePath)
      Specified by:
      setBackingSourcePath in interface IModule
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getNativeModule

      public Object getNativeModule()
      Specified by:
      getNativeModule in interface IModule
      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

      public void setNativeModule(INativeModule nativeModule)
      Specified by:
      setNativeModule in interface IModule
    • initializeTypeLoaders

      public void initializeTypeLoaders()
    • createExtensionTypeLoaders

      protected void createExtensionTypeLoaders()
    • createExtensionTypeloadersImpl

      protected void createExtensionTypeloadersImpl()
    • getExtensionTypeloaderNames

      private Set<String> getExtensionTypeloaderNames()
    • createStandardTypeLoaders

      protected void createStandardTypeLoaders()
    • maybeCreateModuleTypeLoader

      protected void maybeCreateModuleTypeLoader()
    • getModuleTraversalList

      public final IModule[] getModuleTraversalList()
      Specified by:
      getModuleTraversalList in interface IModule
    • buildTraversalList

      private IModule[] buildTraversalList()
    • traverse

      protected void traverse(IModule theModule, List<IModule> traversalList)
    • getTypeLoaders

      public <T extends ITypeLoader> List<? extends T> getTypeLoaders(Class<T> typeLoaderClass)
      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 interface IModule
      Returns:
    • createAndPushTypeLoader

      private ITypeLoader createAndPushTypeLoader(IFileSystemGosuClassRepository classRepository, String className)
    • getExtensionClassLoader

      private ClassLoader getExtensionClassLoader()
    • getExtensionURLs

      private URL[] getExtensionURLs()
    • getConstructor

      private Constructor getConstructor(Class<?> loaderClass, Class... argTypes)
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getName

      public String getName()
      Specified by:
      getName in interface IModule
      Returns:
      A unique name relative to all other modules in a given execution environment.
    • setName

      public void setName(String name)
      Specified by:
      setName in interface IModule
    • getAdditionalSourceRoots

      protected List<IDirectory> getAdditionalSourceRoots()