org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader
Class ResourceDownloaderFactoryImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader.ResourceDownloaderFactoryImpl
All Implemented Interfaces:
ResourceDownloaderFactory

public class ResourceDownloaderFactoryImpl
extends Object
implements ResourceDownloaderFactory


Field Summary
protected static ResourceDownloaderFactoryImpl singleton
           
 
Constructor Summary
ResourceDownloaderFactoryImpl()
           
 
Method Summary
 ResourceDownloader create(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 operate
 ResourceDownloader create(ResourceDownloaderDelayedFactory factory)
          creates a downloader that will be asked to create a ResourceDownloader when required.
 ResourceDownloader create(URL url)
          creates a basic downloader.
 ResourceDownloader create(URL url, boolean force_no_proxy)
          Creates a basic downloader, where you can force any configured proxy to be avoided.
 ResourceDownloader create(URL url, byte[] postData)
           
 ResourceDownloader create(URL url, Proxy proxy)
           
 ResourceDownloader create(URL url, String postData)
           
 ResourceDownloader create(URL url, String postData, Proxy proxy)
           
 ResourceDownloader create(URL url, String user_name, String password)
           
 ResourceDownloader createWithAutoPluginProxy(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 indirection
 ResourceDownloader 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 failing
static ResourceDownloaderFactory getSingleton()
           
 ResourceDownloader getSourceforgeDownloader(String project_name, String filename)
          Creates a resource downloader which can be used to download a file from a Sourceforge project (from different mirrors).
 ResourceDownloader[] getSourceforgeDownloaders(String project_name, String filename)
          Creates multiple resource downloaders which can be used to download a file from a Sourceforge project (from different mirrors).
 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 period
 ResourceDownloader 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, File download_directory)
          Download a torrent's data to the given download location
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

singleton

protected static ResourceDownloaderFactoryImpl singleton
Constructor Detail

ResourceDownloaderFactoryImpl

public ResourceDownloaderFactoryImpl()
Method Detail

getSingleton

public static ResourceDownloaderFactory getSingleton()

create

public ResourceDownloader create(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 interface ResourceDownloaderFactory
Returns:

create

public ResourceDownloader create(URL url)
Description copied from interface: ResourceDownloaderFactory
creates a basic downloader. current url must be http or https

Specified by:
create in interface ResourceDownloaderFactory
Returns:

createWithAutoPluginProxy

public ResourceDownloader createWithAutoPluginProxy(URL url)
Specified by:
createWithAutoPluginProxy in interface ResourceDownloaderFactory

create

public ResourceDownloader create(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 interface ResourceDownloaderFactory

create

public ResourceDownloader create(URL url,
                                 Proxy proxy)
Specified by:
create in interface ResourceDownloaderFactory

create

public ResourceDownloader create(URL url,
                                 String postData)
Specified by:
create in interface ResourceDownloaderFactory
Returns:

create

public ResourceDownloader create(URL url,
                                 String postData,
                                 Proxy proxy)
Specified by:
create in interface ResourceDownloaderFactory

create

public ResourceDownloader create(URL url,
                                 byte[] postData)
Specified by:
create in interface ResourceDownloaderFactory

create

public ResourceDownloader create(URL url,
                                 String user_name,
                                 String password)
Specified by:
create in interface ResourceDownloaderFactory

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 interface ResourceDownloaderFactory
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 interface ResourceDownloaderFactory
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 interface ResourceDownloaderFactory
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 interface ResourceDownloaderFactory

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 interface ResourceDownloaderFactory

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 interface ResourceDownloaderFactory

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 interface ResourceDownloaderFactory

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 interface ResourceDownloaderFactory
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 interface ResourceDownloaderFactory
persistent - whether or not the d/l will be retained over az stop/start
Returns:

getTorrentDownloader

public ResourceDownloader getTorrentDownloader(ResourceDownloader downloader,
                                               boolean persistent,
                                               File download_directory)
Description copied from interface: ResourceDownloaderFactory
Download a torrent's data to the given download location

Specified by:
getTorrentDownloader in interface ResourceDownloaderFactory
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 interface ResourceDownloaderFactory
Returns:

getSourceforgeDownloaders

public ResourceDownloader[] getSourceforgeDownloaders(String project_name,
                                                      String filename)
Description copied from interface: ResourceDownloaderFactory
Creates multiple resource downloaders which can be used to download a file from a Sourceforge project (from different mirrors). The resulting downloaders can then be passed to a method such as ResourceDownloaderFactory.getRandomDownloader(ResourceDownloader[]).

Specified by:
getSourceforgeDownloaders in interface ResourceDownloaderFactory

getSourceforgeDownloader

public ResourceDownloader getSourceforgeDownloader(String project_name,
                                                   String filename)
Description copied from interface: ResourceDownloaderFactory
Creates a resource downloader which can be used to download a file from a Sourceforge project (from different mirrors).

Specified by:
getSourceforgeDownloader in interface ResourceDownloaderFactory