Interface ArchiveDetector

  • All Known Implementing Classes:
    CarDetector, EarDetector, EjbJarDetector, OSGiArchiveDetector, RarDetector, WarDetector

    @Contract
    @Singleton
    public interface ArchiveDetector
    ArchiveHandlers are considered part of container implementation, hence are not available until the corresponding container is setup. On the other hand, ArchiveDetectors are pretty light weight and used for selecting the appropriate ArchiveHandler. ArchiveDetectors are supposed to be part of the connector module of a container. Each detector has a rank as returned by rank() which can be used to order the detectors as archive detection.

    This is a container pluggability interface.

    Author:
    [email protected]
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      ArchiveHandler getArchiveHandler()
      Return a ArchiveHandler that can handle the archive recognised by this ArchiveDetector.
      ArchiveType getArchiveType()
      Returns the type of the deployment unit or archive or module whichever way you want to call what's being depoyed.
      boolean handles​(ReadableArchive archive)
      This method is used to detect the archive type.
      int rank()
      Since archive detection logic is typically executed at a very early stage of deployment, it is mainly heuristic.
    • Method Detail

      • rank

        int rank()
        Since archive detection logic is typically executed at a very early stage of deployment, it is mainly heuristic. So some detectors can incorrectly recognize archives that they actually don't support. e.g., take a war file inside an ear file. and asssume that the war file contains some .jsp files. The archive detector responsible for handling the war file could be fooled into thinking the ear file is a war file since it contains jsp files, yet in reality, it only owns one of the sub archive bundled inside the composite ear file. To deal with such situations, each detector can specify a rank which can be used to order the detectors. Since detectors can come from separate authors, rank of a detector must be configurable in an installation. The order in which detectors are used during archive detection is based on the rank. Lower the integer value as returned by this method, earlier it is used during detection.
        Returns:
        the rank of this detector
      • handles

        boolean handles​(ReadableArchive archive)
                 throws IOException
        This method is used to detect the archive type. If this detector can recognize the given archive, then it must return true.
        Parameters:
        archive -
        Returns:
        Throws:
        IOException
      • getArchiveHandler

        ArchiveHandler getArchiveHandler()
        Return a ArchiveHandler that can handle the archive recognised by this ArchiveDetector.
        Returns:
      • getArchiveType

        ArchiveType getArchiveType()
        Returns the type of the deployment unit or archive or module whichever way you want to call what's being depoyed. Each archive handler is responsible for only one type of archive and the type of the archive is represented by ArchiveType.
        Returns:
        the type of the archive or deployment unit that can be detected by this detector