FileDocCategorySizeDatePackage
TRTrackerAnnouncerFactoryImpl.javaAPI DocAzureus 3.0.3.43614Mon Jan 22 09:08:16 GMT 2007org.gudy.azureus2.core3.tracker.client.impl

TRTrackerAnnouncerFactoryImpl

public class TRTrackerAnnouncerFactoryImpl extends Object
author
parg

Fields Summary
protected static List
listeners
protected static List
clients
protected static AEMonitor
class_mon
Constructors Summary
Methods Summary
public static voidaddListener(TRTrackerAnnouncerFactoryListener l)

		List	clients_copy;
		
		try{
			class_mon.enter();
		
			listeners.add(l);
			
			clients_copy = new ArrayList( clients );
	
		}finally{
			
			class_mon.exit();
		}
		
		for (int i=0;i<clients_copy.size();i++){
			
			try{
				l.clientCreated((TRTrackerAnnouncer)clients_copy.get(i));
				
			}catch( Throwable e ){
				
				Debug.printStackTrace(e);
			}
		}
	
public static TRTrackerAnnouncercreate(TOTorrent torrent, java.lang.String[] networks, boolean manual)


	  
	
				
				
					 
		
		 
	
		TRTrackerAnnouncer	client;
		
		if ( TorrentUtils.isDecentralised( torrent )){
			
			client	= new TRTrackerDHTAnnouncerImpl( torrent, networks, manual );
			
		}else{
			
			client = new TRTrackerBTAnnouncerImpl( torrent, networks, manual );
		}
		
		if ( !manual ){
			
			List	listeners_copy	= new ArrayList();
			
			try{
				class_mon.enter();
				
				clients.add( client );
			
				listeners_copy = new ArrayList( listeners );
		
			}finally{
				
				class_mon.exit();
			}
			
			for (int i=0;i<listeners_copy.size();i++){
				
				try{
					((TRTrackerAnnouncerFactoryListener)listeners_copy.get(i)).clientCreated( client );
					
				}catch( Throwable e ){
					
					Debug.printStackTrace(e);
				}
			}
		}
		
		return( client );
	
public static voiddestroy(TRTrackerAnnouncer client)

		if ( !client.isManual()){
			
			List	listeners_copy	= new ArrayList();
			
			try{
				class_mon.enter();
			
				clients.remove( client );
				
				listeners_copy	= new ArrayList( listeners );
	
			}finally{
				
				class_mon.exit();
			}
			
			for (int i=0;i<listeners_copy.size();i++){
				
				try{
					((TRTrackerAnnouncerFactoryListener)listeners_copy.get(i)).clientDestroyed( client );
					
				}catch( Throwable e ){
					
					Debug.printStackTrace(e);
				}
			}
		}
	
public static voidremoveListener(TRTrackerAnnouncerFactoryListener l)

		try{
			class_mon.enter();
		
			listeners.remove(l);
			
		}finally{
			
			class_mon.exit();
		}