Interface ArchiveHandler

  • All Known Subinterfaces:
    CompositeHandler
    All Known Implementing Classes:
    AbstractArchiveHandler, CarHandler, EarHandler, EjbJarHandler, GenericHandler, OSGiArchiveHandler, RarHandler, WarHandler

    @Contract
    public interface ArchiveHandler
    ArchiveHandlers are handling certain archive type. An archive has a unique type which is usually defines how classes and resources are loaded from the archive. An archive is also known as a module. It represents a unit of deployment. ArchiveHandler should be stateless objects although the implementations of this contract can control that using the scope element of the @Service annotation.
    Author:
    Jerome Dochez, Sanjeeb Sahoo
    • Method Detail

      • getDefaultApplicationName

        String getDefaultApplicationName​(ReadableArchive archive)
        Returns the default name by which the specified archive can be identified.

        The default name is used, for example, during deployment if no name was specified explicitly as part of the deployment request.

        Parameters:
        archive - the archive for which to provide the default name
        Returns:
        the default name for identifying the specified archive
      • getVersionIdentifier

        String getVersionIdentifier​(ReadableArchive archive)
        Returns the version identifier by which the specified archive can be deployed.

        The version identifier is used during deployment if no version identifier was specified null must be returned

        Parameters:
        archive - the archive for which to provide the version identifier
        Returns:
        the version identifier for versioning the deployment archive or null
      • handles

        boolean handles​(ReadableArchive archive)
                 throws IOException
        Returns true if this handler understands the specified archive and can process it.
        Throws:
        IOException - The implementation of this method is expected to interact with the given archive, and if methods on ReadableArchive throws an IOException, it can be simply tunneled to the caller.
      • getClassLoader

        ClassLoader getClassLoader​(ClassLoader parent,
                                   DeploymentContext context)
        Creates a classloader that can load code from inside the archive.
        Parameters:
        parent - The newly created classloader to be returned must eventually delegate to this classloader. (This classloader is capable of resolving APIs and other things that the container
        context -
      • expand

        void expand​(ReadableArchive source,
                    WritableArchive target,
                    DeploymentContext context)
             throws IOException
        Prepares the jar file to a format the ApplicationContainer is expecting. This could be just a pure unzipping of the jar or nothing at all.
        Parameters:
        source - of the expanding
        target - of the expanding
        context -
        Throws:
        IOException
      • getManifest

        Manifest getManifest​(ReadableArchive archive)
                      throws IOException
        Returns the manifest file for this archive, this file is usually located at the META-INF/MANIFEST location, however, certain archive type can change this default location or use another mean of expressing manifest information.
        Parameters:
        archive - file
        Returns:
        manifest instance or null if this archive has no manifest
        Throws:
        IOException
      • getClassPathURIs

        List<URI> getClassPathURIs​(ReadableArchive archive)
        Returns the classpath URIs for this archive.
        Parameters:
        archive - file
        Returns:
        classpath URIs for this archive
      • requiresAnnotationScanning

        boolean requiresAnnotationScanning​(ReadableArchive archive)
        Returns whether this archive requires annotation scanning.
        Parameters:
        archive - file
        Returns:
        whether this archive requires annotation scanning