FileDocCategorySizeDatePackage
Test.javaAPI DocAzureus 3.0.3.45838Wed Mar 28 18:28:10 BST 2007org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader

Test

public class Test extends Object implements ResourceDownloaderListener, Plugin
author
parg

Fields Summary
Constructors Summary
Methods Summary
public booleancompleted(ResourceDownloader downloader, java.io.InputStream data)

		System.out.println( "Completed" );
		
		return( true );
	
public voidfailed(ResourceDownloader downloader, ResourceDownloaderException e)

		System.out.println( "Failed");
		
		Debug.printStackTrace( e );
	
public voidinitialize(PluginInterface pi)

		try{
			ResourceDownloaderFactory	rdf = pi.getUtilities().getResourceDownloaderFactory();
			
			// ResourceDownloader rd_t = rdf.create(new URL("http://play.aelitis.com/torrents/Azureus2201-B22.jar.torrent"));
			
			//rd_t = rdf.getMetaRefreshDownloader(rd_t);
			
			//rd_t = rdf.getRetryDownloader(rd_t, 3);
			
			//rd_t = rdf.getTimeoutDownloader(rd_t,1000);
			
			//rd_t = rdf.getTorrentDownloader(rd_t, true, new File("C:\\temp"));

			//ResourceDownloader rd_u = rdf.create(new URL("http://azureus.sourceforge.net/cvs/Azureus2201-B22.jar"));
			
			//rd_u = rdf.getMetaRefreshDownloader(rd_u);
			
			//rd_u = rdf.getRetryDownloader(rd_u, 3);
			
			//rd_u = rdf.getSuffixBasedDownloader(rd_u);

			ResourceDownloader rd_u = rdf.create( new URL( "http://torrents.aelitis.com:88/files/Azureus3009-B5.jar" ));
			
			// rd_u = rdf.getTorrentDownloader( rd_u, true );

			rd_u.addListener(
					new ResourceDownloaderAdapter()
				    {
						public boolean
				        completed(
				        	ResourceDownloader 	downloader,
				            InputStream 		data )
						{
				        	System.out.println( "complete" );

							return( true );
						}
						
				        public void 
						reportPercentComplete(
							ResourceDownloader 	downloader, 
							final int 			percentage )
				        {
				        	System.out.println( "percentage = " + percentage );
				        }
				            
				    	public void
				    	reportAmountComplete(
				    		ResourceDownloader	downloader,
				    		long				amount )
				    	{	
				    		System.out.println( "amount = " + amount );
				    	}
				    	
				        public void 
						reportActivity(
							ResourceDownloader	downloader, 
							String 				activity) 
				        {
				        	System.out.println( "activity = " + activity );
			            }

				        public void 
						failed(
							ResourceDownloader 			downloader,
							ResourceDownloaderException e) 
				        {
				        	System.out.println( "failed" );
				        	
				        	e.printStackTrace();
				        }
				    });

			InputStream is = rd_u.download();

			FileUtil.copyFile( is, new File( "C:\\temp\\file.jar" ));
			
			is.close();
			
			/*
			ResourceDownloader top_downloader =
				rdf.getAlternateDownloader(
						new ResourceDownloader[]{rd_t,rd_u,});

			final long totalk = top_downloader.getSize();
			
			top_downloader.addListener(
				new ResourceDownloaderListener()
			    {
					public boolean
			        completed(
			        		final ResourceDownloader downloader,
			                InputStream data )
					{
			        	System.out.println( "top - complete" );

						return( true );
					}
					
			        public void 
					reportPercentComplete(
						ResourceDownloader 	downloader, 
						final int 			percentage )
			        {
			        	System.out.println( "top - percentage = " + percentage );
			        }
			            

			        public void 
					reportActivity(
						ResourceDownloader	downloader, 
						String 				activity) 
			        {
			        	System.out.println( "top - activity = " + activity );
		            }

			        public void 
					failed(
						ResourceDownloader 			downloader,
						ResourceDownloaderException e) 
			        {
			        	System.out.println( "top - failed" );
			        }
			    });
					
			top_downloader.asyncDownload();
				*/
			
		}catch( Throwable e ){
			
			Debug.printStackTrace( e );
		}
	
public static voidmain(java.lang.String[] args)

		try{
			PluginManager.registerPlugin( Test.class );
										
			PluginManager.startAzureus( PluginManager.UI_NONE, new Properties() );
			
		}catch( Throwable e ){
			
			Debug.printStackTrace( e );
		}
	
public voidreportActivity(ResourceDownloader downloader, java.lang.String activity)

		System.out.println( "activity = " + activity );
	
public voidreportAmountComplete(ResourceDownloader downloader, long amount)

	
	
public voidreportPercentComplete(ResourceDownloader downloader, int percentage)

		System.out.println( "percent = " + percentage );