Interface OutputContainerGroup

All Superinterfaces:
AutoCloseable, Closeable, ContainerGroup, ModuleContainerGroup, PackageContainerGroup

A base definition for an output-oriented container group.

These can behave as if they are module-oriented, or non-module-oriented. It is down to the implementation to mediate access between modules and their files.

Operations on modules should first get or create the module, and then operate on that sub-container group. Operations on non-module packages should operate on this container group directly.

Note that each container group will usually only support one package container group in the outputs. This is due to the JSR-199 API not providing a method for specifying which output location to write files to for legacy-style packages.

Since:
0.0.1
Author:
Ashley Scopes
  • Method Details

    • addPackage

      void addPackage(PathRoot path)
      Add a path to this group.

      Note that this will destroy the class loader if one is already allocated from a previous request.

      If the path points to some form of archive (such as a JAR), then this may open that archive in a new resource internally. If this occurs, then the resource will always be freed by this class by calling Closeable.close().

      Any other closable resources passed to this function will not be closed by this implementation. You must handle the lifecycle of those objects yourself.

      Note that this implementation will only ever allow a single container in the package container groups. If a container is already present, then an exception will be thrown.

      Specified by:
      addPackage in interface PackageContainerGroup
      Parameters:
      path - the path to add.
      Throws:
      IllegalStateException - if a package already exists in this location.
    • addPackage

      void addPackage(Container container)
      Add a container to this group.

      The provided container will be closed when this group is closed.

      Note that this will destroy the class loader if one is already allocated from a previous request.

      Note that this implementation will only ever allow a single container in the package container groups. If a container is already present, then an exception will be thrown.

      Specified by:
      addPackage in interface PackageContainerGroup
      Parameters:
      container - the container to add.
      Throws:
      IllegalStateException - if a package already exists in this location.
    • getLocation

      Get the output-oriented location.
      Specified by:
      getLocation in interface ContainerGroup
      Specified by:
      getLocation in interface ModuleContainerGroup
      Specified by:
      getLocation in interface PackageContainerGroup
      Returns:
      the output-oriented location.
    • getPackages

      Get the package containers in this group.

      Returned packages are presented in the order that they were registered. This is the resolution order that the compiler will use.

      Note that this implementation will only ever return one container in the list due to JSR-199 limitations.

      Specified by:
      getPackages in interface PackageContainerGroup
      Returns:
      the list containing the package container, if it exists. Otherwise, an empty list is returned instead.