Class ResourceDownloaderFactoryImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderFactoryImpl
-
- All Implemented Interfaces:
ResourceDownloaderFactory
public class ResourceDownloaderFactoryImpl extends java.lang.Object implements ResourceDownloaderFactory
-
-
Field Summary
Fields Modifier and Type Field Description private static LogIDs
LOGID
protected static ResourceDownloaderFactoryImpl
singleton
-
Constructor Summary
Constructors Constructor Description ResourceDownloaderFactoryImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourceDownloader
create(ResourceDownloaderDelayedFactory factory)
creates a downloader that will be asked to create a ResourceDownloader when required.ResourceDownloader
create(java.io.File file)
Creates a downloader for a local file - in particular this is useful for installing a plugin from a local file as the installer required ResourceDownloader instances to operateResourceDownloader
create(java.net.URL url)
creates a basic downloader.ResourceDownloader
create(java.net.URL url, boolean force_no_proxy)
Creates a basic downloader, where you can force any configured proxy to be avoided.ResourceDownloader
create(java.net.URL url, byte[] postData)
ResourceDownloader
create(java.net.URL url, java.lang.String postData)
ResourceDownloader
create(java.net.URL url, java.lang.String user_name, java.lang.String password)
ResourceDownloader
create(java.net.URL url, java.lang.String postData, java.net.Proxy proxy)
ResourceDownloader
create(java.net.URL url, java.net.Proxy proxy)
ResourceDownloader
createWithAutoPluginProxy(java.net.URL url)
ResourceDownloader
getAlternateDownloader(ResourceDownloader[] downloaders)
Gets a downloader that will cycle through a list of downloaders until a download succeeds.ResourceDownloader
getAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try)
Gets a downloader that will cycle through a list of downloaders until a download succeeds.protected ResourceDownloader
getAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try, boolean random)
ResourceDownloader
getMetaRefreshDownloader(ResourceDownloader downloader)
gets a downloader that will automatically follow META refresh tags Will only do a single level of indirectionResourceDownloader
getRandomDownloader(ResourceDownloader[] downloaders)
Gets a downloader that will cycle through a list of downloaders until a download succeeds.ResourceDownloader
getRandomDownloader(ResourceDownloader[] downloaders, int max_to_try)
Gets a downloader that will cycle through a list of downloaders until a download succeeds.ResourceDownloader
getRetryDownloader(ResourceDownloader downloader, int retry_count)
gets a downloader that will retry a number of times before failingstatic ResourceDownloaderFactory
getSingleton()
ResourceDownloader
getSuffixBasedDownloader(ResourceDownloader _downloader)
Returns a downloader that does something sensible based on the url suffix.ResourceDownloader
getTimeoutDownloader(ResourceDownloader downloader, int timeout_millis)
gets a downloader that will timeout after a given periodResourceDownloader
getTorrentDownloader(ResourceDownloader downloader, boolean persistent)
Given a downloader that will download a torrent, this will download the torrent data itself.ResourceDownloader
getTorrentDownloader(ResourceDownloader downloader, boolean persistent, java.io.File download_directory)
Download a torrent's data to the given download location
-
-
-
Field Detail
-
LOGID
private static final LogIDs LOGID
-
singleton
protected static ResourceDownloaderFactoryImpl singleton
-
-
Method Detail
-
getSingleton
public static ResourceDownloaderFactory getSingleton()
-
create
public ResourceDownloader create(java.io.File file)
Description copied from interface:ResourceDownloaderFactory
Creates a downloader for a local file - in particular this is useful for installing a plugin from a local file as the installer required ResourceDownloader instances to operate- Specified by:
create
in interfaceResourceDownloaderFactory
- Returns:
-
create
public ResourceDownloader create(java.net.URL url)
Description copied from interface:ResourceDownloaderFactory
creates a basic downloader. current url must be http or https- Specified by:
create
in interfaceResourceDownloaderFactory
- Returns:
-
createWithAutoPluginProxy
public ResourceDownloader createWithAutoPluginProxy(java.net.URL url)
- Specified by:
createWithAutoPluginProxy
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(java.net.URL url, boolean force_no_proxy)
Description copied from interface:ResourceDownloaderFactory
Creates a basic downloader, where you can force any configured proxy to be avoided.- Specified by:
create
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(java.net.URL url, java.net.Proxy proxy)
- Specified by:
create
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(java.net.URL url, java.lang.String postData)
- Specified by:
create
in interfaceResourceDownloaderFactory
- Returns:
-
create
public ResourceDownloader create(java.net.URL url, java.lang.String postData, java.net.Proxy proxy)
- Specified by:
create
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(java.net.URL url, byte[] postData)
- Specified by:
create
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(java.net.URL url, java.lang.String user_name, java.lang.String password)
- Specified by:
create
in interfaceResourceDownloaderFactory
-
create
public ResourceDownloader create(ResourceDownloaderDelayedFactory factory)
Description copied from interface:ResourceDownloaderFactory
creates a downloader that will be asked to create a ResourceDownloader when required. Useful when used in combination with an alternate downloader so that time isn't wasted creating downloaders for subsequent possibilities if the first one succeeds- Specified by:
create
in interfaceResourceDownloaderFactory
- Returns:
-
getRetryDownloader
public ResourceDownloader getRetryDownloader(ResourceDownloader downloader, int retry_count)
Description copied from interface:ResourceDownloaderFactory
gets a downloader that will retry a number of times before failing- Specified by:
getRetryDownloader
in interfaceResourceDownloaderFactory
- Returns:
-
getTimeoutDownloader
public ResourceDownloader getTimeoutDownloader(ResourceDownloader downloader, int timeout_millis)
Description copied from interface:ResourceDownloaderFactory
gets a downloader that will timeout after a given period- Specified by:
getTimeoutDownloader
in interfaceResourceDownloaderFactory
- Returns:
-
getAlternateDownloader
public ResourceDownloader getAlternateDownloader(ResourceDownloader[] downloaders)
Description copied from interface:ResourceDownloaderFactory
Gets a downloader that will cycle through a list of downloaders until a download succeeds. The resource downloaders will be tried in order.- Specified by:
getAlternateDownloader
in interfaceResourceDownloaderFactory
-
getAlternateDownloader
public ResourceDownloader getAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try)
Description copied from interface:ResourceDownloaderFactory
Gets a downloader that will cycle through a list of downloaders until a download succeeds. The resource downloaders will be tried in order.- Specified by:
getAlternateDownloader
in interfaceResourceDownloaderFactory
-
getRandomDownloader
public ResourceDownloader getRandomDownloader(ResourceDownloader[] downloaders)
Description copied from interface:ResourceDownloaderFactory
Gets a downloader that will cycle through a list of downloaders until a download succeeds. The resource downloaders will be tried randomly.- Specified by:
getRandomDownloader
in interfaceResourceDownloaderFactory
-
getRandomDownloader
public ResourceDownloader getRandomDownloader(ResourceDownloader[] downloaders, int max_to_try)
Description copied from interface:ResourceDownloaderFactory
Gets a downloader that will cycle through a list of downloaders until a download succeeds. The resource downloaders will be tried randomly.- Specified by:
getRandomDownloader
in interfaceResourceDownloaderFactory
-
getAlternateDownloader
protected ResourceDownloader getAlternateDownloader(ResourceDownloader[] downloaders, int max_to_try, boolean random)
-
getMetaRefreshDownloader
public ResourceDownloader getMetaRefreshDownloader(ResourceDownloader downloader)
Description copied from interface:ResourceDownloaderFactory
gets a downloader that will automatically follow META refresh tags Will only do a single level of indirection- Specified by:
getMetaRefreshDownloader
in interfaceResourceDownloaderFactory
- Returns:
-
getTorrentDownloader
public ResourceDownloader getTorrentDownloader(ResourceDownloader downloader, boolean persistent)
Description copied from interface:ResourceDownloaderFactory
Given a downloader that will download a torrent, this will download the torrent data itself. Note that the torrent MUST contain only a single file (although a future enhancement may return a ZIP input stream for multi-file torrents)- Specified by:
getTorrentDownloader
in interfaceResourceDownloaderFactory
persistent
- whether or not the d/l will be retained over az stop/start- Returns:
-
getTorrentDownloader
public ResourceDownloader getTorrentDownloader(ResourceDownloader downloader, boolean persistent, java.io.File download_directory)
Description copied from interface:ResourceDownloaderFactory
Download a torrent's data to the given download location- Specified by:
getTorrentDownloader
in interfaceResourceDownloaderFactory
- Returns:
-
getSuffixBasedDownloader
public ResourceDownloader getSuffixBasedDownloader(ResourceDownloader _downloader)
Description copied from interface:ResourceDownloaderFactory
Returns a downloader that does something sensible based on the url suffix. In particular will return a torrent downloader if the URL ends with ".torrent" The decision is made based on a random child downloader, so don't mix URL suffixes below this point in the hierarchy- Specified by:
getSuffixBasedDownloader
in interfaceResourceDownloaderFactory
- Returns:
-
-