Class ClasspathTransporterFactory

  • All Implemented Interfaces:
    TransporterFactory

    @Named("classpath")
    public final class ClasspathTransporterFactory
    extends java.lang.Object
    implements TransporterFactory
    A transporter factory for repositories using the classpath: protocol. As example, getting an item named some/file.txt from a repository with the URL classpath:/base/dir results in retrieving the resource base/dir/some/file.txt from the classpath. The classpath to load the resources from is given via a ClassLoader that can be configured via the configuration property CONFIG_PROP_CLASS_LOADER.

    Note: Such repositories are read-only and uploads to them are generally not supported.

    • Field Detail

      • CONFIG_PROP_CLASS_LOADER

        public static final java.lang.String CONFIG_PROP_CLASS_LOADER
        The key in the repository session's configuration properties used to store a ClassLoader from which resources should be retrieved. If unspecified, the context class loader of the current thread will be used.
        See Also:
        Constant Field Values
      • priority

        private float priority
    • Constructor Detail

      • ClasspathTransporterFactory

        public ClasspathTransporterFactory()
        Creates an (uninitialized) instance of this transporter factory. Note: In case of manual instantiation by clients, the new factory needs to be configured via its various mutators before first use or runtime errors will occur.
    • Method Detail

      • getPriority

        public float getPriority()
        Description copied from interface: TransporterFactory
        The priority of this factory. When multiple factories can handle a given repository, factories with higher priority are preferred over those with lower priority.
        Specified by:
        getPriority in interface TransporterFactory
        Returns:
        The priority of this factory.
      • setPriority

        public ClasspathTransporterFactory setPriority​(float priority)
        Sets the priority of this component.
        Parameters:
        priority - The priority.
        Returns:
        This component for chaining, never null.
      • newInstance

        public Transporter newInstance​(RepositorySystemSession session,
                                       RemoteRepository repository)
                                throws NoTransporterException
        Description copied from interface: TransporterFactory
        Tries to create a transporter for the specified remote repository. Typically, a factory will inspect RemoteRepository.getProtocol() to determine whether it can handle a repository.
        Specified by:
        newInstance in interface TransporterFactory
        Parameters:
        session - The repository system session from which to configure the transporter, must not be null. In particular, a transporter should obey the timeouts configured for the session.
        repository - The remote repository to create a transporter for, must not be null.
        Returns:
        The transporter for the given repository, never null.
        Throws:
        NoTransporterException - If the factory cannot create a transporter for the specified remote repository.